Nested path contains a colon

645 Views Asked by At

My JSON file is this:

{
   "errors": {
     "missing_permissions:can_trade": "lorem ipsum"
   }
}

I then try to access this translation with the following but none work:

t(`errors.missing_permissions:can_trade`)
t(`errors['missing_permissions:can_trade']`)

Anyway to access this?

1

There are 1 best solutions below

0
On BEST ANSWER

I18next has a special meaning for colon - indicates a namespace.

you can tell it to ignore the colon in the key by passing { nsSeparator: false }.

t('errors.missing_permissions:can_trade', {nsSeparator: false});