Reputation: 3392
I am trying to internationalize my application running with GWT UI Binder using dynamic string i18n. Does UI binder support dynamic string i18n? Please let me whether this is possible.
Upvotes: 1
Views: 1549
Reputation: 1
We have done that using Dictionary . Basically you use dynamic host page (ex. jsp) to create constants dynamically in host page. To use them with UiBinder you have few options, but most straight forward is to create wrapper class around dictionary, for example
package org.gwt.dictionary.test
public class CurrentTheme {
Dictionary theme = Dictionary.getDictionary("CurrentTheme");
public String highlightColor() {
return theme.get("highlightColor");
}
public String shadowColor() {
return theme.get("shadowColor");
}
public String errorColor() {
return theme.get("errorColor");
}
public String errorIconSrc() {
return theme.get("errorIconSrc");
}
public String errorLabel() {
return theme.get("errorLabel");
}
public String someTextContent() {
return theme.get("someTextContent");
}
}
Then you can use it in gwt.xml like this
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:with field="themeConstants" type="org.gwt.dictionary.test.CurrentTheme"/>
<g:HTMLPanel>
<g:Label text="{themeConstants.errorLabel}" styleName="{themeConstants.errorColor}"/>
<div class="aler alert-info"><ui:text from="{themeConstants.someTextContent}"/></div>
</g:HTMLPanel>
</ui:UiBinder>
Hope it helps
Upvotes: 0
Reputation: 16109
UiBinder templates can be marked up for localization. You use the
<ui:msg>
and<ui:attribute>
elements to indicate which portions of the template should be translated, then provide properties files with localized versions of the messages when building your app. More about it
Updated: See this GWT Dynamic String Internationalization, I think you can find a solution from there.
Upvotes: 1
Reputation: 33743
To answer your question - yes, i18n is supported by UI Binder. Please refer to documentation available here and here. To support my claim, here is direct quote:
UiBinder... offers direct support for internationalization that works well with GWT's i18n facility;
You simply make some *.properties files with specified locale, enable i18n module in gwt-xml, create an interface which methods (returning String) can be accessed both in Java code and ui-xml files.
Upvotes: 0