使用UiBinder构建的GWT应用程序的本地化无法在托管模式下使用 [英] Localization of GWT app built with UiBinder doesn't work in hosted mode

查看:148
本文介绍了使用UiBinder构建的GWT应用程序的本地化无法在托管模式下使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用UiBinder构建的GWT应用程序本地化是否以托管模式运行?它不适合我。以下是我所做的:

1)为GWT模块的XML添加语言环境属性

 <继承name =com.google.gwt.i18n.I18N/> 
< extend-property name ='locale'values ='en'/>
< extend-property name ='locale'values ='ru'/>
< set-property-fallback name =localevalue =en/>

2)* .ui.xml文件中的封锁消息,如

 < ui:UiBinder xmlns:ui =urn:ui:com.google.gwt.uibinder
ui:generateFormat =com.google.gwt.i18n.rebind.format.PropertiesFormat
ui:generateKeys =com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator
ui:generateLocales =default
xmlns:g =urn:import:com.google.gwt.user.client。 UI>

< G:HTMLPanel>
< ui:msg description =你好描述>你好!< / UI:消息>
< /克:HTMLPanel>
< / UI:UiBinder的>



<3>添加了GWT编译器选项-extra



< 4)编译该项目。在额外文件夹中找到带有后缀.GenMessages.properties的文件。



5)本地化生成的消息。将每个.GenMessages.properties文件复制到具有相应.ui.xml文件的同一文件夹中。在文件名中用我的语言环境重命名,例如
.GenMessages_en.properties
.GenMessages_ru.properties



6)重新编译项目。



)启动app并更改URL中的locale变量以进行检查,例如
http://127.0.0.1:8888/TestLocale.html?gwt.codesvr=127.0.0.1:9997&locale=ru



它仍然显示我默认的英文版资源。



我错过了什么?我怎样才能调试它?



我在Windows下,使用IntelliJ IDEA和Chrome作为浏览器。



感谢!



更新:不起作用,因为我有额外的< set-property name =localevalue =en/> 在模块配置中:(也许它是覆盖 extend-property 标记。



我写了一步一步的描述如何使它工作 这里 如果有人对此感兴趣。

h2_lin>解决方案

默认情况下,GWT会生成以包名开头的属性文件。在我的GWT项目中最适合我的是使用LocalizableResource_.properties作为文件名并将它们全部保存在 com / google / gwt / i18n / client 包中。 使用UiBinder进行本地化


Does localization of GWT app built with UiBinder work in hosted mode ? It does not for me. Here is what I did:

1) Added locale properties to GWT module's XML

< inherits name="com.google.gwt.i18n.I18N" / >
< extend-property name='locale' values='en'/>
< extend-property name='locale' values='ru'/>
< set-property-fallback name="locale" value="en"/>

2) Taged messages in *.ui.xml files with , as

< ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
     ui:generateFormat="com.google.gwt.i18n.rebind.format.PropertiesFormat"
     ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator"
     ui:generateLocales="default"
     xmlns:g="urn:import:com.google.gwt.user.client.ui">

  < g:HTMLPanel>
     < ui:msg description="Hello Description">Hello!< /ui:msg>  
  < /g:HTMLPanel>
< /ui:UiBinder>

3) Added GWT compiler option -extra

4) Compiled the project. Found files with suffix .GenMessages.properties in the extra folder.

5) Localized generated messages. Copied each .GenMessages.properties file to the same folder with corresponding .ui.xml file. Renamed it with my locale in the file name, e.g. .GenMessages_en.properties .GenMessages_ru.properties

6) Re-compiled the project.

7) Launched the app and change locale variable in the URL for checking, e.g http://127.0.0.1:8888/TestLocale.html?gwt.codesvr=127.0.0.1:9997&locale=ru

It still shows me default English version of resources.

What am I missing ? How can I even debug it ? There is nothing in logs or output.

I'm under Windows, using IntelliJ IDEA and Chrome as browser.

Thanks!

Update: It didn't work because I had extra < set-property name="locale" value="en"/ > in module config :( Perhaps it was overriding values from extend-property tag.

I wrote step-by-step description how to make it work here in case somebody is interested.

解决方案

By default GWT generates properties files which start with package name. Did you remove package from file name?

One thing that worked best for me in my GWT projects is using LocalizableResource_.properties as file names and keeping them all in com/google/gwt/i18n/client package. Check out GWT documentation on Localization with UiBinder

这篇关于使用UiBinder构建的GWT应用程序的本地化无法在托管模式下使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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