You can use LocaleFactory.get(Class<T extends LocalizableResource> cls)
to obtain Messages
, Constants
or ConstantsWithLookup
both on server and client side.
Add I18nFilter
to web.xml
or use ThreadLocalLocaleProvider.pushLocale(Locale)
with ThreadLocalLocaleProvider.popLocale()
to manually set thread-local locale.
Also there are a couple of additional server-only features like MessagesWithLookup
interface and encoding proxies, which allow you to use localization in a more dynamic way.
Note: Unfortunately GWT-specific message formats (described here) are currently not supported except for the "static argument" format ({startBold,<b>}
).
Add <inherits name="net.lightoze.gwt.i18n.GwtI18nServer"/>
to your GWT XML module descriptor.
Call LocaleFactory.put(MyMessages.class, GWT.<MyMessages>create(MyMessages.class))
in your EntryPoint
.
Snapshots - https://oss.sonatype.org/content/groups/public/
Releases - Maven Central
Latest release (for GWT 2.8.1):
<dependency> <groupId>net.lightoze.gwt-i18n-server</groupId> <artifactId>gwt-i18n-server</artifactId> <version>0.25</version> </dependency>
This artifact contains a copy of com.google.gwt.i18n
package from GWT distribution, so you don't have to deploy the whole GWT library on the server.
In case you want only gwt-i18n-server
classes, use an artifact with original
classifier.