Locale
A locale decides how Chameleon's components write numbers and which language their built-in text is in. Set it to German and a number field shows 1.234,5 where an American user sees 1,234.5, and a screen reader announces a dialog's close button as Schließen.
What locale changes
| Component | What changes |
|---|---|
| Number field | The digit grouping and decimal separator it shows when the user isn't editing it: 1.234,5 in de-DE, 1,234.5 in en-US, 12,34,567 in en-IN |
| Dialog | The name of its close button, which screen readers announce |
| Toast | The name of its close button, which screen readers announce |
| Popover | The name of the close button it offers screen readers, which isn't drawn on screen |
| Data table | How its number, price, percentage, and date cells are written: 1.234,5 and 28.12.2025 in de-DE, 1,234.5 and 12/28/2025 in en-US. A price column's currency comes from the column's currency, never from the locale |
| Data grid | The same as a data table |
Every other component looks and sounds the same in every locale.
Choosing the locale
A component's locale is its language, the HTML lang attribute. Each component uses the first of these that's set:
- The
langon the component itself, or on the nearest element around it that has one. - The page's language, the
langattribute of its<html>element. - The user's browser language.
Leave lang off everywhere and each user gets their own browser language. Set it when everybody must see the same format, such as a trading screen that always shows Swiss numbers.
The one tag sets both the text and the formats. en-CH gives English text with Swiss numbers, 1’234.5, and a numbering extension, such as en-u-nu-arab, picks the digits. Dates always use the Gregorian calendar, whatever calendar the tag names.
For your app
Set lang on your page's <html> element. Components follow it at once, those already on screen too, including when your code changes it.
<html lang="de-CH">
For part of a page or one component
Set lang on the component, or on any element around a group of them.
<cw-number-field label="Amount" lang="en-CH"></cw-number-field>
<section lang="fr">
<cw-data-table></cw-data-table>
</section>
In React that's <CrNumberField lang="en-CH" />, and in Blazor <CbNumberField lang="en-CH" />.
A component follows a change to its own lang at once. When your code changes the lang of an element around components, call repaintChameleonComponents() afterward so they pick up the new language.
import { repaintChameleonComponents } from "@materia-technologies-inc/chameleon-components-web";
section.lang = "de";
repaintChameleonComponents();
Tags in other forms
A locale is a BCP 47 tag, written with a hyphen: en-US, not en_US. A tag in another form never breaks a component:
- Chameleon reads
en_USandfr_FR.UTF-8, the forms some operating systems use, asen-USandfr-FR. - A tag that names no language, such as
C, falls back to English.
What locale doesn't do
- Right-to-left layout comes from the
dirattribute on your page or an ancestor.lang="ar"alone leaves a component left-to-right, so setdir="rtl"too. - Your own text stays as you wrote it: labels, placeholders, supporting text, and anything you put in a slot.
- While the user edits a number field, it shows the plain number the way the browser's number input does: a period for the decimal point and no thousands separators. Its
valuetakes the same form, so your code reads1234.5in every locale. - A data table's prices stay in the currency their column names: switching
en-UStode-DEwrites $1,234.50 as 1.234,50 $, not in euros. - Dates, prices, and other values elsewhere on your page aren't Chameleon's to format. Use the browser's
Intlformatters for them.
Translations
Chameleon's built-in text comes in 184 locales across 149 languages. It's machine-translated and lightly reviewed by our team.
A locale without its own translation uses its language's: fr-BE gets the French text. A language Chameleon doesn't translate gets English, marked with lang="en" so screen readers pronounce it as English. A name that joins built-in text to your own words, such as a chip's "Remove" button named after its label, is not marked, since one lang cannot cover both; set aria-label-remove there to write the whole name yourself. Number formats come from the browser instead, so a number field formats every locale the browser knows.
If a translation reads wrong, open an issue in the Chameleon issue tracker naming the locale, the component, what the text says, and what it should say.