OpenWGA 7.6 - OpenWGA Concepts and Features

Design and development » WebTML » Features » Labels

Label retrieval

WebTML labels can be retrieved in WebTML using the tag <tml:label>. Attribute "key" must be used to specify the key of the label to retrieve.

<tml:label key="toc"/>

Note that we do not choose the language to retrieve the label in on the tag. The label language that is used is chosen automatically by OpenWGA individually for every single user according to the currently effective Language choice rules.

The code above will retrieve a label from the "general.properties" file. So the output of this tag - according to the example label file from Label definition - is "Table of contents" when English is chosen for language. If you want to retrieve a label from a different label file than "general.properties" you can specify that using attribute "file":

<tml:label file="webtmlref" key="title"/>

Note that we omit the suffix ".properties" when specifying the file.

WebTML labels could even be retrieved from other label containers than "labels_...". However that is seldomly used. Imagine we have label container folders "dialogs_en" and "dialogs_de":

<tml:label container="dialogs" file="release-content" key="title"/>

Note that we omit the language suffix here as language choice is automatically done by OpenWGA.

If you use multiple labels from the same non-standard container or file you may use a <tml:range> that specifies the container or file to use for all retrieved labels in its contents:

<tml:range labelcontainer="approval" labelfile="wizard">

    <tml:label key="username"/>

    <tml:label key="status"/>

    <tml:label key="next"/>

</tml:range>

This will let all three keys "username", "status" and "next" be retrieved from container "approval_<lang>" and file "wizard.properties".

There are other ways for retrieving labels than <tml:label> if you are not inside WebTML:

  • In TMLScript  method this.label() is the counterpart to <tml:label>
  • The dynamic WebTML attribute function "{label: ...}" can be used if you need to load a label into a WebTML attribute (see Dynamic WebTML attributes

If you use OpenWGA developer studio to create your designs you can benefit from some comfort functions that allow you to create labels while specifying them in WebTML code. If WDS encounters a label addressed in <tml:label> that is not yet defined in the design then it will display a little symbol on the left editor border. Clicking the symbol will offer a function to create the label:

screenshot_94.png

Clicking the function will open the addressed label file and allow you to directly enter the label text.

screenshot_95.png

Note however that this will define the label only for one language . In order to have the design be truly multi-language you will need to manually translate those labels that you defined in one language to all other needed languages.

The language in which WDS will create labels on this function can be configured on the design properties. Right-click the design folder and choose menu item "Properties". On the properties dialog select section "WGA design metadata". There you can set the language to create as setting "development language".