Label
A Label is a text with one translation per language. You read it in the End user’s current language as This.$T.<LabelName>, or in a specific language as This.$T_<LanguageId>.<LabelName>.
Availability: Everywhere
How to reach it
Section titled “How to reach it”| Access path | What it is |
|---|---|
This.$T.<LabelName> | The Label’s text in the current language. |
This.$T_<LanguageId>.<LabelName> | The Label’s text in one language. <LanguageId> is the ID of a Language included in the Module, for example This.$T_English.Greeting. |
Labels are grouped under the $T namespaces. This.<LabelName> does not work: always go through This.$T or This.$T_<LanguageId>. Each Module has its own Labels, so This.$T holds only the Labels of the Module the code belongs to.
Properties
Section titled “Properties”const $T: { '<LabelName>': string '<LabelWithInputs>': ((<input>: <type>, …) => string) & string}The Module’s Labels, each returning its text in the current language (Sys.Language.language). If the Label has no text in that language, Lowgile uses the text in the default language. In the code editor, hovering over a Label shows its translations.
A Label that can have inputs is a function: call it with its inputs to get the text with the inputs filled in, for example This.$T.WelcomeUser(user.firstName). Used as a string without calling it, it gives the text with undefined in place of each input.
Type: an object with one string property per Label · Availability: Everywhere
When a Label has no text in the current language or the default language:
| Side | Result |
|---|---|
| Server | The text [MISSING LABEL: <ModuleId>.<LabelName>]. |
| Client | An HTML span element that shows the Label’s name and marks it as a missing translation. |
An empty text counts as missing.
On the client, while translation edit mode is on (Sys.Language.editMode), each Label returns its text wrapped in an HTML span element. Lowgile uses that element to let the Developer edit the translation on the Screen.
Note
In translation edit mode, a Label with inputs is a string, not a function, so calling This.$T.<LabelName>(…) throws an error.
$T_<LanguageId>
Section titled “$T_<LanguageId>”const $T_<LanguageId>: { '<LabelName>': string '<LabelWithInputs>': ((<input>: <type>, …) => string) & string}The Module’s Labels, each returning its text in this one language, whatever the current language. There is one such object per Language included in the Module. Lowgile does not fall back to another language and does not apply edit mode here.
Type: an object with one string property per Label · Availability: Everywhere
Note
A Label without a text in this language returns undefined, although it is declared as string. For a Label with inputs, calling it returns the text "undefined".
Related
Section titled “Related”- Label
- Sys.Language
- Language