labels"
m (Created page with "{{ZUMLReferencePageHeader}} = labels - java.util.Map = The [[ZK Developer's Reference/Internationalization/Labels|internationalization labels]. =Version History= {| border='1p...") |
m (correct highlight (via JWB)) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
= labels - java.util.Map = | = labels - java.util.Map = | ||
− | + | A map of all [[ZK Developer's Reference/Internationalization/Labels|internationalization labels]] belonging to the current locale (<javadoc method="getCurrent()">org.zkoss.util.Locales</javadoc>). | |
+ | |||
+ | For example, if you have a property file as follows: | ||
+ | |||
+ | <source lang="text"> | ||
+ | owner=Foo Inc. | ||
+ | application.name=Killer | ||
+ | application.title=Killer 2011 | ||
+ | </source> | ||
+ | |||
+ | Then, you could access them with this implicit object as follows. | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <grid> | ||
+ | <row>${labels.owner}</row> | ||
+ | <row>${labels.application.name}</row> | ||
+ | <row>${labels.application.title}</row> | ||
+ | </grid> | ||
+ | </source> | ||
+ | |||
+ | Notice that the key of a property could be name as ''key1.key2'', and EL expressions could retrieve them correctly. | ||
+ | More precisely, ZK groups the segmented labels as map. For example, <code>${labels.app}</code> was resolved as a map containing two entries (<code>title</code> and <code>description</code>). | ||
+ | |||
+ | <source lang="xml"> | ||
+ | app.title=Foo | ||
+ | app.description=A super application | ||
+ | </source> | ||
+ | |||
+ | If you have a key named as the prefix of the other keys, you have to use <code>$</code> to access it. For example, <code>${labels.app.$}</code> is required to resolve the label with key named <code>app</code>. | ||
+ | |||
+ | <source lang="xml"> | ||
+ | app=Application | ||
+ | app.title=Foo | ||
+ | app.description=A super application | ||
+ | </source> | ||
+ | |||
+ | <blockquote> | ||
+ | ---- | ||
+ | '''Under the hood:''' | ||
+ | The <code>labels</code> object is actually the map returned by <javadoc method="getSegmentedLabels()">org.zkoss.util.resource.Labels</javadoc>. Furthermore, if the key of a property contains dot ('''.'''), all properties with the same prefix are grouped as another map. For example, <code>${labels.application}</code> (i.e., <code>Labels.getSegmentedLables().get("application")</code>) will return a map containing two entries (<code>name</code> and <code>title</code>) in the previous example. | ||
+ | </blockquote> | ||
=Version History= | =Version History= |
Latest revision as of 13:26, 19 January 2022
labels - java.util.Map
A map of all internationalization labels belonging to the current locale (Locales.getCurrent()).
For example, if you have a property file as follows:
owner=Foo Inc.
application.name=Killer
application.title=Killer 2011
Then, you could access them with this implicit object as follows.
<grid>
<row>${labels.owner}</row>
<row>${labels.application.name}</row>
<row>${labels.application.title}</row>
</grid>
Notice that the key of a property could be name as key1.key2, and EL expressions could retrieve them correctly.
More precisely, ZK groups the segmented labels as map. For example, ${labels.app}
was resolved as a map containing two entries (title
and description
).
app.title=Foo
app.description=A super application
If you have a key named as the prefix of the other keys, you have to use $
to access it. For example, ${labels.app.$}
is required to resolve the label with key named app
.
app=Application
app.title=Foo
app.description=A super application
Under the hood: The
labels
object is actually the map returned by Labels.getSegmentedLabels(). Furthermore, if the key of a property contains dot (.), all properties with the same prefix are grouped as another map. For example,${labels.application}
(i.e.,Labels.getSegmentedLables().get("application")
) will return a map containing two entries (name
andtitle
) in the previous example.
Version History
Version | Date | Content |
---|---|---|
5.0.7 | March, 2011 | This implicit object was introduced. |