jsverse / transloco-keys-manager

🦄 The Key to a Better Translation Experience

Home Page:https://github.com/jsverse/transloco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support in detective for including "Extra Keys" with --add-missing-keys

micaminoff opened this issue · comments

Is your feature request related to a problem? Please describe.

I'm changing the i18n implementation of a fairly large app and transloco has been great so far. I only have a slight issue with translation generation for dynamic keys.

The number of dynamic translations required is pretty big, and adding explicit comments with every key to the templates is rough. However, one of my translation files already has a bunch of the missing keys missing from other files.

e.g.

File Name Missing Keys Extra Keys
en -- static, ok, error, ...
de -- --

Describe the solution you'd like

I'd like to propose another flag --merge-extra-keys (or something) to be used in conjunction with --add-missing-keys. This flag would cause the detective to add the so-called "extra keys" to i18n files where they are missing.

Alternatively we could have an --add-extra-keys flag to use instead of the two above together.

Before:

File Name Missing Keys Extra Keys
en -- static, ok, error, ...
de -- --

After:

File Name Missing Keys Extra Keys
en -- static, ok, error, ...
de -- static, ok, error, ...

Describe alternatives you've considered

A small script to identify keys present in one file and missing in another one and updating the lacking file is pretty trivial, but I'd rather the library itself supported this.

Current behavior

"Extra" keys present in one file aren't added to one that doesn't have them.

Expected behavior

When using --add-missing-keys and also --merge-extra-keys "extra" keys should be added to files where they don't exist

Additional context

Copy-pasting is boring

Contribution

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