Search code examples
localizationtranslationi18nextreact-i18next

Can you use a key containing a dot (".") in i18next interpolation?


Is it possible to interpolate with a key containing a "." in i18n?

i.e. get this to work:

{
    "key": "Hi {{first.name}}"
}

i18next.t('key', { "first.name": 'Jane'});
// -> "Hi Jane"

Solution

  • No, dot in a property name for interpolation is used as json dot notation. So if you want to keep "Hi {{first.name}}" in your translations, you need to pass in the t options like this: i18next.t('keyk', { first: { name: 'Jane' } })