Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

i18next json dot in key or label

Tags:

i18next

JS: i18n.t("SOME TEXT TO BE TRANSLATED.")

JSON: "SOME TEXT TO BE TRANSLATED.": "Een stukje tekst om te vertalen"

i18n.t("SOME TEXT TO BE TRANSLATED.") gives me "SOME TEXT TO BE TRANSLATED.".

If I remove the "." (dot) from the label and the function t, than the text is translated.

How to solve this?

like image 512
Sven Cornelis Avatar asked Nov 19 '14 11:11

Sven Cornelis


2 Answers

Documentation explains that dot is by default treated as a key separator. You can

  • replace dot with .
  • put dot outside translated string i18n.t("SOME TEXT TO BE TRANSLATED") + "."
  • change key separator

    You can change namespace and/or key separator by setting options on init:

    nsSeparator: ':::'
    keySeparator: '::'
    
like image 99
Peter Avatar answered Oct 21 '22 02:10

Peter


You can set "keySeparator" : false in your init option.

like image 43
Aditya Tomar Avatar answered Oct 21 '22 01:10

Aditya Tomar