Dspace1.5有着对国际化的良好支持。 下面对dspace中国际化的结构进行简单说明,同时对应用简体中文时所遇到的问题给出我的解决办法。
1. 在dspace-jspui/dspace-jspui-webapp工程中,web.xml里定义的资源文件片段如下:
<context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>Messages</param-value> </context-param>
可以看到,资源文件的基本名称是“Messages”。
2. 语言包 dspace-api-lang-1.5.0.0.jar 位于dspace-jspui\dspace-jspui-webapp\target\dspace-jspui-webapp-1.5.1-SNAPSHOT\WEB-INF\lib\ 目录下,里面包括多种语言的资源文件:
3. 在安装目录的配置文件中D:\dspace\config\dspace.cfg中来设置支持语言的种类:
# All the Locales, that are supported by this instance of DSpace # A comma seperated list of Locales. All types of Locales country, country_language, country_language_variant # Note that the appropriate file are present, especially that all the Messages_x.properties are there # may be used, e. g: webui.supported.locales = en, de webui.supported.locales = zh_CN,en,de,hu,ja,fr
webui.supported.locales 中按照命名规则可以任意设定所支持的语言,这里设定六种。
4. 可是唯独 zh_CN 简体中文出不来,找到解决办法如下:
1) 将dspace-api-lang-1.5.0.0.jar 包中的 Messages_zh_TW.properties 转换成中文汉字(繁体)。
native2ascii -reverse Messages_zh_TW.properties temp.properties
2) 下载软件“中文简体繁体转换王”,将temp.properties文件由繁体转换为简体;
3) 将转换后的简体文件通过native2ascii工具转换为ascii编码文件 Messages_zh_CN.properties;
native2ascii temp.properties Messages_zh_CN.properties
4) 将Messages_zh_CN.properties文件放到 dspace-api\src\main\resources 目录下;
4) 运行dspace-assemble重新编译一下,运行ok!