Skip to content

I18n

Unofficial

Main i18next instance interface.

Import:

import type { I18n } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface I18n

Properties

PropertyTypeDescription
isInitializedbooleanWhether the instance has been initialized.
isInitializingbooleanWhether the instance is currently initializing.
isLanguageChangingTo?stringThe language a change is currently in progress to, if any.
languagestringThe active language code.
languagesreadonly string[]The list of languages in fallback order.
loggerunknownThe i18next logger instance.
modulesI18nModulesLoaded plugin modules.
observersunknownThe registered event observers.
optionsInitOptionsThe resolved initialization options.
resolvedLanguage?stringThe resolved language, if available.
servicesServicesThe services container.
storeResourceStoreThe resource store.
tTFunctionThe translation function.
translatorunknownThe i18next translator instance.

Methods

MethodReturnsDescription
addResource(lng, ns, key, value, options?)I18nAdds a single resource entry.
addResourceBundle(lng, ns, resources, deep?, overwrite?)I18nAdds a resource bundle.
addResources(lng, ns, resources)I18nAdds multiple resource entries.
changeLanguage(lng?, callback?)Promise<TFunction>Changes the active language.
cloneInstance(options?, callback?)I18nCreates a new i18next instance.
createInstance(options?, callback?)I18nCreates a new i18next instance.
dir(lng?)'ltr' | 'rtl'Returns the text direction for a language.
emit(event, args?)voidEmits an event.
exists(key, options?)booleanChecks whether a translation key exists.
format(value, format?, lng?, options?)stringFormats a value.
getDataByLanguage(lng)Record<string, Record<string, string>> | undefinedGets all resource data for a language.
getFixedT(lng, ns?)TFunctionGets a translation function fixed to a language and namespace.
getResource(lng, ns, key, options?)unknownGets a single resource value.
getResourceBundle(lng, ns)Record<string, unknown>Gets a resource bundle for a language and namespace.
hasLoadedNamespace(ns, options?)booleanChecks whether a namespace has been loaded.
hasResourceBundle(lng, ns)booleanChecks 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?)voidLoads resources using the configured backend.
off(event, listener?)voidRemoves a listener for an event.
on(event, listener)voidRegisters a listener for an event.
reloadResources(lngs?, ns?, callback?)Promise<void>Reloads resources for the given languages and namespaces.
removeResourceBundle(lng, ns)I18nRemoves a resource bundle.
setDefaultNamespace(ns)voidSets the default namespace.
use(module)thisRegisters a plugin module.

Links to this page: