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

Find/Extract do not detect keys in .html files - in angular NX MonoRepo with Shared Root Transloco Config #81

Open
seadonk opened this issue Feb 8, 2021 · 6 comments

Comments

@seadonk
Copy link
Contributor

seadonk commented Feb 8, 2021

Current behavior

In our NX monorepo, we use a root transloco.config file for all apps/libraries, with the translations sitting at <project>/src/assets/i18n. Transloco-keys-manager FIND and EXTRACT methods do not detect any keys in the template (.html) files and will show them as extra keys.

Expected behavior

All keys in .html files for both libs and apps should be detected by the FIND and EXTRACT commands.

Steps To Reproduce

Here is an example based off your transloco-with-nx-libs repo.
https://github.com/seadonk/transloco-with-nx-libs

Screenshots

Behavior in an APP:
If you run transloco-keys-manager find --project transloco-holder, it will correctly identify the existing keys and also missing key and extra key.

$ transloco-keys-manager find --project transloco-holder

 � �  Staring Search For Missing Keys � �

√ Extracting Template and Component Keys �
√ Checking for missing keys ✨
√ Summary

┌───────────┬───────────────┬────────────┐
│ File Name │ Missing Keys  │ Extra Keys │
├───────────┼───────────────┼────────────┤
│ en        │ 'missing key' │ 'extraKey' │
├───────────┼───────────────┼────────────┤
│ es        │ 'missing key' │ --         │
└───────────┴───────────────┴────────────┘

Behavior in an LIB:
If you run yarn find --project transloco-lib-a, it will identify extra key, but not missing key, and it will incorrectly think that gps is an extra key because it does not see it in the template.

$ transloco-keys-manager find --project transloco-lib-a

 � �  Staring Search For Missing Keys � �

√ Extracting Template and Component Keys �
√ Checking for missing keys ✨
√ Summary

┌───────────┬──────────────┬────────────┐
│ File Name │ Missing Keys │ Extra Keys │
├───────────┼──────────────┼────────────┤
│ en        │ --           │ 'gps'      │
│           │              │ 'extraKey' │
├───────────┼──────────────┼────────────┤
│ es        │ --           │ 'gps'      │
└───────────┴──────────────┴────────────┘

Keys manager config

const availableLangs =['en', 'de', 'es', 'fr', 'it', 'hi', 'ja', 'zh', 'ar'];
module.exports = {
  langs: availableLangs,
  keysManager: {
    sort: true,
    output: 'assets/i18n', // used only for extract, relative path to the translations files from root
    translationFilesPath: 'assets/i18n', // relative path to the translations files from root
    defaultValue: 'Missing Translation: {{key}}',
    unflat: true
  }
};

Environment

- Keys manager version: 2.7.1
- Node version: 14.15.4
- Platform:  Windows

Debug logs

Additional context

Add any other context about the problem here.

Contribution

I would like to make a pull request for this feature:
[ ] Yes! 🚀
[ ] Maybe next time

@shaharkazaz
Copy link
Collaborator

@seadonk Can you please share a small reproduction? would you like to make a PR for it? 🙂

@seadonk
Copy link
Contributor Author

seadonk commented Oct 7, 2021

@shaharkazaz
I was actually just looking into this. It seems to be failing in some of our libraries. In some cases it seems to be a scoping issue, in others not. The https://github.com/seadonk/transloco-with-nx-libs repo should be the reproduction of the issue. If I can narrow it down I'll attempt a PR.

@seadonk
Copy link
Contributor Author

seadonk commented Oct 7, 2021

The find command is not picking up the template keys from the libraries, and thus shows "gps" as an Extra Key and does NOT show "missing key" as a Missing Key.

Here are the two commands:
image

image

I bet it is related to how I am using the TRANSLOCO_SCOPE

@jbchr
Copy link

jbchr commented Jan 10, 2022

I'm facing the same issue, did you find a solution @seadonk ?

@seadonk
Copy link
Contributor Author

seadonk commented Jan 10, 2022

@jbchr No, sorry. I haven't had time to look into it. If I get a chance I'll make a new minimal reproduction.

@shaharkazaz
Copy link
Collaborator

@jbchr You are welcome to give it a shoot as well 🙂

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

3 participants