如何使用 Messages 国际化 GWT UIBinder 页面? [英] How can I internationalize a GWT UIBinder page with Messages?
问题描述
我正在尝试使用属性文件国际化 UIBinder 应用程序.由于我们已经通过 com.google.gwt.i18n.client.Messages 接口 (GWT 1.7.1) 公开了很多翻译,我们希望重用这些消息.
我尝试了以下方法:
<!DOCTYPE ui:UiBinder 系统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"/>
</g:HTMLPanel></ui:UiBinder>
MessageConstants 类如下所示:
@DefaultLocale("nl")公共接口 MessageConstants 扩展消息 {字符串电子邮件();}
然而,这行不通.我该怎么做?
更新:
自从 Igor 写下他的回答后,在 ui binder 中出现了一种使用消息的新方法.
This 已经国际化</span>
此方法使用 GWT 的 文本资源 UiBinder 集成
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?
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
这篇关于如何使用 Messages 国际化 GWT UIBinder 页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!