Thursday, January 31, 2013

Internationalization in GWT UiBinder For Dummies

Internationalization in GWT UiBinder For Dummies



Supporting Multilingual in GWT is simple and very few steps to follow.

<ui:msg> tag for text to support multilingual as shown below.

<ui:msg key="street1" description="Address Street1">Street1</ui:msg>

here key attribute is optional (GWT will create random key if you didn't use key attribute), but its highly recommended to use a key.

while compiling the gwt project, pass -extra <folder_name> argument to the compiler, it will create  properties files for each uibinder files inside the directory with <folder_name>.

1. Properties file with package name can be found eg: com.gwt.sample.client.content.SkillsetDialogViewBinderImplGenMessages.properties

2. Delete package name in the file, eg: SkillsetDialogViewBinderImplGenMessages.properties

3. Place it in the proper package(in the above case, the file must be place in  com.gwt.sample.client.content package

4. Try changing the properties file name (eg: SkillsetDialogViewBinderImplGenMessages_fr.properties for french) for locales and modify the values for each key accordingly.

5. Change the language in browser or pass the language in the URL like below :

http://127.0.0.1:8888/Project.html?gwt.codesvr=127.0.0.1:9997&locale=fr




No comments:

Post a Comment