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
selectedLanguage— the currently selected entry from this listsetSelectedLanguage— selects by slug
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
selectedCountry— the currently selected entry from this listsetSelectedCountry— selects by slugnumberFormatterSubstore.getPriceFormatter— usesselectedCountry.currency.code
selectedLanguage
selectedLanguage: TLanguage | undefinedCurrently 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
setSelectedLanguage— setternumberFormatterSubstore.getNumberFormatter— returnsundefinedwhen this isundefinedaddonsSubstore.getAddons— passes the slug in API requestsappearanceSubstore.getAppearance— passes the slug in API requestsoptionsSubstore.getOption— passes the slug in API requests
selectedCountry
selectedCountry: TCountry | undefinedCurrently 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
setSelectedCountry— setternumberFormatterSubstore.getPriceFormatter— returnsundefinedwhen this isundefined
Methods
setSelectedLanguage
setSelectedLanguage: (languageSlug: string) => voidSelects 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
| Name | Type | Description |
|---|---|---|
languageSlug | string | The slug of the language to select (e.g., "en") |
Related
setSelectedCountry
setSelectedCountry: (countrySlug: string) => voidSelects 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
| Name | Type | Description |
|---|---|---|
countrySlug | string | The slug of the country to select (e.g., "de") |
Related