2.11.2 • Published 1 month ago

ng-extract-i18n-merge v2.11.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

npm Coverage Status CodeQL

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 and translation states are managed. Additionally, translation files are normalized (whitespace, stable sort) so that diffs are easy to read (and translations in PRs might actually get reviewed ;-) ).

Install

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

ng add ng-extract-i18n-merge

Upgrade from 1.x.x to 2.0.0

To upgrade use ng update ng-extract-i18n-merge - this will perform all necessary migrations.

Breaking changes:

  • Now this plugin uses the default angular "extract-i18n" target - so you can (must) simply run ng extract-i18n! (#30)
  • Default sort is now "stableAppendNew" (was: "idAsc") (#26).
  • Leading/trailing whitespaces are normalized (i.e. collapsed to one space) but not completely trimmed (#28).
  • Npm run script is removed (you can create a manual npm run script of course).

Usage

ng extract-i18n # yes, same as before - this replaces the original builder

Configuration

In your angular.json the target extract-i18n that can be configured with the following options:

NameDefaultDescription
browserTargetInferred from current setup by ng addDeprecated: Use buildTarget. A browser builder target to extract i18n messages in the format of project:target[:configuration]. See https://angular.io/cli/extract-i18n#options
buildTargetInferred from current setup by ng addA build builder target to extract i18n messages in the format of project:target[:configuration]. See https://angular.io/cli/extract-i18n#options
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"]).
sourceLanguageTargetFileUnusedIf this is set (to one of the targetFiles), new translations in that target file will be set to state="final" (instead of default state="new"). This file can be used to manage changes to the source texts: when a translator updates the target, this tool will hint the developer to update the code occurrences.
sourceFilemessages.xlf. ng add tries to infer non default setups.Filename (relative to outputPath of source translation file (e.g. "translations-source.xlf").
removeIdsWithPrefix[]List of prefix strings. All translation units with matching id attribute are removed. Useful for excluding duplicate library translations. Cannot be used in combination with includeIdsWithPrefix.
includeIdsWithPrefix[]List of prefix strings. When non-empty, only translations units with matching id are included. Useful for extracting translations of a single library in a multi-library project. Cannot be used in combination with removeIdsWithPrefix.
fuzzyMatchtrueWhether translation units without matching IDs are fuzzy matched by source text.
resetTranslationStatetrueReset the translation state to new/initial for new/changed units.
prettyNestedTagstrue (will change to false with v3.0.0)If source/target only contains xml nodes (interpolations, nested html), true formats these with line breaks and indentation. false keeps the original angular single line format. Note: while true was the historic implementation, it is not recommended, as it adds whitespace between tags that had no whitespace in between and increases bundle sizes.
sortNestedTagAttributessfalseAttributes of xml nodes (interpolations, nested html) in source/target/meaning/description can be sorted for normalization.
collapseWhitespacetrueCollapsing of multiple whitespaces/line breaks in translation sources and targets.
trimfalseTrim translation sources and targets.
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. When sourceFileOnly, the context is retained only in the sourceFile.
includeMeaningAndDescriptiontrueWhether to include the meaning and description information in the translation files.
newTranslationTargetsBlankfalseWhen false (default) the "target" of new translation units is set to the "source" value. When true, an empty string is used. When 'omit', no target element is created.
sort"stableAppendNew" (will change to stableAlphabetNew with v3.0.0)Sorting of all translation units in source and target translation files. Supported: "idAsc" (sort by translation IDs), "stableAppendNew" (keep existing sorting, append new translations at the end), "stableAlphabetNew" (keep existing sorting, sort new translations next to alphabetical close IDs).
builderI18n"@angular-devkit/build-angular:extract-i18n"The builder to use for i18n extraction. Any custom builder should handle the same options as the default angular builder (buildTarget, outputPath, outFile, format, progress).
verbosefalseExtended/debug output - it is recommended to use this only for manual debugging.

Contribute

Feedback and PRs always welcome :-)

Before developing complex changes, I'd recommend opening an issue to discuss whether the indented goals match the scope of this package.

2.11.2

1 month ago

2.11.1

1 month ago

2.11.0

2 months ago

2.11.0-0

2 months ago

2.11.0-1

2 months ago

2.10.0

3 months ago

2.10.0-2

3 months ago

2.10.0-1

3 months ago

2.10.0-0

3 months ago

2.9.1

5 months ago

2.8.1

6 months ago

2.8.0

6 months ago

2.8.0-0

7 months ago

2.9.0

6 months ago

2.8.3

6 months ago

2.8.2

6 months ago

2.8.3-2

6 months ago

2.8.3-0

6 months ago

2.8.3-1

6 months ago

2.7.1

8 months ago

2.5.0

1 year ago

2.7.0

1 year ago

2.6.0

1 year ago

2.5.1

1 year ago

2.6.0-0

1 year ago

2.3.0

2 years ago

2.4.0

2 years ago

2.5.0-0

1 year ago

2.2.0

2 years ago

2.0.0-10

2 years ago

2.1.2

2 years ago

2.0.0-6

2 years ago

2.1.1

2 years ago

2.0.0-5

2 years ago

2.0.0-4

2 years ago

2.0.0-3

2 years ago

2.0.0-2

2 years ago

2.0.0-1

2 years ago

2.0.0-0

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-8

2 years ago

2.0.0-7

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.4-0

2 years ago

1.2.3

2 years ago

1.0.5

2 years ago

1.2.2

2 years ago

1.0.4

2 years ago

1.0.3-0

2 years ago

1.2.1

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.2-alpha.1

2 years ago