On this page
Configuration options
Every option `init()` and `createInstance()` take, grouped by what it controls, with its default.
i18next.init(options, callback)
Returns a Promise; use it (await or .then()). The callback is the older way (Older ways).
The same options go to createInstance().
Languages
lng(default none): the language to use; it overrides the language detector.'cimode'returns the key instead of the text. Use codes likeen-US(FAQ).fallbackLng(defaultfalse): the language to use when a text is missing, usually the one your app is written in;falseloads no fallback language (Fallback).supportedLngs(defaultfalse): the languages allowed; others are not loaded.nonExplicitSupportedLngs(defaultfalse): counts a variant as supported when its language is (en-USwhenenis insupportedLngs); with a backend such as i18next-http-backend it can cause request errors.load(default'all'): which codes to look up foren-USwithfallbackLng: 'dev':'all'givesen-US,en,dev;'currentOnly'givesen-US;'languageOnly'givesen.preload(defaultfalse): languages to load on init, for example on a server before it renders.lowerCaseLng(defaultfalse): lowercases the whole code (en-USbecomesen-us).cleanCode(default none, deprecated): codes without a region get their canonical casing (ENbecomesen);falsekeeps them as they are.appendNamespaceToCIMode(defaultfalse): withlng: 'cimode', puts the namespace in front of the returned key.detection(default none): the options of the language detector (plugins and utils).
Namespaces
ns(default'translation'): the namespace, or namespaces, to load;[]loads none on init (Namespaces).defaultNS(default'translation'): the namespacet()uses when none is given; withnsset and nodefaultNS, the first ofns.falseor[]turns the default namespace off.fallbackNS(defaultfalse): namespaces to look in when a key is missing in the current one (Fallback).
Loading translations
resources(default none): the translations to start with, when no backend loads them (Add or load translations).partialBundledLanguages(defaultfalse): some translations inresources, the rest through the backend.backend(default none): the options of the backend (plugins and utils).cache(default none): the options of a cache layer in a backend (Cache and fallback).initAsync(defaulttrue): loads ininit()after asetTimeout.falseloads at once, which only works with a backend that loads synchronously, such as i18next-fs-backend; thent()works right afterinit():
javascript
import i18next from 'i18next';
import Backend from 'i18next-fs-backend';
i18next.use(Backend).init({ initAsync: false });
i18next.t('key'); // -> the value
maxParallelReads(default10): at most this many backend reads at a time, so loading many files does not open thousands of sockets or file descriptors (EMFILE); usually faster, too.maxRetries(default5) andretryTimeout(default350ms, doubled on each retry): how often and after how long a failed read is tried again.
Keys
keySeparator(default'.'): the character between the levels of a nested key;falsefor flat keys.nsSeparator(default':'): the character between namespace and key;falseturns namespace prefixes off.pluralSeparator(default'_'): the character before the plural suffix.contextSeparator(default'_'): the character before the context suffix.ignoreJSONStructure(defaulttrue): looks a key that is not found as a nested key up as a flat key.enableSelector(defaultfalse):t()takes a selector function;'optimize'for very large resources,'strict'for a namespace in every path (Selector API, Typed keys).
Translation defaults
What t() does for every call unless the call says otherwise (t options).
postProcess(defaultfalse): the post processors to apply (Plugins).postProcessPassResolved(defaultfalse): passes the resolved details to the post processors asoptions.i18nResolved.returnNull(defaultfalse): anullvalue counts as a translation.returnEmptyString(defaultfalse): an empty string counts as a translation; withfalseit falls back like a missing value, while an explicit''default value from code still counts.returnObjects(defaultfalse): returns objects and arrays (Objects and arrays).returnDetails(defaultfalse): returns the language, namespace, key and value used, instead of the text.returnedObjectHandler(default none):function(key, value, options), called when a key holds an object butreturnObjectsis off.joinArrays(defaultfalse): joins an array into one text with this separator, for example', '.overloadTranslationOptionHandler(default: a second string argument becomesdefaultValue): turns the extra arguments oft()into options.interpolation: the interpolation options (All interpolation options).
Formats
cacheInBuiltFormats(defaulttrue): caches the built-in formatters (Formatting);falseif you run into this issue.i18nFormat(default none): the options of an i18n format plugin such as i18next-icu (Using ICU or MF2).
Missing keys
What happens when a key or a value is missing. New keys get into your files with i18next-cli extract; saving them at run time is under Older ways.
parseMissingKeyHandler(default none):function(key, defaultValue, options), returns what to show for a missing key.appendNamespaceToMissingKey(defaultfalse): puts the namespace in front of a missing key.missingInterpolationHandler(default none):function(text, value), called when a value for a placeholder isundefined(not for an empty string ornull); returns the text to use.
Logging
debug(defaultfalse): logs to the console, for example why loading did not work.
React
react: the options of react-i18next (React options).
Older ways
Saving missing keys
i18next-cli extract writes new keys from your code into the translation files before the app runs. With saveMissing: true, i18next instead sends the keys it does not find to the backend's create function while the app runs.
saveMissing(defaultfalse): sends missing keys to the backend (only backends withcreate, such as i18next-fs-backend and i18next-http-backend).updateMissing(defaultfalse): also sends a key whosedefaultValuediffers from its translation; useful only while the code is the source of the texts.saveMissingTo(default'fallback'): the language to save to: the fallback language,'current'(the language in use) or'all'(every language ini18next.languages).saveMissingPlurals(defaulttrue): saves every plural form, not only the singular, whent()was called withcount.missingKeyHandler(defaultfalse):function(lngs, ns, key, fallbackValue, updateMissing, options), your own handling of a missing key; needssaveMissing: true. Its arguments:lngs: the languages to save to, bysaveMissingTo.ns: the namespace.key: the key, with its plural suffix whensaveMissingPluralssaves each form.fallbackValue: the default value from the code (per plural formdefaultValue_<form>), otherwise the key;undefinedwithmissingKeyNoValueFallbackToKey.updateMissing:truewhen the key exists but itsdefaultValuediffers andupdateMissingis on.options: the options of thet()call.
missingKeyNoValueFallbackToKey(defaultfalse): does not use the key as the value of a saved missing key (with i18next-http-backend the key gets an empty value).
Disable saveMissing in production.