Types
The types of @poltura/theme-sdk/i18n.
On this page
import { … } from '@poltura/theme-sdk/i18n';Locale
A language the store's storefront is available in.
tagrequiredstringThe BCP 47 tag, such as `hu-HU`.
languagerequiredstringThe language subtag, such as `hu`.
countryrequiredCountryCode | nullThe country subtag in upper case, or null for a language without one.
labelrequiredstringThe language's own name for itself, such as `Magyar`.
nameOrderrequiredNameOrderThe order names are written in this language.
NameOrder
The order a person's given and family names are written in.
type NameOrder = 'givenFirst' | 'familyFirst'TextValues
Values filled into the placeholders of a text.
type TextValues = Readonly<Record<string, string | number>>Translator
One platform text by key, with its placeholders filled.
type Translator = (key: string, values?: TextValues) => stringRichTextValues
Values for a text with marked passages: plain values fill placeholders, functions wrap the passage between <name> and </name>.
type RichTextValues = Readonly<Record<string, string | number | ((chunks: ReactNode) => ReactNode)>>RichTranslator
One platform text by key, its placeholders filled and its marked passages drawn by the given functions.
type RichTranslator = (key: string, values?: RichTextValues) => ReactNodeThemeText
One of the theme's own texts by dotted key, with placeholders and ICU plurals resolved.
type ThemeText = (key: string, values?: TextValues) => stringMoneyFormatOptions
How Formatter writes an amount of money.
display'symbol' | 'code'`symbol` writes `Ft` or `€`, `code` writes `HUF` or `EUR`; screens use the symbol.
zeroLabelstringThe text shown instead of a zero amount, such as `Free`.
Formatter
Formats numbers, money, dates and lists in the page language and the store's time zone.
moneyrequired(value: Money, options?: MoneyFormatOptions) => stringAn amount of money, such as `12 990 Ft`; empty while prices are hidden from the visitor.
numberrequired(value: number, options?: Intl.NumberFormatOptions) => stringA number with the language's separators.
percentrequired(value: number) => stringA percentage from its number, so `27` writes `27%`.
daterequired(value: Date | string, options?: Intl.DateTimeFormatOptions) => stringA calendar date in the store's time zone.
dateTimerequired(value: Date | string, options?: Intl.DateTimeFormatOptions) => stringA date with its time of day in the store's time zone.
relativeTimerequired(value: Date | string, now?: Date) => stringHow long ago or from now an instant is, such as `3 minutes ago`.
listrequired(values: readonly string[], options?: Intl.ListFormatOptions) => stringA list joined the language's way, such as `a, b and c`.
calendarYearrequired() => numberThe current year in the store's time zone.
Locales
The page language and every language the storefront offers.
currentrequiredLocaleThe language the page renders in.
availablerequiredreadonly Locale[]Every language the storefront offers, the current one included.