How can I internationalize a GWT UIBinder page with Messages?

Jan picture Jan · Feb 18, 2010 · Viewed 12.7k times · Source

I am trying to internationalize a UIBinder application with property files. Since we have already a lot of translations exposed by the com.google.gwt.i18n.client.Messages interface (GWT 1.7.1), we would like to reuse these messages.

I have tried the following:

<!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" 
 xmlns:res="ui:with:be.credoc.iov.webapp.client.MessageConstants">

 <g:HTMLPanel>
  <div>
   <res:msg key="email">Emaileke</res:msg>:
   <g:TextBox ui:field="email" />
  </div>
 </g:HTMLPanel>
</ui:UiBinder>

The MessageConstants class looks like this:

@DefaultLocale("nl")
public interface MessageConstants extends Messages {
 String email();
}

However, this does not work. How can I do this?

Answer

logan picture logan · Aug 30, 2011

Update:

Since Igor wrote his answer, there has been a new method of using messages in ui binder.

<span>This <ui:text from="{msgRes.message}" /> has been internationalized</span>

This method uses GWT's text resource UiBinder integration