刚看了@eyelee同窗的JFinal 国际化的简单实现的文章,我打算分享一下本身为@紫电清霜的JFinal-BBS示例应用添加Rythm模版引擎和国际化功能展现的经验。html
在开始以前,你们能够先经过点击这个视频看看效果。java
下面是实现步骤:git
下载JFinal Rythm插件。解包后将lib中的jar文件加入到你的JFinal应用项目中github
配置JFinal Rythm插件:浏览器
private Properties conf = null; public void configConstant(Constants me) { this.conf = loadPropertyFile("path/to/properties/"); } public void configPlugin(Plugins me) { ... me.add(new RythmPlugin(conf)); }
# 设置模版根目录到 WEB-INF/rythm rythm.home.template=../rythm # 支持国际化 rythm.i18n.enabled=true
messages_zh_CN.properties messages_en_US.properties
并在其中分别加入所需内容,例如:this
layout.home=首页 #messages.zh_CN.properties layout.home=Home #messages.en_US.properties
<a href="/">@i18n("layout.home")</a>
好了,基本上就是这些了。.net
综上所述,在JFinal/Rythm的开发环境下,国际化主要工做在messages文件上面,完成以后你的国际化经过Rythm引擎内置指令@i18n()来完成。值得一提的是这个国际化机制是比较智能的。根据用户浏览器的语言设置,系统会自动加载所需资源,不须要开发人员在代码中作任何事情。插件
但愿你们能喜欢[] 若有反馈能够@greenlaw110。谢谢!code