gxt 中文

在使用gxt的时候 发现默认使用的是English

这样的话应用开发起来不能够完全中文化

这样可是太不方便了哈

 

在gxt的官方网站中找到了提示:http://www.sencha.com/forum/showthread.php?40607-How-to-translate-Ext-GWT-s-messages/page6

只是改变一下配置文件就行了

在gxt的jar文件中已经包括了XMessage_zh.properties文件

故能够帮助我们实现中文化

下面把主要的内容粘贴下来:

  1. Create the messages file. You can translate from english language in com/extjs/gxt/ui/client/messages/XMessages.properties
  2. Save your file as "XMessages_<country code>.properties" e.g XMessages_id.properties
  3. Open gxt.jar with winzip or winrar or another program and goto "com/extjs/gxt/ui/client/messages" folder and add your translation file there
  4. That's it. Your translation is already included in gxt.jar file. -- In my case, I need to reconfigure my build path (I'm using eclipse and it doesn't automatically detect the new translation file). I remove the gxt.jar from the build path and re-include it in my project
  5. Now, add the locale to your gwt module xml (YourProject.gwt.xml) file like this:
    <module>
    <inherits name="com.google.gwt.user.User"/>
    <inherits name="com.google.gwt.i18n.I18N"/>
    
    <!-- Below is the line. Replace the "id" string to your country code (same as your XMessages_<country code>) file -->
    <extend-property name="locale" values="id"/>
    </module>
     
  6. Your translation (locale) is already included in your gwt module. Now you must specify your locale to be loaded by the client side script (html). Add this line to your html file like this:

    <html>
    <head>
    
    <!-- Below is the line. Replace the "id" string to your country code (same as your XMessages_<country code>) file -->
    <meta name="gwt:property" content="locale=id">
    
    </head>
    <body>
    <!-- Load the GWT compiled module code -->
    <script src="com.google.gwt.examples.i18n.ColorNameLookupExample.nocache.js " />
    </body>
    </html>
     
  7. You can also load the locale by setting from query string like:
    http://www.example.org/myapp.html?locale=id
  8. Refresh your browser or recompile your project. Done. Your gxt is now in your language
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值