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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot parse the keys from all my specified project files #502

Closed
hippolyte42 opened this issue Jan 3, 2022 · 9 comments
Closed

cannot parse the keys from all my specified project files #502

hippolyte42 opened this issue Jan 3, 2022 · 9 comments
Labels

Comments

@hippolyte42
Copy link

hippolyte42 commented Jan 3, 2022

馃悰 Bug Report

Can not manage to retrieve all my keys and write them in my output files, it is currently missing every keys called in my components/**/*.{ts,tsx}, the other keys are well retrieved as wanted

To Reproduce

my config file is set with input as below

// Paste your code here
input: "./!(node_modules)/**/*.{ts,tsx}",

Expected behavior

parse all my specified files and add the new found keys in my output: "public/locales/$LOCALE/$NAMESPACE.json" file.

Your Environment

  • runtime version: node v14.17.4
  • i18next version: 5.3.0
  • os: Windows 10
@joepsyko
Copy link

I have a similar problem, after updating to version 5.x.x it doesn't extract translation correctly

@karellm
Copy link
Member

karellm commented Mar 13, 2022

@buyhighHippo Can you provide a reproduceable example?

@glekner
Copy link

glekner commented Apr 6, 2022

@karellm we have the same issue in our repo https://github.com/kubevirt-ui/kubevirt-plugin
if you check https://github.com/kubevirt-ui/kubevirt-plugin/blob/main/locales/en/plugin__kubevirt-plugin.json
you will see only 216 keys, for some reason the parser does not parse files inside src/utils/**

we have a script for parsing: https://github.com/kubevirt-ui/kubevirt-plugin/blob/main/package.json#L12

can you please help?

@tradingstratagem
Copy link

I found the problem, I had this in my source code:
label: t(''),
After removing it, the parser works perfectly

@upalatucci
Copy link

I can confirm! Also in our repo https://github.com/kubevirt-ui/kubevirt-plugin

@alk-mandrianarijaona
Copy link

I have just checked our project, I also found a t(''), this must be the root cause. I will remove that. Thanks @tradingstratagem @upalatucci

@alk-sdavid
Copy link

alk-sdavid commented Apr 28, 2022

Hi 馃憢 indeed empty keys are resetting the namespace catalog here:

if (!key) {
target[entry.namespace] = {}
return { target, duplicate, conflict }
}
I'm not sure to understand the logic here 馃 Is it really intended?
t('') can mess up all translations from a project, and there is another use case I found in our codebase:

i18n.t("some key: {{key}}", { key: someVar })

It extracts an empty key too. After removing all the empty keys, it seems to work just fine, but this behavior looks quite dangerous 馃槄 what do you think?

@karellm karellm added the Bug label Apr 29, 2022
@karellm
Copy link
Member

karellm commented Apr 29, 2022

Thanks for finding the issue @alk-sdavid. I've pushed a patch as 6.4.0

@alk-sdavid
Copy link

thanks @karellm it seems to work as expected now 馃憤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants