I18n
Unofficial
Main i18next instance interface.
Import:
import type { I18n } from '@obsidian-typings/obsidian-catalyst-latest';Signature:
export interface I18nProperties
| Property | Type | Description | |
|---|---|---|---|
| isInitialized | boolean | Whether the instance has been initialized. | |
| isInitializing | boolean | Whether the instance is currently initializing. | |
| isLanguageChangingTo? | string | The language a change is currently in progress to, if any. | |
| language | string | The active language code. | |
| languages | readonly string[] | The list of languages in fallback order. | |
| logger | unknown | The i18next logger instance. | |
| modules | I18nModules | Loaded plugin modules. | |
| observers | unknown | The registered event observers. | |
| options | InitOptions | The resolved initialization options. | |
| resolvedLanguage? | string | The resolved language, if available. | |
| services | Services | The services container. | |
| store | ResourceStore | The resource store. | |
| t | TFunction | The translation function. | |
| translator | unknown | The i18next translator instance. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addResource(lng, ns, key, value, options?) | I18n | Adds a single resource entry. | |
| addResourceBundle(lng, ns, resources, deep?, overwrite?) | I18n | Adds a resource bundle. | |
| addResources(lng, ns, resources) | I18n | Adds multiple resource entries. | |
| changeLanguage(lng?, callback?) | Promise<TFunction> | Changes the active language. | |
| cloneInstance(options?, callback?) | I18n | Creates a new i18next instance. | |
| createInstance(options?, callback?) | I18n | Creates a new i18next instance. | |
| dir(lng?) | 'ltr' | 'rtl' | Returns the text direction for a language. | |
| emit(event, args?) | void | Emits an event. | |
| exists(key, options?) | boolean | Checks whether a translation key exists. | |
| format(value, format?, lng?, options?) | string | Formats a value. | |
| getDataByLanguage(lng) | Record<string, Record<string, string>> | undefined | Gets all resource data for a language. | |
| getFixedT(lng, ns?) | TFunction | Gets a translation function fixed to a language and namespace. | |
| getResource(lng, ns, key, options?) | unknown | Gets a single resource value. | |
| getResourceBundle(lng, ns) | Record<string, unknown> | Gets a resource bundle for a language and namespace. | |
| hasLoadedNamespace(ns, options?) | boolean | Checks whether a namespace has been loaded. | |
| hasResourceBundle(lng, ns) | boolean | Checks whether a resource bundle exists. | |
| init(options?, callback?) | Promise<TFunction> | Initializes the i18next instance. | |
| loadLanguages(lngs, callback?) | Promise<void> | Loads additional languages. | |
| loadNamespaces(ns, callback?) | Promise<void> | Loads additional namespaces. | |
| loadResources(callback?) | void | Loads resources using the configured backend. | |
| off(event, listener?) | void | Removes a listener for an event. | |
| on(event, listener) | void | Registers a listener for an event. | |
| reloadResources(lngs?, ns?, callback?) | Promise<void> | Reloads resources for the given languages and namespaces. | |
| removeResourceBundle(lng, ns) | I18n | Removes a resource bundle. | |
| setDefaultNamespace(ns) | void | Sets the default namespace. | |
| use(module) | this | Registers a plugin module. |
Links to this page: