1. Prepare three resource files i3-label.properties, i3-label_en_us.properties, i3-label_zh_cn.properties, and place the resource files in the Web-inf directory.
I3-label.properties:
Title=greeting
Msg=hello, {0}\!
I3-label_en_us.properties:
Title=greeting
Msg=hello, {0}\!
I3-label_zh_cn.properties:
title= Greetings
msg= Hello, {0}.
2. Add the taglib directive to the Zul page:
<?taglib uri= "Http://www.zkoss.org/dsp/web/core" prefix= "C"?>
3. There are three ways to use internationalized resources: EL Expression built-in object labels:
<label value= "${labels.title}"/>
Tag library c:l (' key '):
<label value= "${c:l (' title ')}"/>
Java code is obtained using the Org.zkoss.util.resource.Labels object instance:
String title = Labels.getlabel ("title");
String msg = Labels.getlabel ("msg", New string[]{"Huey"});
4. Modify Locale:
Locale Locale = new Locale ("en", "CN");
Session.setattribute (Org.zkoss.web.Attributes.PREFERRED_LOCALE, LOCALE);
5. Example:
<?page title= "Hello i18n" contenttype= "Text/html;charset=utf-8"?> <?taglib uri= "http://www.zkoss.org/dsp/" Web/core "prefix=" C "?> <zk> <zscript><! [cdata[string[] name = new string[] {"Huey"};]] ></zscript> <window title= "Hello i18n" border= "normal" > <vbox>