README
If you like this project please show your support with a GitHub star. Much appreciated!
ngx-translate-extract
Extract translatable (ngx-translate) strings and save as a JSON or Gettext pot file. Merges with existing strings if the output file already exists.
Usage
Install the package in your project:
npm install @sebastianzillessen/ngx-translate-extract --save-dev
Add an extract
script to your project's package.json
:
"scripts": {
"extract": "ngx-translate-extract --input ./src --output ./src/assets/i18n/ --sort --format namespaced-json"
}
You can now run npm run extract
to extract strings.
Extract examples
Extract from dir and save to file
ngx-translate-extract -i ./src -o ./src/i18n/strings.json
Extract from multiple dirs
ngx-translate-extract -i ./src/folder-a ./src/folder-b -o ./src/i18n/strings.json
Extract and save to multiple files
ngx-translate-extract -i ./src -o ./src/i18n/{da,en,fr}.json
or
ngx-translate-extract -i ./src -o ./src/i18n/da.json ./src/i18n/en.json ./src/i18n/fr.json
or (update only)
ngx-translate-extract -i ./src -o ./src/i18n/*.json
or (update only)
Custom indentation
By default, tabs are used for indentation when writing extracted strings to json formats:
ngx-translate-extract -i ./src -o ./src/i18n/en.json --format-indentation