views:

473

answers:

1

I have a monolingual GWT application (English) and I would like to use localized date and number formats.

I have added <inherits name="com.google.gwt.i18n.I18N"/> to my gwt.xml, but the formats remain in en-us. I have checked the browser lacale using this script

private native String getBrowserLocale() /*-{
      return navigator.language!=null ? navigator.language : navigator.browserLanguage; 
}-*/;

which reports da_DK.

I also tried forcing the locale by adding <meta name="gwt:property" content="locale=da"> to the index.html, but no luck.

The only way i can get the correct formats is by directly adding the locales to the gwt.xml using <extend-property name="locale" values="da" />, which is quite annoying because there is quite a few locales available.

Does anybody know a workaround for this?

+2  A: 

There is no other way to use the build in date and numberformats.

This is because I18N uses deferred binding.

The properties files with the localized formats are actually compiled into localized html/javascript. Only one format pr language. The correct localized bundle is loaded by the browser.

Orla