2016-12-03 17:09:39 +03:00
# ng2-translate-extract
Extract strings from projects using ng2-translate to json or pot files.
2016-12-05 01:14:00 +03:00
**THIS IS STILL VERY MUCH A WORK IN PROGRESS**
2016-12-03 17:09:39 +03:00
2016-12-05 01:14:00 +03:00
## Usage
If you only need to extract strings from one project, you can install the package locally:
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
Add the following `extract` script your project's `package.json` :
```
"scripts": {
"extract": "ng2-translate-extract --dir ./src --output ./ --format=json"
}
```
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
## Global install
You can also install the package globally:
2016-12-05 01:22:00 +03:00
`npm install @biesbjerg/ng2-translate-extract -g`
2016-12-05 01:14:00 +03:00
Now you can execute the script from everywhere:
2016-12-09 21:29:48 +03:00
`ng2-translate-extract --dir /extract/from/this/dir --output /save/to/this/dir --format json --merge --clean`
2016-12-05 01:14:00 +03:00
## Commandline arguments
```
Usage:
ng2-translate-extract [OPTIONS] [ARGS]
Options:
2016-12-09 21:29:48 +03:00
-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
2016-12-10 03:59:25 +03:00
strings (Default is current directory)
2016-12-05 01:14:00 +03:00
-f, --format [VALUE] Output format. VALUE must be either [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
(merging by default)
2016-12-09 21:29:48 +03:00
-c, --clean BOOLEAN Remove unused keys when merging
-h, --help Display help and usage details
2016-12-05 01:14:00 +03:00
```