Extract translatable (using ngx-translate) strings and save as a JSON or Gettext pot file
Go to file
2017-03-21 15:59:18 +01:00
bin Rename cli script filename. Rename option 'dir' to 'input' 2017-03-20 15:51:38 +01:00
src Update cli option descriptions. Change default filename to strings.format 2017-03-21 15:59:03 +01:00
tests Rename Test class for ServiceParser 2017-03-20 15:32:49 +01:00
.gitignore Include tslint.json 2016-12-07 15:27:48 +01:00
package.json - Added typings for packages where typings existed 2017-03-20 15:29:41 +01:00
README.md Update README 2017-03-21 15:59:18 +01:00
tsconfig.json Transpile to es5 to support older node versions 2016-12-20 15:17:37 +01:00
tslint.json Add experimental AstServiceParser 2017-01-28 15:22:08 +01:00

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 @biesbjerg/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/*.json --clean --sort --format namespaced-json"
}

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.

Commandline arguments

Usage:
ngx-translate-extract [options]

Options:
  --version, -v   Show version number                                  [boolean]
  --help, -h      Show help                                            [boolean]
  --input, -i     Paths you would like to extract strings from. You can use path
                  expansion, glob patterns and multiple paths
                     [array] [default: "/Users/kim/ionic/ngx-translate-extract"]
  --patterns, -p  Extract strings from the following file patterns
                                    [array] [default: ["/**/*.html","/**/*.ts"]]
  --output, -o    Paths where you would like to save extracted strings. You can
                  use path expansion, glob patterns and multiple paths
                                                              [array] [required]
  --format, -f    Output format
          [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]