ngx-translate-extract/README.md

38 lines
1.4 KiB
Markdown
Raw Normal View History

2016-12-03 17:09:39 +03:00
# ng2-translate-extract
2016-12-20 18:02:56 +03:00
Extract translatable (ng2-translate) strings and save as a JSON or Gettext pot file.
Merges with existing strings if the output file already exists.
2016-12-03 17:09:39 +03:00
2016-12-05 01:14:00 +03:00
## Usage
2016-12-20 18:02:56 +03:00
Install the package in your project:
2016-12-03 17:09:39 +03:00
2016-12-05 01:22:00 +03:00
`npm install @biesbjerg/ng2-translate-extract --save-dev`
2016-12-05 01:14:00 +03:00
2016-12-20 18:02:56 +03:00
Add an `extract` script to your project's `package.json`:
2016-12-05 01:14:00 +03:00
```
"scripts": {
2016-12-20 18:02:56 +03:00
"extract": "ng2-translate-extract --dir ./src --output ./ --format=json --clean"
2016-12-05 01:14:00 +03: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-05 01:22:00 +03:00
Modify the scripts arguments as required.
2016-12-05 01:14:00 +03:00
## Commandline arguments
```
Usage:
ng2-translate-extract [OPTIONS] [ARGS]
Options:
-d, --dir [DIR] Directory path you would like to extract strings from (Default is current directory)
2016-12-05 01:14:00 +03:00
-o, --output [DIR] Directory path you would like to save extracted
2017-01-13 08:09:43 +03:00
strings (Default is current directory/template.json)
2017-01-13 11:02:01 +03:00
-f, --format [VALUE] Output format. VALUE must be either
[json|namespaced-json|pot] (Default is json)
2016-12-10 03:59:25 +03:00
-r, --replace BOOLEAN Replace the contents of output file if it exists
2016-12-20 18:02:56 +03:00
(Merges by default)
2017-01-13 08:09:43 +03:00
-s, --sort BOOLEAN Sort translations in the output file in alphabetical
order
2016-12-20 18:02:56 +03:00
-c, --clean BOOLEAN Remove obsolete strings when merging
-h, --help Display help and usage details
2016-12-05 01:14:00 +03:00
```