我如何使用消息国际化GWT UIBinder页面? [英] How can I internationalize a GWT UIBinder page with Messages?

查看:75
本文介绍了我如何使用消息国际化GWT UIBinder页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将UIBinder应用程序与属性文件国际化。由于com.google.gwt.i18n.client.Messages接口(GWT 1.7.1)已经提供了很多翻译,我们希望重用这些消息。



我试过以下内容:

 <!DOCTYPE ui:UiBinder SYSTEMhttp://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>

MessageConstants类如下所示:

  @DefaultLocale(nl)
公共接口MessageConstants扩展消息{
String email();
}

但是,这不起作用。

解决方案

更新:



由于Igor写了他的回答,所以有一种在UI绑定中使用消息的新方法。 span>此< ui:text from ={msgRes.message}/>已经国际化< / 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

这篇关于我如何使用消息国际化GWT UIBinder页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆