1.0.2-SNAPSHOT • Published 2 years ago

@mingleats/ng-extract-i18n-merge v1.0.2-SNAPSHOT

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm Coverage Status Language grade: JavaScript

Angular extract i18n and merge

This extends Angular CLI to improve the i18n extraction and merge workflow. New/removed translations are added/removed from the target translation files. Additionally, translation files are normalized (pretty print, sorted by id) so that diffs are easy to read (and translations in PRs might actually get reviewd ;-) ).

Install

Prerequisites: i18n setup with defined target locales in angular.json - as documented here.

ng add ng-extract-i18n-merge

Usage

ng run [PROJECT_ID]:extract-i18n-merge
# or (if you confirmed to adding an npm command):
npm run extract-i18n-merge 

Configuration

In your angular.json you'll find a new target extract-i18n-merge that can be configured with the following options:

NameDefaultDescription
formatInferred from current setup by ng addAny of xlf, xlif, xliff, xlf2, xliff2
outputPathInferred from current setup by ng addPath to folder containing all (source and target) translation files.
targetFilesInferred from current setup by ng addFilenames (relative to outputPath of all target translation files (e.g. ["messages.fr.xlf", "messages.de.xlf"]
removeIdsWithPrefix[]List of prefix strings. All translation units with matching id attribute are removed. Useful for excluding duplicate library translations.
fuzzyMatchtrueWhether translation units without matching IDs are fuzzy matched by source text.
resetTranslationStatetrueReset the translation state to new/initial for new/changed units.
collapseWhitespacetrueCollapsing of multiple whitespaces and trimming when comparing translations sources.
includeContextfalseWhether to include the context information (like notes) in the translation files. This is useful for sending the target translation files to translation agencies/services.

Contribute

Feedback and PRs always welcome :-)