i18next-parser icon indicating copy to clipboard operation
i18next-parser copied to clipboard

useKeysAsDefaultValue broken for Trans component

Open amandapouget opened this issue 3 years ago • 2 comments

🐛 Bug Report

When using Trans, default value is populated rather than left as empty string. useDefaultValueAsKeys should result in empty string.

To Reproduce

A codesandbox example or similar or at least steps to reproduce the behavior:

<Trans count={count}>
  <div>{'{{ count, INTEGER }}'}</div>
</Trans>

...
useKeysAsDefaultValue: false

Expected behavior

Should generate this:

"<0>{{ count, INTEGER }}</0>_one": "",
"<0>{{ count, INTEGER }}</0>_other": "",

But generates:

"<0>{{ count, INTEGER }}</0>_one": "<0>{{ count, INTEGER }}</0>",
"<0>{{ count, INTEGER }}</0>_other": "<0>{{ count, INTEGER }}</0>",

Your Environment

  • runtime version: node 14.17.3
  • i18next version: 21.5.4, react-i18next: 11.14.3, i18next-parser: 5.3.0
  • os: Mac
  • any other relevant information

Will make a sandbox if the template link above is replaced with a link to a forkable sandbox that contains a Terminal rather a list of search results.

amandapouget avatar Dec 10 '21 23:12 amandapouget

Hi, I still face same behavior on version 8.9.0, what is the status of this ticket?

Fley avatar Dec 20 '23 13:12 Fley

@Fley I have extremely limited bandwidth to code this project. I will review PRs though. If you want this fixed, I invite you to make a PR

karellm avatar Dec 24 '23 15:12 karellm