GWT Tip Of The Day

February 13, 2011 08:16 by docbliny 

Here’s a quick for anyone who is using Google Web Toolkit rebind and code generators. If you want to see the output of the created .java source file(s), add the “-gen gen” parameter to the compiler options. This will cause the GWT compiler to emit the files your generator created into a folder named “gen” next to the “src” directory.


Getting i18n with UiBinder up and running in GWT

April 12, 2010 16:24 by docbliny 

OK, fiddled around a little today with GWT trying to get i18n working with UiBinder. Ran into some issues that I was able to sort out so here’s the obligatory post. I’ll leave reading the basic information from the GWT docs up to you and only highlight the steps that seem to be missing. GWT 2.0.3.


Rough Overview

  1. Create a UiBinder *.ui.xml file with <msg/> elements.
  2. Compile the project using the –soyc or –extra compiler argument. –soyc does some extra legwork, so you may want to configure –extra instead. This generates .properties files in the extra folder.
  3. Copy the generated properties file(s) from the extras folder into the folder where the *.ui.xml lives.
  4. Rename the properties file(s) removing the namespace from the beginning. Note that the class name is duplicated. For example, if the your UiBinder file is named MyView.ui.xml, then the properties file should be named
  5. Create translated properties files by appending _XX (language, independent of country) or _XX_YY (language_country) to end of the filename, before the extension. For example,

Editing Properties Files In Eclipse

Please be aware that the properties files need to be encoded as UTF-8 and by default Eclipse will encode using ISO-8859-1. You’ll probably want to change the default encoding for .properties files as follows before editing them. Otherwise, Eclipse will simply save them with the incorrect encoding.

  1. In Eclipse, click the Window-menu, and then click Preferences.
  2. Expand and select General/Content Types in the options tree on the left.
  3. In the Content types list, select Java Properties File.
  4. In the Default encoding field, type UTF-8.
  5. Click OK.


Set Default and Fallback Language

[Untested, beware] By default GWT uses a locale named “default”. You’ll most likely want to change this to whatever your real default language is. You do this in (each of) the module XML files, for example MyModule.gwt.xml. Here’s what I did to switch to “en” as the default and remove the “default” from the compile permutations.

<extend-property name=”locale” values=”en”/>

<set-property name=”locale” value=”en"/>

<set-property-fallback name=”locale” value=”en”/>

And then I added another language:

<extend-property name=”locale” values=”fi”/>


Optimizing Compile Permutations

While I’m almost still on the subject of compile permutations, you can continue to edit the MyModule.gwt.xml file to optimize how many permutations GWT creates for languages and browser combinations. To remove languages for development, just comment out the extra languages you added in the previous step. To modify which browsers should be compiled to, add and edit the following like:

<set-property name=”user.agent” value=”safari,ie8"/>

Separate multiple browsers with a comma. Here are some supported values:

  • safari
  • gecko
  • gecko1_8
  • opera
  • ie6
  • ie8