Nesting
Nesting allows you to reference other keys in a translation. Could be useful to build glossary terms.
Basic
keys
sample
You can reference keys from other namespaces by prepending the namespace: "nesting1": "1 $t(common:nesting2)",
Passing options to nestings
You can pass entire data models in options.
keys
sample
Make sure the options string is valid JSON and can be parsed using JSON.parse
'sampleKey': 'test $t(nest2, { "changedVarName": "{{var}}" })'
Passing nesting to interpolated
keys
sample
If you're using >= v21.0.0 you need to set skipOnVariables to false:
Additional options
Prefix/Suffix for nesting and other options can be overridden in init interpolation options or by passing additional options to t function:
sample
nestingPrefixEscaped
undefined
escaped prefix for nesting (regexSafe)
nestingSuffixEscaped
undefined
escaped suffix for nesting (regexSafe)
While there are a lot of options going with the defaults should get you covered.
Last updated