Localization

Updated:

Provides text localization via HTML

Tecton provides a HTML element to simplify rendering localizable content to your web application. For further details on Tecton's internationalization system, see our guide: Translation and Localization

Basic Implementation

The <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.

// In translation dictionary

translations: {
  "styleGuide.components.q2Loc.greetingExample": "Hello there!"
}

// In HTML

<q2-loc value="styleGuide.components.q2Loc.greetingExample"></q2-loc>

// Alternate:

<q2-loc>styleGuide.components.q2Loc.greetingExample</q2-loc>

This will render the value of the provided key as text (e.g. "Hello there!").

Using Substitutions

In addition to passing a localization key to the value attribute , you can also dynamically set the substitutions property as an array of strings.

// In translation dictionary

translations: {
  "styleGuide.components.q2Loc.greetingExample": "Hello, {0} {1}, welcome to {2}"
}

// In JS file or script tag

locElement.value = "styleGuide.components.q2Loc.greetingExample";
locElement.substitutions = ["Jane", "Doe", "Earth"];

This will render combined text using the provided substitutions (e.g., "Hello, Jane Doe, welcome to Earth!").

Properties

The q2-loc element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.

Learn more about properties.

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.

Localizable

Release Notes

Initial Release

Support use inside <q2-option>

Accessibility Report

Tecton components are designed and tested to be WCAG compliant when used appropriately, and do not get released without proper validation. Developers should prefer not to set ARIA attributes when using components from the Tecton Design System.

The following CSS variables are available to override the default theme styles of the q2-loc component.

No results

There is 1 frequently asked question related to this page.