Update readme

This commit is contained in:
Kim Biesbjerg 2019-09-17 08:25:47 +02:00
parent a72dbf0494
commit 096fc79a9b

View File

@ -2,13 +2,11 @@ If this tool saves you time, please consider making a donation towards the conti
[![Donate](images/donate-badge.png)](https://donate.biesbjerg.com)
# Usage
## ngx-translate-extract
# 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
Install the package in your project:
`npm install @biesbjerg/ngx-translate-extract --save-dev`
@ -23,7 +21,7 @@ Add a script to your project's `package.json`:
```
You can now run `npm run extract-i18n` and it will extract strings from your project.
### Examples
## Usage
**Extract from dir and save to file**
@ -51,8 +49,8 @@ If you want to use spaces instead, you can do the following:
`ngx-translate-extract --input ./src --output ./src/i18n/en.json --format-indentation ' '`
## Mark strings for extraction using a marker function
If, for some reason, you want to extract strings not passed directly to `TranslateService`'s `get()` or `instant()` methods, you can wrap them in a marker function to let `ngx-translate-extract` know you want to extract them.
### Marker function
If you want to extract strings that are not passed directly to `TranslateService`'s `get()`/`instant()`/`stream()` methods, you can wrap them in a marker function to let `ngx-translate-extract` know you want to extract them.
Install marker function:
`npm install @biesbjerg/ngx-translate-extract-marker`
@ -63,10 +61,6 @@ import { marker } from '@biesbjerg/ngx-translate-extract-marker';
marker('Extract me');
```
Add the `marker` argument when running the extract script:
`ngx-translate-extract ... -m extract`
You can alias the marker function if needed:
```ts
@ -75,9 +69,9 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
_('Extract me');
```
`ngx-translate-extract ... -m _`
_Note: `ngx-translate-extract` will automatically detect the import name_
## Commandline arguments
### Commandline arguments
```
Usage:
ngx-translate-extract [options]