官方文档中说国际化很简单,资源文件放在WEB-INF下,文件名固定,都是i3-label.properties,简体中文的就是i3-label_zh_CN.properties。
按照官方文档说的,修改Locale就是:
session.setAttribute(Attributes.PREFERRED_LOCALE,xxxLocale)
但是根本不好使,后来搜索了下,发现需要设置:
Locales.setThreadLocal(xxxLocale)

另外一个问题是页面的刷新是个问题,如果不考虑用户已有的操作,假设用户进入首页没有做什么事情,首先改变Locale,那么刷新比较简单:
Executions.getCurrent().sendRedirect(“”)

国际化在页面中使用也比较丑陋,先是:
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?>

<toolbarbutton label="${c:l(‘button.add’)}" image="../images/add.png" onClick="userListWindow.onAdd()"/>
比较理想的应该是像数据绑定一样,能够声明某个东西,然后Label的内容都从资源文件取:
<?init class="xxx.I18nBinderInit"?>
<toolbarbutton label="button.add" image="../images/add.png" onClick="userListWindow.onAdd()"/>

当然,这个功能可能自己也可以自己实现,有时间我会试试。

最后说的一点就是zk的默认中文是繁体中文,比较难受。

(Visited 266 times, 1 visits today)