std/build/i18n/locale
std/build/i18n/locale
Variables
DEFAULT_LOCALE
const DEFAULT_LOCALE: "en" = "en";Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:16
The fallback locale when no stored or detected choice exists.
INTL_LOCALES
const INTL_LOCALES: Readonly<Record<string, string>>;Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:18
The Intl locale each application locale maps to for Intl.* formatting.
STORED_LOCALE_KEY
const STORED_LOCALE_KEY: "norbital.locale" = "norbital.locale";Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:25
Browser/localStorage key under which a viewer's locale choice is persisted.
SUPPORTED_LOCALES
const SUPPORTED_LOCALES: readonly string[];Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:14
The supported application locales, in toggle order. English is the source-of-truth catalog.
Functions
intlLocale()
function intlLocale(locale): string;Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:23
The Intl locale string for an application locale, falling back to the raw code so an unmapped locale still formats sensibly.
Parameters
| Parameter | Type |
|---|---|
locale |
string |
Returns
string
parseLocale()
function parseLocale(value): string | null;Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:33
Parse a BCP-47 tag into an application locale, or null.
zh-CN, zh-TW, and zh-Hans all resolve to zh; anything whose primary
subtag is not a supported locale resolves to null. Malformed values resolve
to null — never to a guessed locale, so callers keep their fallback chain.
Parameters
| Parameter | Type |
|---|---|
value |
string | null | undefined |
Returns
string | null
pickLocale()
function pickLocale(candidates, fallback?): string;Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:38
Pick the first supported locale from an ordered candidate list (typically
navigator.languages or an Accept-Language header).
Parameters
| Parameter | Type |
|---|---|
candidates |
readonly string[] | null | undefined |
fallback? |
string |
Returns
string
setHtmlLang()
function setHtmlLang(locale): void;Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:44
Set the document language attribute. Safe in non-browser environments.
Parameters
| Parameter | Type |
|---|---|
locale |
string |
Returns
void
storedLocale()
function storedLocale(storage?): string | null;Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:40
Read the persisted locale, if any. Safe in non-browser environments.
Parameters
| Parameter | Type |
|---|---|
storage? |
Pick<Storage, "getItem"> | null |
Returns
string | null
storeLocale()
function storeLocale(locale, storage?): void;Defined in: apps/website/.api-docs-entry/std/build/i18n/locale.d.ts:42
Persist the locale choice. Safe in non-browser environments.
Parameters
| Parameter | Type |
|---|---|
locale |
string |
storage? |
Pick<Storage, "setItem"> | null |
Returns
void