Essentials
Accessing keys
resources with 2 keys:
sample
Passing a default value
You can pass in a default value for cases the key could not be found in translations like:
Accessing keys in different namespaces
Namespaces are a feature in i18next internationalization framework which allows you to separate translations that get loaded into multiple files.
init
moduleA.json
common.json
sample
Multiple fallback keys
Calling the t function with an array of keys enables you to translate dynamic keys providing a non specific fallback value.
As a sample think of an error code you get and you like to show a specific warning in some cases:
keys
sample
Overview options
i18next.t(key, options)
option
description
defaultValue
count
context
replace
lng
override language to use
lngs
override languages to use
fallbackLng
ns
override namespaces (string or array)
keySeparator
override char to separate keys
nsSeparator
override char to split namespace from key
returnObjects
accessing an object not a translation string (can be set globally too)
returnDetails
returns an object that includes information about the used language, namespace, key and value
joinArrays
char, eg. '\n' that arrays will be joined by (can be set globally too)
postProcess
interpolation
skipInterpolation
skip interpolation and nesting for this call to t function
ignoreJSONStructure
if a key is not found as nested key, it will try to lookup as flat key
Last updated