Provides text localization in the browser.
Tecton provides text localization in three ways:
loc
platform capabilityq2-loc
element described belowThe <q2-loc>
component can be used to add translated text to various parts of your application. The value
attribute accepts a key from your translation dictionary, and will render the translated value at runtime. Alternatively, you can pass the translation key as text in the element to the same effect.
translations: {
"styleGuide.components.q2Loc.greetingExample": "Hello there!"
}
// Preferred method:
<q2-loc value="styleGuide.components.q2Loc.greetingExample"></q2-loc>
// Alternative method:
<q2-loc>styleGuide.components.q2Loc.greetingExample</q2-loc>
This will render the value of the provided key as text (e.g. "Hello there!")
In addition to passing a localization key to the value
attribute , you can also dynamically set the substitutions property as an array of strings.
translations: {
"styleGuide.components.q2Loc.greetingExample": "Hello, {0} {1}, welcome to {2}"
}
element.value = "styleGuide.components.q2Loc.greetingExample";
element.substitutions = ["Jane", "Doe", "Earth"];
This will render combined text using the provided substitutions (e.g., "Hello, Jane Doe, welcome to Earth!").
The q2-loc
element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.
substitutions
Any substitutions you would like to pass into the localization string.
value
The reference to the localization key you would like to display the localized output of. If no value is provided, any text inside the element will be used as a fallback.
Initial Release
Support use inside <q2-option>
The following CSS variables are available to override the default theme styles of the q2-loc
component.
There is 1 frequently asked question related to this page.