开发者

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 defa开发者_如何学Goult from compilation?


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


How about:

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


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.


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜