Update README

This commit is contained in:
Kim Biesbjerg
2017-03-21 15:59:18 +01:00
parent 7b10b246e6
commit 7654397bb3

View File

@@ -12,29 +12,56 @@ Install the package in your project:
Add an `extract` script to your project's `package.json`: Add an `extract` script to your project's `package.json`:
``` ```
"scripts": { "scripts": {
"extract": "ngx-translate-extract --dir ./src --output ./ --format=json --clean" "extract": "ngx-translate-extract --input ./src --output ./src/assets/i18n/*.json --clean --sort --format namespaced-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. You can now run `npm run extract` to extract strings.
## Commandline 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`
Modify the scripts arguments as required. Modify the scripts arguments as required.
## Commandline arguments ## Commandline arguments
``` ```
Usage: Usage:
ngx-translate-extract [OPTIONS] [ARGS] ngx-translate-extract [options]
Options: Options:
-d, --dir [DIR] Directory path you would like to extract strings from (Default is current directory) --version, -v Show version number [boolean]
-o, --output [DIR] Directory path you would like to save extracted --help, -h Show help [boolean]
strings (Default is current directory/template.json) --input, -i Paths you would like to extract strings from. You can use path
-f, --format [VALUE] Output format. VALUE must be either expansion, glob patterns and multiple paths
[json|namespaced-json|pot] (Default is json) [array] [default: "/Users/kim/ionic/ngx-translate-extract"]
-r, --replace BOOLEAN Replace the contents of output file if it exists --patterns, -p Extract strings from the following file patterns
(Merges by default) [array] [default: ["/**/*.html","/**/*.ts"]]
-s, --sort BOOLEAN Sort translations in the output file in alphabetical --output, -o Paths where you would like to save extracted strings. You can
order use path expansion, glob patterns and multiple paths
-c, --clean BOOLEAN Remove obsolete strings when merging [array] [required]
-e, --experimental BOOLEAN Use experimental AST Service Parser --format, -f Output format
-h, --help Display help and usage details [string] [choices: "json", "namespaced-json", "pot"] [default: "json"]
``` --replace, -r Replace the contents of output file if it exists (Merges by
default) [boolean] [default: false]
--sort, -s Sort strings in alphabetical order when saving
[boolean] [default: false]
--clean, -c Remove obsolete strings when merging[boolean] [default: false]