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

The function passed to parseTransFromString is called multiple times. #226

Open
gomo opened this issue Mar 17, 2022 · 0 comments
Open

The function passed to parseTransFromString is called multiple times. #226

gomo opened this issue Mar 17, 2022 · 0 comments

Comments

@gomo
Copy link

gomo commented Mar 17, 2022

🐛 Bug Report

The function passed to parseTransFromString is called multiple times with even though there is only one component.

To Reproduce

https://codesandbox.io/s/autumn-wildflower-81pqi4?file=/package.json

Create a terminal and run yarn i18next-scanner. You should see the following

sandbox@sse-sandbox-81pqi4:/sandbox$ yarn i18next-scanner
yarn run v1.22.17
warning package.json: No license field
$ i18next-scanner
some.key
some.key
some.key
Done in 0.21s.

The following code can also be reproduced.

      const jsx = '<Box><Box><Trans i18nKey="some.key">Default text</Trans></Box></Box>'

      parser.parseTransFromString(jsx, { component: 'Trans', i18nKey: 'i18nKey' }, function(key, options){
        console.log(key)
      });

Expected behavior

So there is only one Trans component, the console.log should output once.

sandbox@sse-sandbox-81pqi4:/sandbox$ yarn i18next-scanner
yarn run v1.22.17
warning package.json: No license field
$ i18next-scanner
some.key
Done in 0.21s.

Your Environment

  • node v16.13.1
  • i18next 21.6.14
  • i18next-scanner 3.1.0
  • os: Mac 12.2.1 (21D62) CPU M1
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