EOS如何实现国际化处理

来源:互联网 发布:20级研究所升级数据 编辑:程序博客网 时间:2024/06/04 23:24

另有文章Coframe通过配置文件实现国际化功能,保持前后台同时国际化



<b:message>标签可以根据locale输出国际化信息。

  • 配置国际化资源

资源文件扩展名为properties,以语言为文件名称后缀,存放在"构件包-配置信息-resources-i18n"目录下。
Test_en.properties文件内容:

?
key1=English
key2=name is{0},gender is {1}

Test_zh_CN.properties文件内容:

?
key1=\u4e2d\u56fd
key2=\u59d3\u540d:{0},\u6027\u522b:{1}
  • <b:message>标签locale优先级规则

标签的locale属性设置优先级最高,其次是DataContextManager.current().setCurrentLocale()设置的locale。若以上两处都未设置,则取浏览器的locale设置做为标签的locale设置。

?
<%@includefile="/common/common.jsp"%>
<%@includefile="/common/skins/skin0/component-debug.jsp"%>
<%@pagepageEncoding="utf-8"contentType="text/html; charset=utf-8"%>
<%@pageimport="com.eos.data.datacontext.DataContextManager"%>
<html>
    <head>
       <title>Title</title>
    </head>
    <body>
 
       <b:message key="key1"locale="en" /><!-- 输出English -->
 
       <b:message key="key1"/><!--取浏览器locale设置 输出中国 -->
 
    <%
       DataContextManager.current().setCurrentLocale(new java.util.Locale("en"));
    %>
 
       <b:message key="key1"/><!--取setCurrentLocale设置的locale 输出English -->
    </body>
</html>
0 0