-
Notifications
You must be signed in to change notification settings - Fork 21
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
Dynamic keys are incorrectly marked as unused #21
Comments
Hello. It's correct. i18n-unused is static analyze tool, it's mean, that code doesn't compiles, only read sources. |
Thanks. I understand that — I think what I was really wondering is whether there is a way to automatically exclude keys that match a dynamic pattern. For example auto-exclude keys containing I don't really want to have it mark all these keys as 'unused' and delete them, when doing so would actually break my app, because they are used. I know I'd then run the risk of having missing or unused keys within that scope, but it'd still be nice to have the option to auto-exclude dynamic keys from these reports, even accepting this risk 😄 |
Oh, ok. You can use option |
And if u use js output in your ci, u can ignore {
translations: [
{
filePath: 'src_file_path',
staticKeys: ['missed_key'], // keys without ${} syntax
dynamicKeys: ['missed_key'], // keys with ${} syntax
staticCount: 1,
dynamicCount: 1,
},
],
totalStaticCount: 1,
totalDynamicCount: 1,
} |
Auto-excluding for dynamic keys it's may be good feature. I'll make a note for future releases. |
Thanks 🙏 I knew I could manually exclude keys, didn't realise I could put a dynamic substring placeholder in there, that's useful. And yes, I've seen that the output of the missed keys gives a count of the dynamic keys it found, but it doesn't seem to find them for unused keys which is what I was looking for. I can do without for now — thanks for the help! |
Hi! I might be missing something, but I believe some keys are incorrectly reported as unused when they are in fact used as dynamic keys.
For example, in code I have some calls like this:
Running the CLI command
display-unused
will list keys like those below as being unused, even though they do get used by the code above, which will fill in the dynamic code with a value such aserrorClass
orid
.Is there a mechanism to automatically mark those as used? This library does seem to support dynamic keys when finding missing keys, but it only seems to be one-way.
The text was updated successfully, but these errors were encountered: