Skip to content
Widget Library

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.


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.


The same rule is used for titles and for button texts.

  1. An exact match on the language key.
  2. Otherwise the base language: tr-TR matches the key TR.
  3. 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.


{
"labels": { "addToBasket": "Add to cart" },
"labelsByLanguage": {
"TR": { "addToBasket": "Sepete ekle" }
}
}

For each text the widget takes the first that exists:

  1. the entry for the language in labelsByLanguage,
  2. the entry in labels,
  3. 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.


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.


  • Config Schema lists the other settings.
  • The scenarios 13-* and 05b-*, 05c-* under scenarios/recommendation/ test this page.