ui/build/i18n/context.svelte
ui/build/i18n/context.svelte
Interfaces
I18nApi
Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:3
The translation API a component consumes. Keys is the catalog key union.
Type Parameters
| Type Parameter | Default type |
|---|---|
Keys extends string |
string |
Properties
intlLocale
readonly intlLocale: string;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:9
The Intl.* locale string for the active locale (en-US / zh-CN).
locale
readonly locale: string;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:5
The active application locale.
locales
readonly locales: readonly string[];Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:7
The locale order the catalogs ship (toggle order, primary first).
t
readonly t: (key, vars?) => string;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:11
Translate a typed key, with {placeholder} interpolation.
Parameters
| Parameter | Type |
|---|---|
key |
Keys |
vars? |
Readonly<Record<string, string | number>> |
Returns
string
Methods
has()
has(key): key is Keys;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:13
True when the key exists in any locale of the catalog set.
Parameters
| Parameter | Type |
|---|---|
key |
string |
Returns
key is Keys
setLocale()
setLocale(locale): void;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:15
Switch the active locale; persists the choice and sets <html lang>.
Parameters
| Parameter | Type |
|---|---|
locale |
string |
Returns
void
Functions
getGlobalLocale()
function getGlobalLocale(): string;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:41
Returns
string
provideI18n()
function provideI18n<C>(catalogs, initialLocale?): I18nApi<KeysOf<C>>;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:26
Install the application's catalog pair and initial locale for the whole
component subtree. Call once from an application root during component init;
the Bolt workspace shell is the caller, merging the tenant's catalogs over
uiMessages before handing them here.
The initial locale resolves as: persisted choice, browser languages, then English.
Type Parameters
| Type Parameter |
|---|
C extends Readonly<Record<string, Readonly<Record<string, string>>>> |
Parameters
| Parameter | Type |
|---|---|
catalogs |
C |
initialLocale? |
string |
Returns
I18nApi<KeysOf<C>>
setGlobalLocale()
function setGlobalLocale(locale): void;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:40
Switch the ui package's fallback locale for apps that do not install a
provider (only possible once @norbital-ai/ui ships the i18n module).
Parameters
| Parameter | Type |
|---|---|
locale |
string |
Returns
void
useI18n()
function useI18n<Keys>(): I18nApi<Keys>;Defined in: apps/website/.api-docs-entry/ui/build/i18n/context.svelte.d.ts:35
Read the translation API from context.
Falls back to the ui package's own catalog and a module-level global locale
(see setGlobalLocale) when no provider is installed — which keeps
components renderable in isolation and lets apps without the context
mechanism still switch the shared ui chrome.
Type Parameters
| Type Parameter | Default type |
|---|---|
Keys extends string |
string |
Returns
I18nApi<Keys>