Mike Chaliy
Mike Chaliy

Reputation: 26698

How to change default locale in GWT

Our application should be fixed to use eb-GB locale. For now I've added:

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

But this means that GWT builds premutations for both. How to setup GWT to eb-GB by default? Or how to remove default from compilation?

Upvotes: 16

Views: 17586

Answers (6)

Kyone
Kyone

Reputation: 523

I'm playing the archeologist here but according to GWT docs about internationalization you should use the property fallback for "locale" instead of forcing the locale itself.

So in your module XML (the .gwt.xml file) you should have :

<!-- Let say you app supports the english language, independent of country -->
<extend-property name="locale" values="en"/>
<!-- Now set the fallback locale so your app will be in british english by default, Sir -->
<set-property-fallback name="locale" value="en_GB"/>

<set-property name="locale" value="en_GB"/> will only set en_GB as the locale of your application and won't create the permutation for the other locales you defined.

Hope this helps.

Upvotes: 9

Jernej
Jernej

Reputation: 131

<extend-property name="locale" values="sl_SI"/>
<set-property name="locale" value="sl_SI" />

first adds to the set of available locales.

then sets the default.

if default is not set to the same locale as the added ones, gwt will build permutations for added locale and default locale.

Upvotes: 12

Mohsen
Mohsen

Reputation: 3552

Here is a better hack (see the second comment).

Note that having only this code

<set-property name="locale" value="en_GB" />

causes LocaleInfo.getLocaleNativeDisplayName(localeName) to return empty string for default locale.

Upvotes: 1

David Nouls
David Nouls

Reputation: 1895

How about:

<set-property name="locale" value="en_GB" />

Upvotes: 9

Hilbrand Bouwkamp
Hilbrand Bouwkamp

Reputation: 13519

You can set the default via the annotation: @DefaultLocale("en_GB") on the interfaces extending the i18 interfaces, e.g. com.google.gwt.i18.client.Messages.

For example:

@DefaultLocale("en_GB")
public interface MyMessages extends com.google.gwt.i18.client.Messages {
  ...

I'm not sure if this actual solves your problem, but it seems the way to set the default. See also http://code.google.com/p/google-web-toolkit/wiki/I18nAnnotations

Upvotes: 3

Michael Balint
Michael Balint

Reputation: 2285

See this.

You need to specify the locale in the host page like so...

<meta name="gwt:property" content="locale=x_Y">

You could also write your own property provider.

Upvotes: 3

Related Questions