This Built-in DataType defines a structure containing a String in a locale-specific translation specified in the identifier for the locale. Its elements are defined in Table 26.
Table 26 – LocalizedText Definition
Name |
Type |
Description |
LocalizedText |
structure |
|
Locale |
LocaleId |
The identifier for the locale (e.g. “en-US”). |
Text |
String |
The localized text. |
Two special locales may be used with LocalizedText to support multiple languages and text substitutions. When using the special locales the content of the Text element shall be a JSON encoded object. The JSON Text element should be in the JSON minified form.
Special locales shall never be used as a Server’s default locale.
The “mul” locale is used to provide multiple languages in the Text element. The JSON object shall include a key “t” which consists of an array of locale and text pairs with the locale being the first element of the pair array.
An example which provides 2 languages.
{
“t”:[
[“de-DE“, “Ich bin dein text 1,2345”],
[“en-US”, “I’m your text 1.2345”]
]
}
The “qst” locale is used to provide consumer substitutions of the Text element in a single or in multiple languages. This locale extends the “mul” locale defined in 8.5.2.2 and therefore shall include a key “t” which provides the text that replacements are applied to.
The JSON object shall also contain a key “r” which consists of an array of replacement key and replacement text pairs. These replacements shall be applied by the consumer to the “t” text strings by replacing any occurrence of the replacement key with the replacement text.
If there is only one replacement text, and the text is encoded as a scalar the text isapplied to all languages.
If separate languages are provided the replacement texts shall be encoded as an array. In this case the first replacement text shall be applied to the first language, the second to the second language and so on. If there are less replacement texts than languages due to an error, no replacement takes place for the remaining languages, leaving the replacement key. The last example below illustrates these rules.
A replacement key shall be unique and shall not be a substring of another replacement key. A consumer shall ensure replaced text shall not be replaced again by any subsequent replacement operation.
An example of a single language substitution.
{
“t”:[
[“en-US”, “I’m your text @1@”]
],
“r”:[
[“@1@”, 1.2345]
]
}
“en-US” text after substitution
“I’m your text 1.2345”
An example which provides 2 languages with a substitution that apply to both languages.
{
“t”:[
[“de-DE“, “Ich bin dein text @1@”],
[“en-US”, “I’m your text @1@”]
],
“r”:[
[“@1@”, 1.2345]
]
}
“de-DE” text after substitution
“Ich bin dein text 1,2345”
“en-US” text after substitution
“I’m your text 1.2345”
An example which provides 2 languages with a substitution that apply to both languages and substitutions that apply to specific languages.
{
“t”:[
[“de-DE”, “Dieses@2@ Ist eine @1@ Meldung: /2/ hat das Problem %d6 verursacht!”],
[“en-US”, “This@2@ is a @1@ Message: Problem %d6 was caused by /2/!”]
],
“r”:[
[“%d6”, 1.2345],
[“@1@”, [“gültige”, “valid”]],
[“/2/”, 42],
[“@2@”, [“@”]]
]
}
“de-DE” text after substitution
“Dieses@ Ist eine gültige Meldung: 42 hat das Problem 1,2345 verursacht!”
“en-US” text after substitution
“This@2@ is a valid Message: Problem 1.2345 was caused by 42!”