Languages and Texts
How a widget chooses its title and button texts by language.
This page explains where the language comes from and how a widget picks its title and button texts.
Where the Language Comes From
Section titled “Where the Language Comes From”The widget reads one value: runtime.getContext().language.
It does not look at window, at the lang attribute of the page or at the browser’s language. The class that initialises @segmentify/integration is told where the language of the site comes from, and the runtime reads it from there. There is one source of truth, and it is the integration’s.
Matching
Section titled “Matching”The same rule is used for titles and for button texts.
- An exact match on the language key.
- Otherwise the base language:
tr-TRmatches the keyTR. - Otherwise the default.
Keys compare case-insensitively, so tr, TR and Tr are the same key.
| Context language | Keys in the config | Result |
|---|---|---|
TR |
TR, EN |
TR |
tr-TR |
TR, EN |
TR |
DE |
TR, EN |
the default |
{ "title": "Recommended for you", "titles": { "TR": "Sizin için seçtiklerimiz" }}title is the default. titles holds one title per language.
Button Texts
Section titled “Button Texts”{ "labels": { "addToBasket": "Add to cart" }, "labelsByLanguage": { "TR": { "addToBasket": "Sepete ekle" } }}For each text the widget takes the first that exists:
- the entry for the language in
labelsByLanguage, - the entry in
labels, - the English default built into the library (
Add to basket,Add to favourites,See all).
A language entry may set only some of the texts; the rest fall through.
Numbers
Section titled “Numbers”The numbers the widget writes itself follow the context language, through the platform’s own number formatting.
| Value | English | Turkish |
|---|---|---|
Rating 4.5 |
4.5 |
4,5 |
Review count 1250 |
(1,250) |
(1.250) |
Discount 25 |
-25% |
-%25 |
A rating is rounded to one decimal and a discount to a whole percent.
The language may be written as TR, tr-TR or tr_TR. A language the platform does not know, or a malformed one, is formatted as English. It never falls back to the locale of the visitor’s machine, so the same config looks the same everywhere.
Prices are not formatted by the widget: priceText and oldPriceText arrive ready from the server.
Next Steps
Section titled “Next Steps”- Config Schema lists the other settings.
- The scenarios
13-*and05b-*,05c-*underscenarios/recommendation/test this page.