Labels"

From Documentation
m (Created page with '{{ZKDevelopersGuidePageHeader}} Developers could separate Locale-dependent data from the ZUML pages (and JSP pages) by storing them in i3-label_''lang''_''CNTY''.properties unde…')
 
(No difference)

Revision as of 09:44, 1 October 2010

Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


Developers could separate Locale-dependent data from the ZUML pages (and JSP pages) by storing them in i3-label_lang_CNTY.properties under the WEB-INF directory, where lang is the language such as en and fr, and CNTY is the country, such as US and FR.

To get a Locale-dependent property, you could use Labels in Java, or ${c:l('key')} in EL expression. To use it in EL, you have to specify the TLD file with the taglib directive in your page as follows.

<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>

<window title="${c:l('app.title')}">
 ...
</window>

When a Locale-dependent label is about to retrieved, one of i3-label_lang_CNTY.properties will be loaded. For example, if the Locale is de_DE, then WEB-INF/i3-label_de_DE.properties will be loaded. If no such file, ZK will try to load WEB-INF/i3-label_de.properties and WEB-INF/i3-label.properties in turn.[1]

To access labels in Java codes (including zscript), use the getLabel method of the Labels class.

In addition, you could extend the label loader to load labels from other locations, say database, by registering a locator, which must implement the LabelLocator interface. Then, invoke the register method of the Labels class.

Notes

  1. For performance issue, the look up sequence for English is different: First:i3-label_en_US.properties, Second:i3-label.properties, Third:i3-label_en.properties



Last Update : 2010/10/01

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.