Light-commons加入I18nBundle
java里的国际化一般是用ResourceBundle来实现,ResourceBundle.getBundle用的是Properties,Properties只支持iso-8859-1编码,中文要用 \udddd的格式,十分不爽。因此Light-common 加入ExProperties,方便中文配置。解决了Properties不支持中文的问题,然而ResourceBundle仍然不能用。
现在加入了I18nBundle可以实现常用的国际化。
TestCase
Properties cn =I18nBundle.getBundle("message", "conf", "utf-8", Locale.CHINA); Properties tw = I18nBundle.getBundle("message", "conf", "utf-8", Locale.TAIWAN); Properties fr = I18nBundle.getBundle("message", "conf", "utf-8", Locale.FRENCH); assertEquals("中国名字",cn.getProperty("test.name") ); assertEquals("中文名字",tw.getProperty("test.name") ); assertEquals("English Name", fr.getProperty("test.name"));
#message.conf
test.name=English Name
#message_zh.conf
test.name=中文名字
#message_zh_CN.conf
test.name=中国名字
页:
[1]