ngx-translate-extract-marker/README.md

26 lines
751 B
Markdown
Raw Normal View History

2019-06-24 13:40:32 +03:00
## 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 custom marker function to let `ngx-translate-extract` know you want to extract them.
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
Install marker function:
`npm install @biesbjerg/ngx-translate-extract-marker`
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
```ts
import { extract } from '@biesbjerg/ngx-translate-extract-marker';
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
extract('Extract me');
```
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
Add the `marker` argument when running the extract script:
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
`ngx-translate-extract ... -m extract`
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
You can alias the marker function if needed:
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
```ts
import { extract as _ } from '@biesbjerg/ngx-translate-extract-marker';
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
_('Extract me');
```
2019-06-24 13:39:17 +03:00
2019-06-24 13:40:32 +03:00
`ngx-translate-extract ... -m _`