How to internationalize the text attribute of a TreeItem in UIBinder?
Given a UIBinder tree like this:
<g:Tree ...>
<g:TreeItem text='Links1' >
<g:Hyperlink ... />
<g:Hyperlink ... />
<g:TreeItem text='Links2' >
<g:Hyperlink ... />
开发者_StackOverflow社区 <g:Hyperlink ... />
</g:Tree>
How to internationalize the 'text' attribute of TreeItem
elements (without resorting to doing it programmatically)?
If you already have a Messages (or Constants) interface you can do it as follows:
Add a ui:with
resource to to UiBinder xml:
<ui:with field='i18n' type="com.example.myapp.client.i18n.MyMessages" />
Next use it as follows:
<g:Tree ...>
<g:TreeItem text='{i18n.links1}' >
<g:Hyperlink ... />
<g:Hyperlink ... />
<g:TreeItem text='{i18n.links2}' >
<g:Hyperlink ... />
<g:Hyperlink ... />
</g:Tree>
Where links1
and links2
refer to method names on your MyMessages
interface.
精彩评论