ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - daniel-sc/ng-extract-i18n-merge: Extract and merge i18n xliff translation files for angular projects.
Extract and merge i18n xliff translation files for angular projects. - daniel-sc/ng-extract-i18n-merge
Visit Site

GitHub - daniel-sc/ng-extract-i18n-merge: Extract and merge i18n xliff translation files for angular projects.

GitHub - daniel-sc/ng-extract-i18n-merge: Extract and merge i18n xliff translation files for angular projects.

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 ;-) ).

[!TIP] If you'd like to keep your translation process simple and rather validate translations, than waiting for actual translations, I'd like you to check out doloc.io.

Created by the maintainer of ng-extract-i18n-merge (@daniel-sc), it integrates seamlessly with this library (see here) and provides instant translations on extraction!

Expect great translations!

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:

Name Default Description
browserTarget Inferred from current setup by ng add Deprecated: 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
buildTarget Inferred from current setup by ng add A build builder target to extract i18n messages in the format of project:target[:configuration]. See https://angular.io/cli/extract-i18n#options
format Inferred from current setup by ng add Any of xlf, xlif, xliff, xlf2, xliff2
outputPath Inferred from current setup by ng add Path to folder containing all (source and target) translation files.
targetFiles Inferred from current setup by ng add Filenames (relative to outputPath of all target translation files (e.g. ["messages.fr.xlf", "messages.de.xlf"]).
sourceLanguageTargetFile Unused If 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.
sourceFile messages.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.
fuzzyMatch true Whether translation units without matching IDs are fuzzy matched by source text.
resetTranslationState true Reset the translation state to new/initial for new/changed units.
prettyNestedTags true (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.
sortNestedTagAttributess false Attributes of xml nodes (interpolations, nested html) in source/target/meaning/description can be sorted for normalization.
collapseWhitespace true Collapsing of multiple whitespaces/line breaks in translation sources and targets.
trim false Trim translation sources and targets.
includeContext false Whether 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.
includeMeaningAndDescription true Whether to include the meaning and description information in the translation files.
newTranslationTargetsBlank false When 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).
verbose false Extended/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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory