i18next / i18next-parser

Parse your code to extract translation keys/values and manage your catalog files
MIT License
486 stars 198 forks source link

Make output directory relative to the config file #1043

Open comp615 opened 3 months ago

comp615 commented 3 months ago

🚀 Feature Proposal

output directory should be relative to the config file (when used) just like input is.

Motivation

I'm evaluating using this tool in a large monorepo where we would ideally extract i18n tags for each project independently, and due to how we need our files to work in git, it would co-locate the i18n files.

Currently, I was imagining putting a i18next-parser.config.js at each package root, and in CI having it just run each of those against the ci.

It makes sense that input is local to the config, as this allows each package to specify it's processed files. But they lose control over where their files go currently. In my singular CI setup, either the CI tool would need to put them all in one place, or it'd have to figure out the dir for each config and manually set the output path.

I think there are two different styles:

As a bonus, we could maintain functionality for both use cases (and enable more flexible usage) by adding a $CWD variable too. Config files could specify this to namespace themselves relative to where the script was run too.

Example

output: '$CWD/locales/myspecialpackage/$LOCALE/$NAMESPACE.json'