文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>How to change a normal struts2 project to support multi-language

How to change a normal struts2 project to support multi-language

时间:2010-10-19  来源:Forest.Stellar

Step 1, Detect if the encoding of the project is UTF-8. If not, change its encoding to UTF-8. Step 2, Add configuration in struts' config file[src/struts.xml].
    <constant name="struts.custom.i18n.resources" value="messageResource" />
    <constant name="struts.i18n.encoding" value="UTF-8"/>
    <constant name="struts.locale" value="en_US"> </constant>
Step 3, Add propertites files to src. the file name's format is messageResource_lang_county.properties. Take chinese and english for example:     messageResource_zh_CN.properties, messageResource_en_US.properties... The content's format in property file is key/value, and one pair per line:     Login.Login=Login
    Login.Language=Language
    HelloWord={0},Hello World     ... Step 4, Replace labels you want to change in jsp page with the struts tag as follow methods.    1, <s:property value="%{getText('Login.Login')}"/>    2, <s:text name="Login.Language"/>    3, <s:text name="HelloWord">            <s:param>Mike</s:param>        </s:text> Step 4, Replace strings you want to change in action as follow methods.     1, getText("Login.Language")     2, getText("HelloWord", {"Mike"}) At this time, The page's language will be same as your browser's language. And if you want to change the language manually, you should do the next step. Step 5, Add a action to change the current Locale.      request.getSession().setAttribute("WW_TRANS_I18N_LOCALE", currentlocale);


  Wish it can help you.

 

相关阅读 更多 +
排行榜 更多 +
零界之痕手游安卓下载

零界之痕手游安卓下载

角色扮演 下载
漫游都市手机版下载

漫游都市手机版下载

赛车竞速 下载
涡轮螺旋桨飞行模拟器无限金币版下载

涡轮螺旋桨飞行模拟器无限金币版下载

模拟经营 下载