-
-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Is there an existing issue for this?
- I have searched the existing issues
Is this a regression?
No
Current behavior
Angular allows for the use of factory providers, which represents a function that returns a specific token. These function can have other providers as arguments which get provided via the deps property of the factory provider.
When TranslocoService is provided as such argument and the translate function is invoked with a key, the translation manager do not find this key. This does also happen when the translation key is a static string. Additionally, it does not matter whether the TranslocoPipe or the TranslocoService is used in the same component.
Expected behavior
As a developer I expect the transloco key manager to find keys that are defined in factory providers.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/transloco-missing-key-detection-factory-provider?file=src%2Fmain.ts
Transloco Config
This should not be relevant, but can be seen in the debug log.Debug Logs
Note
It is true that the key APP_NAME_INLINE is also missing in the configuration, but it serves as a verification that the tool is working in the targeted component.
The key I expect to show up is APP_NAME_FROM_FACTORY.
<details>
<summary>Log</summary>
🐞 DEBUG - Config:
Default: {
input: [ 'src/app' ],
output: 'src/assets/i18n',
langs: [ 'en' ],
marker: 't',
sort: false,
defaultValue: undefined,
replace: false,
removeExtraKeys: false,
addMissingKeys: false,
emitErrorOnExtraKeys: false,
translationsPath: 'src/assets/i18n',
fileFormat: 'json'
} +0ms
Transloco file: {
translationsPath: 'src/assets/i18n/',
langs: [ 'en', 'de' ],
input: [ 'src' ]
} +3ms
Inline: { command: 'find' } +0ms
Merged: {
input: [ 'src' ],
output: 'src/assets/i18n',
langs: [ 'en', 'de' ],
marker: 't',
sort: false,
defaultValue: undefined,
replace: false,
removeExtraKeys: false,
addMissingKeys: false,
emitErrorOnExtraKeys: false,
translationsPath: 'src/assets/i18n/',
fileFormat: 'json',
command: 'find'
} +0ms
🐞 DEBUG - Configuration Paths:
Input: [ '/home/projects/stackblitz-starters-2l82hu/src' ] +0ms
Output: '/home/projects/stackblitz-starters-2l82hu/src/assets/i18n' +0ms
Translations: '/home/projects/stackblitz-starters-2l82hu/src/assets/i18n' +0ms
🐞 DEBUG - Scopes:
Scopes map: {} +0ms
🕵 🔎 Starting Search For Missing Keys 🔍 🕵
⠋ Extracting Template and Component Keys
🐞 DEBUG - Extracting keys:
file: '/home/projects/stackblitz-starters-2l82hu/src/index.html' +0ms
fileType: 'html' +0ms
🐞 DEBUG - Extracting keys:
file: '/home/projects/stackblitz-starters-2l82hu/src/transloco-loader.ts' +0ms
fileType: 'ts' +0ms
🐞 DEBUG - Extracting keys:
file: '/home/projects/stackblitz-starters-2l82hu/src/main.ts' +0ms
fileType: 'ts' +0ms
✔ Extracting Template and Component Keys 🗝
✔ Checking for missing keys ✨
✔ Summary
┌───────────┬───────────────────┬────────────┐
│ File Name │ Missing Keys │ Extra Keys │
├───────────┼───────────────────┼────────────┤
│ en │ 'APP_NAME_INLINE' │ -- │
├───────────┼───────────────────┼────────────┤
│ de │ 'APP_NAME_INLINE' │ -- │
└───────────┴───────────────────┴────────────┘
Please provide the environment you discovered this bug in
#### System:
OS: Linux 5.0 undefined
CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
#### Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
#### npmPackages:
@jsverse/transloco: ^7.5.0 => 7.5.0
@jsverse/transloco-keys-manager: ^5.1.0 => 5.1.0
@angular/*: ^18.1.0 => 18.2.7Additional context
I can provide a PR pull likely need guidance since I'm unfamiliar with the projects internal code base.
I would like to make a pull request for this bug
Yes 🚀