mashpie / i18n-node

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
3.09k stars 421 forks source link

passing a zero number value (0) incorrectly returns the full json string, brackets and all, without injecting the replacement value #497

Closed mikeyamato closed 2 years ago

mikeyamato commented 2 years ago

Whenever I try passing a zero (0) number value what returns is the original JSON string with brackets and the key name. Any other number value that gets passed is injected correctly.

// JSON
{
  "greatJobPracticedWords": "Great job! You practiced {{number}} of your saved words today.",
}

when passing a zero number value, i18next.t('greatJobPracticedWords', { number: 0 });, I get the following: Screen Shot 2022-05-20 at 10 25 28

All other number values passed, i18next.t('greatJobPracticedWords', { number: 1 });, I get the following: Screen Shot 2022-05-20 at 10 26 18

mashpie commented 2 years ago

better ask @adrai over at https://github.com/i18next/i18next ;)

adrai commented 2 years ago

@mikeyamato seems to work: https://codesandbox.io/s/react-i18next-http-example-forked-ui9p6j?file=/src/app.js:838-895

image
mikeyamato commented 2 years ago

Thanks for confirming. I'm going to be extremely embarrassed if this turns out to be a local setting (inherited project).