ng9-ts-extractor v1.0.2
ng9-ts-extractor
Angular 9 I18n Extractor from TypeScript files.
Install
npm install ng9-ts-extractor --saveWhat the package do
Angular 9 now supports code based localization via
$localize:`meaning|description@@id:message`And because there is no extractor until now for code based localization. You have to
- Add
idto every$localize. - Write
trans-unitfor everyid.
And That is what ng9-ts-extractor do for you. It adds a unique id for every $localize that doesn't have an id.
And add trans-unit for every $localize using its id.
Usage
There is an extraction tool called ts-extract that will extract the messages. You should first extract the messages from the templates using the ng-xi18n extraction tool from @angular/compiler-cli which will create an xliff or xmb file, and then run ts-extract on the same file to add the messages extracted from your code. The messages will be merged.
Example
ts-extract -i=src/**/*.ts -f=xlf -o=src/i18n/messages.xlfCommandline arguments
usage ts-extract options
--include,-istring, required: Files to include. You can use path expansion, glob patterns and multiple paths.Example:
-i src/**/*.ts.--format,-fstring, optional, Default:xlf: Output format. (For now only xlf is supported).Example:
-f xlf--out-file,-ostring, required: Path where you would like to save extracted strings.Example
-o src/i18n/messages.xlf
Limitaions
This package is using regex to extract code based localization. that is why it needs id or automatically assign id to work.
It extracts code based localization even if it is commented. The fix is at my TODO
No support for meaning and discription. Currently working on this
Supports only
xlfmessages file extenstion. The fix is at my TODO
Other TODO
- Create report at logs