13.3. Using static-string i18n with UiBinder

UiBinder allows you to define string constants and messages in the UI declaration. The approach is quite simple but with some gotchas along the way.

Let’s look at how to use string constants in UiBinder, which are messages with no parameters, and after that, we’ll discuss what changes to make for using messages with parameters.

13.3.1. Constants with UiBinder

Our example’s UiBinder declaration, StaticExample.ui.xml, has a label

<g:Label>GWTiA Static Internationalization Example</g:Label>

to which we’d like to apply i18n techniques.

We need to make one small change to the definition: wrap the text we wish to be translated with a <ui:msg> tag, so it becomes

<g:Label> <ui:msg> GWTiA Static Internationalization ...

Get GWT in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.