東南西北風

生活就像一杯加了糖的苦咖啡。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

17、java国际化问题

Posted on 2009-08-27 02:38  东南西北风  阅读(194)  评论(0)    收藏  举报

1、了解缺省Locale是由操作系统决定的,Locale是由语言和国家代码组成
      在浏览器上:工具---Internet选项---语言  可以查看Locale
2、国际化资源文件是由baseName+locale组成,如:MessageBundle_en_US.properties
baseName是任意合法的文件名
------比如:
      需要提供配置文件,这写命名是由规则的,且放置在classpath能直接能找到的地方,一般放在src文件下
MessagesBundle_en_US.properties--美国
MessagesBundle_zh_CN.properties--中国

3、native2ascii命令的位置和用法
 * 位置:JAVA_HOME/bin
 * 使用native2ascii.exe  o.properties MessagesBundle_zh_CN.properties
4、I18nSimple.java类

Code
5、MessagesBundle_en_US.properties
k1=hello,{0}
k2
=good bye
6、MessagesBundle_zh_CN.properties
k1=\u4F60\u597D,{0}
k2
=\u518D\u89C1
7、MessageBundle.properties---默认的
k1=hello,{0}
k2
=good bye