i18next-parser icon indicating copy to clipboard operation
i18next-parser copied to clipboard

Export as 1 file

Open ngdangtu-vn opened this issue 5 years ago • 5 comments

🚀 Feature Proposal

I would like to export the translation as 1 language file with all the namespace in it.

Motivation

Not every project are big enough to necessarily make multiple files per a language.

Example

I think if the output only have one $LOCALE, the parser should export 1 file contains all the namespace and translation in it. If it have $LOCALE and $NAMESPACE, the parser will create many files.

ngdangtu-vn avatar Oct 12 '20 06:10 ngdangtu-vn

What is the issue with having multiple files? My assumption is that if the project is so small then it probably isn't changing much either.

karellm avatar Oct 13 '20 02:10 karellm

Some translation tools doesn't support multiple files :D (ex. POEditor)

ngdangtu-vn avatar Oct 13 '20 06:10 ngdangtu-vn

I'm not a fan of obscure configurations that trigger a behaviour like you suggested. That said you are welcome to open a PR with a configuration option name 'concatenateNamespaces` or something like that.

karellm avatar Oct 13 '20 18:10 karellm

I'm busy currently, but I would love to learn the source code and contribute it. (Kinda busy in this month, maybe next month? Does it sound good? 😁)

ngdangtu-vn avatar Oct 13 '20 19:10 ngdangtu-vn

You can do this now with the following sample config:

module.exports = {
  namespaceSeparator: false,
  output: "src/locales/$LOCALE/translations.json"
};

mattrigg9 avatar Sep 23 '21 21:09 mattrigg9