InformationModel.LookupTranslation(localizedText, localeIds)

Reads the translations associated with a key based on the
NamespaceIndex
and
TextId
properties of the first argument.
Returns the
LocaleId
and
Text
properties of the
LocalizedText
object that are assigned a value based on the first translation available between the locales supplied in the second argument.
LocalizedText LookupTranslation(LocalizedText
localizedText
, List<string>
localeIds
);

Arguments

localizedText
(LocalizedText)
A C# object that
TextId
and
NamespaceIndex
properties identify the key of interest.
localeIds
(List)
The locales of interest expressed with locale IDs. Any IDs that come after the first ID indicate a fallback locale.

Returns

LocalizedText
The
LocaleId
and
Text
properties of a C# object that are assigned values based on the first locale available among those indicated in the
localeIds
argument.
TIP: If a string for the indicated locale is not available, the
LocaleId
and
Text
properties remain empty.

Example

The following example shows an API that returns a
translation
object of the
LocalizedText
type, which represents the
Key2
key of a
LocalizationDictionary
. The first API argument is a
LocalizedText
object created using a constructor which argument defines its
TextId
property. The second argument is a list that contains the IDs for the locales of interest (
it-IT
and
es-ES
).
The
translation
object is used to set the text of a label based on the first available translation between
it-IT
and
es-ES
.
var myLocalizedText = new LocalizedText("Key2"); var translation = InformationModel.LookupTranslation(myLocalizedText, new List<string>() { "it-IT", "es-ES" }); var label2 = Owner.Get<Label>("Label2"); label2.Text = "Translation: " + translation.Text;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.