Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React component key is extracted instead of i18nKey #1038

Open
Shiwa opened this issue Aug 1, 2024 · 0 comments
Open

React component key is extracted instead of i18nKey #1038

Shiwa opened this issue Aug 1, 2024 · 0 comments

Comments

@Shiwa
Copy link

Shiwa commented Aug 1, 2024

🐛 Bug Report

When extracting translation from a Trans component with a react key prop, this key is used in place of the i18nKey.

To Reproduce

Running i18next-parser on the following tsx code

<SomeComponent
  texts={[
    <Trans ns="settings" key={0} i18nKey="my.i18n.key">
      <span className="font-bold">Lorem Ipsum…</span> 
    </Trans>,
  ]}
/>

Expected behavior

The etracted key should be my.i18n.key but is instead {0}

{
  "{0}": "<0>Lorem Ipsum…</0> "
}

Your Environment

  • runtime version: node 20, pnpm
  • i18next version: 23.6.0 ; react-i18next: 13.3.1 ; i18next-parser: 8.13.0
  • os: Linux
  • I tried quickly with i18next-parser 9.0.1 and by customizing the JsxLexer, but got the same result. Changing the prop order of key / i18nKey did not fix the problem either, key is always used in place of i18nKey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant