ngx-translate-extract: Problems extracting and saving to multiple files

Hi biesbjerg!

I’m trying to extract and save to multiple files with the following code:

"extract": "ngx-translate-extract --input ./src/app/ --output ./src/assets/i18n/{en,es,fr}.json --clean --sort --format namespaced-json"

And also tried:

"extract": "ngx-translate-extract --input ./src/app/ --output ./src/assets/i18n/en.json ./src/assets/i18n/es.json ./src/assets/i18n/fr.json --clean --sort --format namespaced-json"

But doesn’t work.

With a single file like ’ ./src/assets/i18n/en.json’ works, but not for multiple Any idea what it might be? I’m using npm 3.10

Many thanks in advance! Greetings

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

I use ubuntu and encounter this problem.

I solve the problem by changing shell in npm or yarn script using the following command

$ npm config set script-shell /bin/bash

// or yarn
$ yarn config set script-shell /bin/bash

and npm run extract now expand glob pattern and save output files correctly.

Hope this help

A good thought. 👍 It is not exactly correct, but pushed me into the right direction. What works is

"scripts": {
    "extract": "ngx-translate-extract -i ./src -o ./src/i18n/en.json --clean --sort --format namespaced-json --format-indentation=\"  \""
}

In the above example I inserted two spaces and that’s exactly what came out in the json file. For getting tabs into the json the call should be:

"scripts": {
    "extract": "ngx-translate-extract -i ./src -o ./src/i18n/en.json --clean --sort --format namespaced-json --format-indentation=\"\t\""
}

And if you want it really crazy, simply mix tabs and spaces:

"scripts": {
    "extract": "ngx-translate-extract -i ./src -o ./src/i18n/en.json --clean --sort --format namespaced-json --format-indentation=\"  \t  \""
}