api.l10n
Interface: IL10nApi
Implementation tier: T1
Localization helpers: resolve translation keys from the extension's catalog and detect locale changes.
info
Extension catalogs ship in l10n/<bcp47>.json files inside the extension
package. The host loads them into Spec B's I18nService under a namespace
prefixed with the extension ID, so ext.greekTools.openLexicon resolves to
the extension's own catalog.
Methods
t
t(key: string, params?: Record<string, unknown>): Promise<string>
Resolve a localization key against the extension's catalog.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
key | string | Yes | |
params | Record<string, unknown> | No |
Returns: Promise<string>
currentLocale
currentLocale(): Promise<string>
The host's current UI locale, e.g. 'en' or 'pt-BR'.
Returns: Promise<string>
Events
onDidChangeLocale
onDidChangeLocale: IEventApi<string>
Payload type: string
Subscribe to this event:
const handle = await api.l10n.onDidChangeLocale.subscribe((payload) => {
// Handle event
});
// Later, to unsubscribe:
await handle.dispose();