Beetl国际化原理是Java中自定义一个方法(该方法根据Locale获取对应的properties), 然后将该方法注册到Beetl框架中,最后在Beetl模版页使用该方法。
public class I18n implements Function {
@Override
public Object call(Object[] obj, Context context) {
HttpServletRequest req = (HttpServletRequest )context.getVar("request");
//Locale locale = LocaleContextHolder.getLocale();
return I18N.getText((String) obj[0],req.getLocale());
}
}
//gt是GroupTemplate对象
gt.registerFunction("i18n", new I18n());
<%i18n("test");%>
参考
http://blog.csdn.net/linxingliang/article/details/52350238
http://blog.csdn.net/qq_28587263/article/details/53611979
http://ibeetl.com/guide/#beetl
https://segmentfault.com/a/1190000007342110