`

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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics