ng-extract-i18n-merge
Version:
Extract and merge i18n xliff translation files for angular projects.
27 lines (26 loc) • 957 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.TranslationFile = void 0;
class TranslationFile {
constructor(units, sourceLang, targetLang, xmlHeader, trailingWhitespace) {
this.units = units;
this.sourceLang = sourceLang;
this.targetLang = targetLang;
this.xmlHeader = xmlHeader;
this.trailingWhitespace = trailingWhitespace;
}
mapUnitsList(unitsMapper) {
return new TranslationFile(unitsMapper(this.units), this.sourceLang, this.targetLang, this.xmlHeader, this.trailingWhitespace);
}
replaceUnit(unit, updated) {
const index = this.units.findIndex(u => u.id === unit.id); // TODO performance?
if (index === -1) {
throw new Error(`Unit ${unit.id} not found`);
}
this.units[index] = updated;
}
addUnit(updated) {
this.units.push(updated);
}
}
exports.TranslationFile = TranslationFile;
;