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

Keys that are only used on conditional translations are always treated as missing keys #146

Open
grackeon opened this issue Nov 16, 2022 · 3 comments

Comments

@grackeon
Copy link

grackeon commented Nov 16, 2022

Bug report

Describe the bug

If a translation key is only used in cases, where it depends on a condition if the key is used, the linting treats the key as missing.

ngx-translate-lint@1.11.0 works fine.
ngx-translate-lint@1.20.4 shows error that keys don't exist in project.

To Reproduce

Steps to reproduce the behavior:

  • Include a conditional translation key in a view, for example like: <div>{{(condition ? 'myKey1' : 'myKey2')|translate}}</div>
  • Add myKey1 and myKey2 to translation file.
  • Run ngx-translate-lint --keysOnViews disable -l <path-to-languages> -p <path-to-views>
  • Lint will fail with: Key: 'myKey1' doesn't exist in project' and Key: 'myKey2' doesn't exist in project'

Expected behavior

Keys that are used under certain conditions should not count as missing.

@itekaf
Copy link
Owner

itekaf commented Nov 16, 2022

Hi @Moritz1409

I think the main problem is on flag --deepSearch. In previous versions, logic (from ---deepSearch) was included in the main flow. But I created a separate flag, because that logic works slowly (on big projects). Right now this flag is disable by default.

Could you pls enable this flag and check result?

@grackeon
Copy link
Author

Yes, with --deepSearch enabled it works as before! Didn't know that the default behavior was changed.

Thanks for the quick response!

@itekaf
Copy link
Owner

itekaf commented Nov 17, 2022

Hi @Moritz1409 thanks for quick answer, :) I try to resolve your issue without this flag in the future.

Have a nice day

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

No branches or pull requests

2 participants