A simple example of ZK (7.0.1) internationalization

Source: Internet
Author: User
Tags cdata i18n locale
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>  


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.