How to implement custom internationalization with gwt?
I want to make custom internationalization for my gwt app. What does this means? Imagine that开发者_StackOverflow中文版 my app must be internationalized for men and women. (id=men, id=women). is it possible to make two different .properties files like MyAppMessages_men_en.properties MyAppMessages_women_en.properties
MyAppMessages_men_fr.properties MyAppMessages_men_fr.properties
etc...
and my app host page will be accessed like this for example http://blabla/MyAppHostPage.html?locale=en&id=men and this must load english version for men.
Thanks.
How about using fictional locale identifiers such as en_US_Men
and en_US_Women
and so forth for other locales?
(note that you should include a country whenever you include a variant of a locale)
Otherwise, I'd suggest using an abstract factory for your Messages and switch the concrete implementation using deferred binding on a distinct property (men vs. women):
interface MyAppMessagesFactory { MyAppMessages create(); }
class MyAppMessagesFactory_Men implements MyAppMessagesFactory {
@Override
public MyAppMessages create() { return GWT.create(MyAppMessages_Men.class); }
}
class MyAppMessagesFactory_Women implements MyAppMessagesFactory {
@Override
public MyAppMessages create() { return GWT.create(MyAppMessages_Women.class); }
}
You'd then have your MyAppMessages_Men_en.properties and MyAppMessages_Women_en.properties.
精彩评论