GWT 2.1 DateTimeFormat & locale changes?

1,174 views
Skip to first unread message

Rick Porter

unread,
Nov 23, 2010, 7:52:01 AM11/23/10
to Google Web Toolkit
Hello,

I recently made some tool updates to Helios & GWT 2.1, and everything
looks pretty good. However, I am seeing some changed behavior
regarding the date/time formatting and locales. Previously, my "out-
of-the-box" compile gave me "en-US" formatting (12 hr times, week
starting on Sun, and mm/dd/yy). Now, I am seeing 24 hr clock, weeks
starting on Monday, and yyyy-mm-dd formatting. I changed my
DateTimeFormat calls to the deprecated 'getShortDateFormat' to
'getFormat(PredefinedFormat.DATE_SHORT)' without any luck (and similar
changes for other date/time functions).

I did include the "<inherits name="com.google.gwt.i18n.I18N"/>" based
on guidance found at http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsFormatting.html.
However, this did not seem to help.

Suggestions?

Thanks,
Rick

Rick Porter

unread,
Dec 2, 2010, 8:23:00 AM12/2/10
to Google Web Toolkit
I think I have solved my date/time issues by forcing a locale, but I
would welcome suggestions for a better solution.

In my module XML, I added the following line to include some
internationalization code:

<inherits name="com.google.gwt.i18n.I18N"/>

I added the following line to my module XML for my locale:

<extend-property name="locale" values="en_US"/>

Including the locale extend-property increases the GWT compile time,
since the compile does each browser/locale combination. This was the
most undesireable piece of my solution since it basically doubled my
GWT compile times. I tried to set the default locale using another bit
of XML found at http://code.google.com/intl/es-AR/webtoolkit/doc/latest/DevGuideI18nLocale.html#LocaleDefault,
but I could not even get the GWT compile to work when including that
XML.

The last required piece was adding the following line in my HTML file:

<meta name='gwt:property' content='locale=en_US'>

This gives it a default locale, but I believe that it can be
overridden with request parameters.

I did test this on a couple projects, and it worked for both. However,
I did not test with different locales. It seems that a new GWT 2.1
project has the same issues, so this is not just a GWT 2.0 conversion
problem -- I tested by adding a DateBox to a new GWT default project.


Enjoy,
Rick

jhulford

unread,
Dec 15, 2010, 10:47:40 AM12/15/10
to Google Web Toolkit
This message is several days old, but I just ran into this too and
wanted to avoid having to update my host pages w/ the meta tags since
I'm only using the one locale as well.

To do this, add the following to your module's config file (.gwt.xml):

<inherits name="com.google.gwt.i18n.I18N"/>
<extend-property name="locale" values="en_US"/>
<set-property name="locale" value="en_US"/>


On Dec 2, 8:23 am, Rick Porter <rickwpor...@gmail.com> wrote:
> I think I have solved my date/time issues by forcing alocale, but I
> would welcome suggestions for a better solution.
>
> In my module XML, I added the following line to include some
> internationalization code:
>
>    <inherits name="com.google.gwt.i18n.I18N"/>
>
> I added the following line to my module XML for mylocale:
>
>    <extend-property name="locale" values="en_US"/>
>
> Including thelocaleextend-property increases theGWTcompile time,
> since the compile does each browser/localecombination. This was the
> most undesireable piece of my solution since it basically doubled myGWTcompile times. I tried to set the defaultlocaleusing another bit
> of XML found athttp://code.google.com/intl/es-AR/webtoolkit/doc/latest/DevGuideI18nL...,
> but I could not even get theGWTcompile to work when including that
> XML.
>
> The last required piece was adding the following line in my HTML file:
>
>    <meta name='gwt:property' content='locale=en_US'>
>
> This gives it a defaultlocale, but I believe that it can be
> overridden with request parameters.
>
> I did test this on a couple projects, and it worked for both. However,
> I did not test with different locales. It seems that a newGWT2.1
> project has the same issues, so this is not just aGWT2.0 conversion

Jim Douglas

unread,
Dec 15, 2010, 12:55:26 PM12/15/10
to Google Web Toolkit
> I tried to set the default locale using another bit
> of XML found at http://code.google.com/intl/es-AR/webtoolkit/doc/latest/DevGuideI18nL...,
> but I could not even get the GWT compile to work when including that
> XML.

Me too; I thought I was just missing something.

The documentation says to add this to the .gwt.xml file:

<set-property-fallback name="locale" value="en"/>

http://code.google.com/webtoolkit/doc/latest/DevGuideI18nLocale.html#LocaleDefault

But that rule does not appear to be valid. I get this error message
when I add it:

The content of element type "module" must match "(inherits|source|
public|super-source|entry-point|stylesheet|
script|servlet|replace-with|generate-with|define-property|extend-
property|set-property|clear-configuration-
property|define-configuration-property|extend-configuration-property|
set-configuration-property|property-
provider|define-linker|add-linker)*".

And I don't see it defined, even in the most current version of the
dtd:

http://google-web-toolkit.googlecode.com/svn/tags/2.1.0/distro-source/core/src/gwt-module.dtd

On Dec 2, 5:23 am, Rick Porter <rickwpor...@gmail.com> wrote:
> I think I have solved my date/time issues by forcing a locale, but I
> would welcome suggestions for a better solution.
>
> In my module XML, I added the following line to include some
> internationalization code:
>
>    <inherits name="com.google.gwt.i18n.I18N"/>
>
> I added the following line to my module XML for my locale:
>
>    <extend-property name="locale" values="en_US"/>
>
> Including the locale extend-property increases the GWT compile time,
> since the compile does each browser/locale combination. This was the
> most undesireable piece of my solution since it basically doubled my
> GWT compile times. I tried to set the default locale using another bit
> of XML found athttp://code.google.com/intl/es-AR/webtoolkit/doc/latest/DevGuideI18nL...,

Rytis

unread,
Jan 7, 2011, 2:54:30 PM1/7/11
to Google Web Toolkit
I had a problem where I deleted the locale specifying lines from the
gwt.xml, and the calendar based on CalendarUtil decided to start on a
Monday. Folks in the US like their calendars starting with Sunday, so
putting what jhulford wrote in my gwt.xml fixed it for me, and the
calendar starts with Sunday again, making US folks happy. Including
all the 3 lines doesn't add any extra compiling permutations either
(it happens when <set-property name="locale" value="en_US"/> is left
out).
Reply all
Reply to author
Forward
0 new messages