i18next / i18next-gitbook

165 stars 172 forks source link

Fallback parsing #168

Closed veronQ closed 3 years ago

veronQ commented 3 years ago

🐛 Bug Report

Fallback string with the : (colon) punctuation mark extracts only parts of it.

To Reproduce

Use the i18next.t(keys, options) function with an undefined key.

i18next.t('Undefined variable: $example')
// Output is: " $example"

Expected behavior

If the key is not defined in the translation file, it should return the string itself, as per the doc.

"Undefined variable: $example"

Your Environment

jamuhl commented 3 years ago

: is reserved as namespace separator -> https://www.i18next.com/translation-function/essentials#accessing-keys-in-different-namespaces

Either override nsSeparator or pass a real defaultValue like: i18next.t('Undefined variable: $example', 'Undefined variable: $example')