16

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?

6 Answers 6

12
<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.

Sign up to request clarification or add additional context in comments.

Comments

9

How about:

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

4 Comments

I guess you will need to combine this with answers from above.
This works! I've had this idea. But seems typed something icorrectly.
Where should I add this property? I tried in my .gwt.xml file, but it complains about "Unexpected exception while processing element 'set-property'"
this answer is kind of a workaround since you force the locale. According to the GWT documentation about i18n Locale "you should avoid running the app in the default locale", instead you should set a fallback locale.
9

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.

Comments

3

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.

3 Comments

This will not replace default locale. This is about to setup what locale to use. What I need is default locale to bahaive as en_GB.
If you've specified a locale (as you've shown above), shouldn't it replace the default. Here is what is said about the Default Locale... "The com.google.gwt.i18n.I18N module defines only one locale by default, called default. This default locale is used when the locale client property goes unspecified in deployment. The default locale is used internally as a last-resort match between a Localizable interface and a localized resource or class."
We use exaclty one locale - default, but we want it to be en-GB rather en-US. This is why I've asked how to configure default locale.
3

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

2 Comments

This looks like what you are really looking for.
I mostly need this for built-in stuff. Like date time and number formates. So thank you for pointing this out, but this does not solve my problem. Anyway thanks for your time.
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.