Selkies

i18n

The translator: one dictionary per locale (translations.ts), the locale resolved once at module load from navigator.language, and English as the fallback for a key the locale lacks. A key no dictionary has is returned as written, or as the literal a caller passes in place of its variables, so a misspelled key shows its English text rather than nothing.

Functions

resolveLocale()

function resolveLocale(langCode?): string;

Defined in: i18n.ts:25

The dictionary key a browser language tag reads: its base language, so en-US reads en, except Chinese, which is two written languages under one base: a tag naming the Traditional script or a region that writes it (Taiwan, Hong Kong, Macao) reads zh_tw, any other Chinese tag zh_cn.

Parameters

ParameterTypeDefault valueDescription
langCode?string"en"A BCP 47 tag.

Returns

string

The dictionary key.


lookup()

function lookup(table, key): string;

Defined in: i18n.ts:37

Resolves a dotted key against a dictionary, a string or nothing.

Parameters

ParameterType
tableDictionary
keystring

Returns

string


interpolate()

function interpolate(text, vars?): string;

Defined in: i18n.ts:47

Substitutes {name} placeholders from vars, leaving unknown ones intact.

Parameters

ParameterType
textstring
vars?Record<string, unknown>

Returns

string


t()

function t(key, vars?): string;

Defined in: i18n.ts:59

Translates a dotted key.

Parameters

ParameterTypeDescription
keystringDotted lookup key.
vars?string | Record<string, unknown>Values for {name} placeholders, or a literal to show where no dictionary has the key.

Returns

string

The translated string.


tl()

function tl(key, vars?): string;

Defined in: i18n.ts:75

Label variant of t: a label that ends in : (or fullwidth :) in the dictionary is shown without it, since the controls draw their own labels.

Parameters

ParameterTypeDescription
keystringDotted lookup key.
vars?Record<string, unknown>Values for {name} placeholders.

Returns

string

The translated label without its trailing colon.