我想在我的应用程序中实现 gwt i18n 而不更改应用程序的 url。有人知道这件事吗?
1 回答
Apart from specifying the locale via parameters (queryparam), you have other methods: cookie, meta and useragent.
1.- queryparam: appending to the url query-string the parameter locale="es"
2.- cookie: Setting a cookie value somehow and reloading the page, in gwt could use this code:
Cookies.setCookie("foo", "nn");
Window.Location.reload();
you need this line in your module file:
<set-configuration-property name="locale.cookie" value="foo"/>
3.- meta: You have to add a meta tag to your html page:
<meta name="gwt:property" content="locale=es">
4.- useragent: It uses the navigator.language
javascript property, which normally matches the desktop language selected by the user, you have to enable it though:
<set-configuration-property name="locale.useragent" value="Y"/>
You can define the order of how gwt computes the locale setting this property:
<set-configuration-property name="locale.searchorder" value="queryparam,cookie,meta,useragent"/>
You can get more info reading the comments in the I18N.gwt.xml file.