Reputation: 31
I'm trying to write my first project with using of GWT. And I do not understand the principles of the internationalization of GWT application with UiBinder. I used JSP before now. I clearly understand the internationalization of the technology:
<fmt:message key="myValue" />
In GWT the similar tag can have some content:
<ui:msg key="myKey" description="myDescription">My content</ui:msg>
It is unclear for me. What does the content of this tag mean? What is sense in it? All the data as I understand it should be taken from .properties
files.
And what do the attributes key
and description
means? What values they should contain?
I would be very grateful if someone can available explain how does internationalization work in UiBinder. Thanks in advance!
Upvotes: 3
Views: 1939
Reputation: 1216
I think the best way to do uibinder internationalization is follow the steps of this blog: http://joergviola.blogspot.com.es/2011/07/gwt-uibuilder-internationalisation.html.
I have tested it and it works like a charm!
Upvotes: 1
Reputation: 64561
UiBinder i18n works by generating a Messages
interface under-the-hood, so to understand UiBinder i18n, you actually only need to understand GWT i18n.
Each ui:msg
is turned into a method in the interface, each attribute of ui:msg
is turned into an annotation on that method, and the content of the ui:msg
is turned into the value of a @DefaultMessage
annotation on the method, with each widget or ui:ph
turned into a placeholder and resolved at runtime.
Similarly, some attributes attributes on the top-level ui:UiBinder
element are turned into annotations on the generated Messages
interface.
In GWT i18n, you can have one locale integrated into your code, in the form of annotations (@DefaultMessage
within a Messages
interface), without the need for a *.properties
file for that locale. The locale is given in a @DefaultLocale
annotation on the interface (ui:defaultLocale
in UiBinder). Only messages for other locales have to be provided in *.properties
files.
(note that you cannot use all features of Messages
from UiBinder: plurals, selection, optional arguments, etc.)
So, to answer your more specific questions: key
gives the key used to lookup the message in the *.properties
file (for all locales besides the ui:defaultLocale
, where the message is given right in the UiBinder file), and description
, as well as meaning
, are only a hint for translators.
Upvotes: 12