Skip to content

localizationSubstore

Manages the available languages and countries offered by the API, and tracks which language and country the user has selected. The selected values flow into numberFormatterSubstore to produce locale-correct number and price strings.

Table of contents

Properties

Methods


Properties

availableLanguagesData

availableLanguagesData: ApiResource<TLanguage[]>

API resource containing the list of supported languages, including loading and error state.

Each TLanguage has at minimum a slug (e.g., "en", "de") and a display name. Fetch is initiated automatically on store creation. See ApiResource for the loading/error shape.

Related


availableCountriesData

availableCountriesData: ApiResource<TCountry[]>

API resource containing the list of supported countries, including loading and error state.

Each TCountry has a slug, a display name, and a nested currency object (with at minimum a code such as "EUR" or "USD"). See ApiResource.

Related


selectedLanguage

selectedLanguage: TLanguage | undefined

Currently selected language, or undefined if not yet resolved.

undefined while availableLanguagesData is still loading or when no language has been set yet. The SDK uses this value as the locale for all Intl.NumberFormat instances and as the lang query parameter in API calls.

Related


selectedCountry

selectedCountry: TCountry | undefined

Currently selected country (with its associated currency), or undefined if not yet resolved.

undefined while availableCountriesData is still loading or when no country has been set. The SDK uses selectedCountry.currency.code to build currency-aware Intl.NumberFormat instances.

Related


Methods

setSelectedLanguage

setSelectedLanguage: (languageSlug: string) => void

Selects a language by its slug from the available languages list.

Looks up the language in availableLanguagesData.data by slug and writes it to selectedLanguage. Does nothing if no match is found.

Parameters

NameTypeDescription
languageSlugstringThe slug of the language to select (e.g., "en")

Related


setSelectedCountry

setSelectedCountry: (countrySlug: string) => void

Selects a country by its slug from the available countries list.

Looks up the country in availableCountriesData.data by slug and writes it to selectedCountry. Does nothing if no match is found.

Parameters

NameTypeDescription
countrySlugstringThe slug of the country to select (e.g., "de")

Related