rcp(插件开发)资源文件国际化问题-中文例子
2012-09-18 14:53
281 查看
只需要简单的几步:
1.
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
public static String getResourceString(String key) {
ResourceBundle bundle= LauncherPlugin.getDefault().getResourceBundle();
try {
return bundle.getString(key);
} catch (MissingResourceException e) {
return key;
}
}
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle() {
try {
//设置成中文
Locale local = Locale.CHINA;
resourceBundle= PropertyResourceBundle.getBundle("resources", local);
} catch (MissingResourceException x) {
resourceBundle = null;
}
return resourceBundle;
}
2.资源文件的命名方式,例如:resources_zh_cn.properties 就可以了。后边的zh_cn 不区分大小写的。
3.定义一个资源变量 msg=中文; 中文要进行转码 就可以了。
4.key就是国际化资源文件中的key,例如:msg。
剩下的就是看看中文是否成功输出。
1.
/**
* Returns the string from the plugin's resource bundle,
* or 'key' if not found.
*/
public static String getResourceString(String key) {
ResourceBundle bundle= LauncherPlugin.getDefault().getResourceBundle();
try {
return bundle.getString(key);
} catch (MissingResourceException e) {
return key;
}
}
/**
* Returns the plugin's resource bundle,
*/
public ResourceBundle getResourceBundle() {
try {
//设置成中文
Locale local = Locale.CHINA;
resourceBundle= PropertyResourceBundle.getBundle("resources", local);
} catch (MissingResourceException x) {
resourceBundle = null;
}
return resourceBundle;
}
2.资源文件的命名方式,例如:resources_zh_cn.properties 就可以了。后边的zh_cn 不区分大小写的。
3.定义一个资源变量 msg=中文; 中文要进行转码 就可以了。
4.key就是国际化资源文件中的key,例如:msg。
剩下的就是看看中文是否成功输出。
相关文章推荐
- struts国际化问题,利用Eclipse插件编辑中文资源文件
- rcp(插件开发)获取Plugin/Bundle中文件资源的绝对路径
- rcp(插件开发)获取Plugin/Bundle中文件资源的绝对路径
- rcp(插件开发)RCP程序导出后中文乱码问题
- I18n(国际化)原理(国际化资源文件2种实现支持中文的方法,propedit5.3.3插件在MyEclipse和Eclipse中安装)
- rcp(插件开发) plugin.xml 国际化中文未出现?
- 菜鸟教程之工具使用(十九)——国际化资源文件开发凶器MultiProperties
- Eclipse插件开发中对于Jar包和类文件引用的处理(彻底解决插件开发中的NoClassDefFoundError问题)
- PDF网页显示: object标签使用pdf插件打开中文文件的问题 (WEB开发)
- 在开发node.js中,关于使用VS2013插件出现一直读取资源的问题
- rcp(插件开发)资源管理三
- iOS开发中配置了国际化文件,但是只想显示中文
- liferay二次开发部署在weblogic上的文件下载中文名问题解决
- 解决Extjs 引入国际化中文文件build后没汉化问题
- Eclipse插件开发中对于Jar包和类文件引用的处理(彻底解决插件开发中的NoClassDefFoundError问题)
- rcp(插件开发) 去掉plugin_customization.ini文件,在代码中实现配置功能
- Javaweb开发的资源文件位置问题
- 插件开发的一个中文文件
- eclipse下的struts资源文件中文问题
- web开发时在浏览器上下载文件中文名字乱码问题