@translation/angular
Advanced tools
Comparing version 1.6.0 to 1.7.0
# Changelog | ||
## [v1.7.0](https://github.com/translation/angular/releases/tag/v1.7.0) (2023-07-07) | ||
#### Fixes (bugs & defects): | ||
* Improve the rebuilding of target XLF files [#7](https://github.com/translation/angular/pull/7). | ||
## [v1.6.0](https://github.com/translation/angular/releases/tag/v1.6.0) (2023-02-20) | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@translation/angular", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Translation.io client for Angular applications", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -346,9 +346,12 @@ const Interpolation = require('../utils/interpolation') | ||
// 4 Populate the loaded .xlf it with targets from Translation.io | ||
const translatedTargetSegments = response.segments[language] | ||
const targetXmlUnitsHash = this.buildXmlUnitsHash(targetXmlUnits) | ||
const translatedTargetSegments = response.segments[language] | ||
const translatedTargetSegmentsHash = this.buildTranslatedTargetSegmentsHash(translatedTargetSegments) | ||
translatedTargetSegments.forEach(translatedTargetSegment => { | ||
let targetXmlUnit = targetXmlUnitsHash[this.uniqueIdentifier(translatedTargetSegment)] | ||
if (targetXmlUnit && translatedTargetSegment.target != '') { // if not translated, then no <target>, then fallback to source language | ||
// Iterate over XML units | ||
targetXmlUnits.forEach(targetXmlUnit => { | ||
const targetXmlUnitSegment = this.convertXmlUnitToSegment(targetXmlUnit) | ||
const xmlUniqueIdentifier = this.uniqueIdentifier(targetXmlUnitSegment) | ||
const translatedTargetSegment = translatedTargetSegmentsHash[xmlUniqueIdentifier] | ||
if (translatedTargetSegment && translatedTargetSegment.target != '') { // if not translated, then no <target>, then fallback to source language | ||
targetXmlUnit.target = this.recomposeTarget(targetXmlUnit, translatedTargetSegment) | ||
@@ -364,2 +367,13 @@ } | ||
// For O(1) search optimization | ||
buildTranslatedTargetSegmentsHash(segments) { | ||
let translatedTargetSegmentsHash = {} | ||
segments.forEach(segment => { | ||
translatedTargetSegmentsHash[this.uniqueIdentifier(segment)] = segment | ||
}) | ||
return translatedTargetSegmentsHash | ||
} | ||
// Use XML segment and API segment to build back the target with existing interpolations | ||
@@ -393,14 +407,2 @@ recomposeTarget(xmlUnit, segment) { | ||
// For O(1) search optimization | ||
buildXmlUnitsHash(xmlUnits) { | ||
let targetXmlUnitsHash = {} | ||
xmlUnits.forEach(xmlUnit => { | ||
const segment = this.convertXmlUnitToSegment(xmlUnit) | ||
targetXmlUnitsHash[this.uniqueIdentifier(segment)] = xmlUnit | ||
}) | ||
return targetXmlUnitsHash | ||
} | ||
escapeDoubleSingleQuotesFromIcuPlural(icuPlural) { | ||
@@ -407,0 +409,0 @@ // cf. https://www.debuggex.com/r/KO9jkSfi2RVzHlVE |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52372
713