override locale in datebox

205 views
Skip to first unread message

HamsterofDeath

unread,
Jun 15, 2011, 9:12:31 AM6/15/11
to Google Web Toolkit
hi,

i've been trying to figure this out for hours.
i have a simple datebox. in swing, i'd just take my locale and apply
it to a dateformatter. using the gwt, i don't have a locale
(LocaleInfo.getAvailableLocaleNames() only returns "default") and i
don't have a dateformatter (not available in client code).

what can i do now? i just want to make the datebox format the date
according to a specific locale. why isn't there a simple setter or
something?

John A. Tamplin

unread,
Jun 16, 2011, 11:19:31 PM6/16/11
to google-we...@googlegroups.com
GWT is only running one locale at a time -- you specify the set of locales you want to build your app with, and then only the strings / formats for that locale are downloaded to the user.  See http://code.google.com/webtoolkit/doc/latest/DevGuideI18nLocale.html for more info.

Once you set the locales you want, then your date box will be formatted appropriately for the locale it is running in.

Dennis Haupt

unread,
Jun 17, 2011, 1:12:54 PM6/17/11
to google-we...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

my requirement is to be able to change the locale on the fly. i've
cheated by asking the server for a date format which i get out of a
simpledateformat via reflection.

> --
> You received this message because you are subscribed to the Google
> Groups "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/cZNcXsiKyPcJ.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJN+4sVAAoJENRtux+h35aGswwQAKp0IUFgs9cLPeSyPbUcG+5z
78Z6OG3F34u49dJpjLaN4OhGlcgY1JTZmnhAaRdUeVdpHEYDQSd48JlQLKtHOD4J
MJzi8JaHPkGvcSu9M0NUnaqROHgOFPvDdlkULJ9hMD1WBXmVLwLBHStvEzTAVl+b
yurWxUtto7mxR0adO1FFyVJ5HjgYtdrm4kb8h+U6krGvSJmBdwSFr2Xk4QD+8Aav
L2QG59ITJ0k5ZB5cYunrL1STcqBRscIOcbphBGeXG7djDROSPh/E1sp91z2ywV4T
dQHlX2x+B42mxqHuS0bGa4B/vkkgdJHkYJPJhQf9z5LevEKq8UimpCLiWAXNWVWB
WgXVKjUhlkCVofDe2tNex9KAWH2QHZsvBxZTJGMgUphh6hGhXJggiR7pJA2grFM0
ttzUBmEazuH36VoYzq0lcYbUIl1xx1vO4or3S89sCEfymo6nAXcG/JQJ3XLxI/mj
f8I4bjZg1LJciuGDXwXZe9zPc2J96Wrx6d0jZied1TDxjpOt1gy5QZJxnlN/6no1
zfvXrQuaferN45u6Trrt3kXFkDW0WltwXT4hj77XlP9BZ1ANHonTTr1L68z38XP7
7w9ICpZOuiLumbphmZtRlL1xxkFV27zYxqnjSGfpWObz4HpnBxj7GrpLZbHFz+2L
g7LZcinnjtR4a+WuGGOM
=1MbB
-----END PGP SIGNATURE-----

John Tamplin

unread,
Jun 17, 2011, 3:45:58 PM6/17/11
to google-we...@googlegroups.com
On Fri, Jun 17, 2011 at 1:12 PM, Dennis Haupt <d.ha...@googlemail.com> wrote:
my requirement is to be able to change the locale on the fly. i've
cheated by asking the server for a date format which i get out of a
simpledateformat via reflection.

Right, all of GWT's i18n support is designed to do as much as possible at compile time rather than runtime -- if you don't want that, you need to do it on the server (you could do it yourself on the client, but the time/speed penalty is pretty large).

--
John A. Tamplin
Software Engineer (GWT), Google
Reply all
Reply to author
Forward
0 new messages