2017-01-28 15:32:16 +01:00
If you like this project please show your support with a GitHub star. Much appreciated!
2017-03-07 15:56:26 +01:00
# ngx-translate-extract
Extract translatable (ngx-translate) strings and save as a JSON or Gettext pot file.
2016-12-20 16:02:56 +01:00
Merges with existing strings if the output file already exists.
2016-12-03 15:09:39 +01:00
2016-12-04 23:14:00 +01:00
## Usage
2016-12-20 16:02:56 +01:00
Install the package in your project:
2016-12-03 15:09:39 +01:00
2017-03-07 15:56:26 +01:00
`npm install @biesbjerg/ngx-translate-extract --save-dev`
2016-12-04 23:14:00 +01:00
2016-12-20 16:02:56 +01:00
Add an `extract` script to your project's `package.json` :
2016-12-04 23:14:00 +01:00
```
"scripts": {
2017-03-07 15:56:26 +01:00
"extract": "ngx-translate-extract --dir ./src --output ./ --format=json --clean"
2016-12-04 23:14:00 +01:00
}
```
You can now run `npm run extract` to extract strings from your project's `src` dir. The extracted strings are saved in `JSON` -format in your project's root.
2016-12-04 23:22:00 +01:00
Modify the scripts arguments as required.
2016-12-04 23:14:00 +01:00
## Commandline arguments
```
Usage:
2017-03-07 15:56:26 +01:00
ngx-translate-extract [OPTIONS] [ARGS]
2016-12-04 23:14:00 +01:00
Options:
2016-12-09 19:29:48 +01:00
-d, --dir [DIR] Directory path you would like to extract strings from (Default is current directory)
2016-12-04 23:14:00 +01:00
-o, --output [DIR] Directory path you would like to save extracted
2017-01-13 06:09:43 +01:00
strings (Default is current directory/template.json)
2017-01-13 09:02:01 +01:00
-f, --format [VALUE] Output format. VALUE must be either
[json|namespaced-json|pot] (Default is json)
2016-12-10 01:59:25 +01:00
-r, --replace BOOLEAN Replace the contents of output file if it exists
2016-12-20 16:02:56 +01:00
(Merges by default)
2017-01-13 06:09:43 +01:00
-s, --sort BOOLEAN Sort translations in the output file in alphabetical
order
2016-12-20 16:02:56 +01:00
-c, --clean BOOLEAN Remove obsolete strings when merging
2017-01-28 15:32:16 +01:00
-e, --experimental BOOLEAN Use experimental AST Service Parser
2016-12-09 19:29:48 +01:00
-h, --help Display help and usage details
2016-12-04 23:14:00 +01:00
```