Socket
Book a DemoInstallSign in
Socket

ngx-i18nsupport

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-i18nsupport - npm Package Compare versions

Comparing version

to
0.15.0

test/testdata/i18n/WithSourceContentChange.de.xlf

11

Changelog.md

@@ -0,1 +1,8 @@

<a name="0.15.0"></a>
# [0.15.0](https://github.com/martinroob/ngx-i18nsupport/compare/v0.15.0...v0.14.0) (2018-04-22)
### Bug fixes
* **xliffmerge** Merge for source language isn't updating ([#81](https://github.com/martinroob/ngx-i18nsupport/issues/81)).
This happened when there was an explicitly set ID and the original text was changed.
<a name="0.14.0"></a>

@@ -10,3 +17,3 @@ # [0.14.0](https://github.com/martinroob/ngx-i18nsupport/compare/v0.14.0...v0.13.0) (2018-04-16)

(`node_modules/ngx-i18nsupport/dist/xliffmerge/configuration-schema.json`,
actual version available under [configuration-schema.json](https://github.com/martinroob/ngx-i18nsupport/src/xliffmerge/configuration-schema.json)).
actual version available under [configuration-schema.json](https://github.com/martinroob/ngx-i18nsupport/blob/master/src/xliffmerge/configuration-schema.json)).

@@ -301,2 +308,2 @@ ### Bug fixes

Initial version
Initial version

@@ -257,2 +257,31 @@ "use strict";

});
it('should merge changed source content with explicit ID to default language file (#81)', function (done) {
var ID_SOURCE_CHANGE = 'sourcechanged';
var ID_SOURCE_CHANGE_STATE_FINAL = 'sourcechanged_state_final';
var TRANSLATED_FILE = 'WithSourceContentChange.de.xlf';
file_util_1.FileUtil.copy(SRCDIR + 'ngExtractedMasterWithSourceContentChange.xlf', MASTER);
file_util_1.FileUtil.copy(SRCDIR + TRANSLATED_FILE, WORKDIR + 'messages.de.xlf');
var ws = new writer_to_string_1.WriterToString();
var commandOut = new command_output_1.CommandOutput(ws);
var profileContent = {
xliffmergeOptions: {
defaultLanguage: 'de',
srcDir: WORKDIR,
genDir: WORKDIR,
i18nFile: MASTERFILE
}
};
var xliffMergeCmd = xliff_merge_1.XliffMerge.createFromOptions(commandOut, { languages: ['de', 'en'], verbose: true }, profileContent);
xliffMergeCmd.run();
expect(ws.writtenData()).not.toContain('ERROR');
expect(ws.writtenData()).toContain('WARNING: transferred 2 changed source content from master to "de"');
// check that source is changed
var langFileGerman = readXliff(xliffMergeCmd.generatedI18nFile('de'));
var tu = langFileGerman.transUnitWithId(ID_SOURCE_CHANGE);
expect(tu).toBeTruthy();
expect(tu.sourceContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetState()).toBe(dist_1.STATE_FINAL);
done();
});
it('should merge changed source content to already translated files', function (done) {

@@ -259,0 +288,0 @@ var ID_SOURCE_CHANGE = 'sourcechanged';

@@ -282,2 +282,32 @@ "use strict";

});
it('should merge changed source content with explicit ID to default language file (#81)', function (done) {
var ID_SOURCE_CHANGE = 'sourcechanged';
var ID_SOURCE_CHANGE_STATE_FINAL = 'sourcechanged_state_final';
var TRANSLATED_FILE = 'WithSourceContentChange.de.xlf2';
file_util_1.FileUtil.copy(SRCDIR + 'ngExtractedMasterWithSourceContentChange.xlf2', MASTER);
file_util_1.FileUtil.copy(SRCDIR + TRANSLATED_FILE, WORKDIR + 'messages.de.xlf');
var ws = new writer_to_string_1.WriterToString();
var commandOut = new command_output_1.CommandOutput(ws);
var profileContent = {
xliffmergeOptions: {
defaultLanguage: 'de',
srcDir: WORKDIR,
genDir: WORKDIR,
i18nFormat: 'xlf2',
i18nFile: MASTERFILE
}
};
var xliffMergeCmd = xliff_merge_1.XliffMerge.createFromOptions(commandOut, { languages: ['de', 'en'], verbose: true }, profileContent);
xliffMergeCmd.run();
expect(ws.writtenData()).not.toContain('ERROR');
expect(ws.writtenData()).toContain('WARNING: transferred 2 changed source content from master to "de"');
// check that source is changed
var langFileGerman = readXliff2(xliffMergeCmd.generatedI18nFile('de'));
var tu = langFileGerman.transUnitWithId(ID_SOURCE_CHANGE);
expect(tu).toBeTruthy();
expect(tu.sourceContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetState()).toBe(dist_1.STATE_FINAL);
done();
});
it('should merge changed source content to already translated files', function (done) {

@@ -284,0 +314,0 @@ var ID_SOURCE_CHANGE = 'sourcechanged';

13

dist/xliffmerge/xliff-merge.js

@@ -330,6 +330,13 @@ "use strict";

transUnit.setSourceContent(masterTransUnit.sourceContent());
if (transUnit.targetState() == dist_1.STATE_FINAL) {
// source is changed, so translation has to be checked again
transUnit.setTargetState(dist_1.STATE_TRANSLATED);
if (isDefaultLang) {
// #81 changed source must be copied to target for default lang
transUnit.translate(masterTransUnit.sourceContent());
transUnit.setTargetState(dist_1.STATE_FINAL);
}
else {
if (transUnit.targetState() == dist_1.STATE_FINAL) {
// source is changed, so translation has to be checked again
transUnit.setTargetState(dist_1.STATE_TRANSLATED);
}
}
correctSourceContentCount++;

@@ -336,0 +343,0 @@ }

{
"name": "ngx-i18nsupport",
"version": "0.14.0",
"version": "0.15.0",
"description": "Some tooling to be used with the Angular 2 i18n workflow",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,3 +12,3 @@ import * as fs from "fs";

import {getApiKey} from '../autotranslate/auto-translate-service.spec';
import {STATE_NEW, STATE_TRANSLATED} from 'ngx-i18nsupport-lib/dist';
import {STATE_FINAL, STATE_NEW, STATE_TRANSLATED} from 'ngx-i18nsupport-lib/dist';
import {XmlReader} from './xml-reader';

@@ -276,2 +276,33 @@

it('should merge changed source content with explicit ID to default language file (#81)', (done) => {
const ID_SOURCE_CHANGE = 'sourcechanged';
const ID_SOURCE_CHANGE_STATE_FINAL = 'sourcechanged_state_final';
const TRANSLATED_FILE = 'WithSourceContentChange.de.xlf';
FileUtil.copy(SRCDIR + 'ngExtractedMasterWithSourceContentChange.xlf', MASTER);
FileUtil.copy(SRCDIR + TRANSLATED_FILE,WORKDIR + 'messages.de.xlf');
let ws: WriterToString = new WriterToString();
let commandOut = new CommandOutput(ws);
let profileContent: IConfigFile = {
xliffmergeOptions: {
defaultLanguage: 'de',
srcDir: WORKDIR,
genDir: WORKDIR,
i18nFile: MASTERFILE
}
};
let xliffMergeCmd = XliffMerge.createFromOptions(commandOut, {languages: ['de', 'en'], verbose: true}, profileContent);
xliffMergeCmd.run();
expect(ws.writtenData()).not.toContain('ERROR');
expect(ws.writtenData()).toContain('WARNING: transferred 2 changed source content from master to "de"');
// check that source is changed
let langFileGerman: ITranslationMessagesFile = readXliff(xliffMergeCmd.generatedI18nFile('de'));
let tu: ITransUnit = langFileGerman.transUnitWithId(ID_SOURCE_CHANGE);
expect(tu).toBeTruthy();
expect(tu.sourceContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetState()).toBe(STATE_FINAL);
done();
});
it('should merge changed source content to already translated files', (done) => {

@@ -278,0 +309,0 @@ const ID_SOURCE_CHANGE = 'sourcechanged';

@@ -10,3 +10,3 @@ import * as fs from "fs";

import {TranslationMessagesFileReader} from './translation-messages-file-reader';
import {STATE_NEW, STATE_TRANSLATED} from 'ngx-i18nsupport-lib/dist';
import {STATE_FINAL, STATE_NEW, STATE_TRANSLATED} from 'ngx-i18nsupport-lib/dist';
import {getApiKey} from '../autotranslate/auto-translate-service.spec';

@@ -302,2 +302,34 @@ import {XmlReader} from './xml-reader';

it('should merge changed source content with explicit ID to default language file (#81)', (done) => {
const ID_SOURCE_CHANGE = 'sourcechanged';
const ID_SOURCE_CHANGE_STATE_FINAL = 'sourcechanged_state_final';
const TRANSLATED_FILE = 'WithSourceContentChange.de.xlf2';
FileUtil.copy(SRCDIR + 'ngExtractedMasterWithSourceContentChange.xlf2', MASTER);
FileUtil.copy(SRCDIR + TRANSLATED_FILE,WORKDIR + 'messages.de.xlf');
let ws: WriterToString = new WriterToString();
let commandOut = new CommandOutput(ws);
let profileContent: IConfigFile = {
xliffmergeOptions: {
defaultLanguage: 'de',
srcDir: WORKDIR,
genDir: WORKDIR,
i18nFormat: 'xlf2',
i18nFile: MASTERFILE
}
};
let xliffMergeCmd = XliffMerge.createFromOptions(commandOut, {languages: ['de', 'en'], verbose: true}, profileContent);
xliffMergeCmd.run();
expect(ws.writtenData()).not.toContain('ERROR');
expect(ws.writtenData()).toContain('WARNING: transferred 2 changed source content from master to "de"');
// check that source is changed
let langFileGerman: ITranslationMessagesFile = readXliff2(xliffMergeCmd.generatedI18nFile('de'));
let tu: ITransUnit = langFileGerman.transUnitWithId(ID_SOURCE_CHANGE);
expect(tu).toBeTruthy();
expect(tu.sourceContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetContent()).toBe('Test Änderung Source (geändert!)');
expect(tu.targetState()).toBe(STATE_FINAL);
done();
});
it('should merge changed source content to already translated files', (done) => {

@@ -304,0 +336,0 @@ const ID_SOURCE_CHANGE = 'sourcechanged';

@@ -348,5 +348,11 @@ import * as program from 'commander';

transUnit.setSourceContent(masterTransUnit.sourceContent());
if (transUnit.targetState() == STATE_FINAL) {
// source is changed, so translation has to be checked again
transUnit.setTargetState(STATE_TRANSLATED);
if (isDefaultLang) {
// #81 changed source must be copied to target for default lang
transUnit.translate(masterTransUnit.sourceContent());
transUnit.setTargetState(STATE_FINAL);
} else {
if (transUnit.targetState() == STATE_FINAL) {
// source is changed, so translation has to be checked again
transUnit.setTargetState(STATE_TRANSLATED);
}
}

@@ -353,0 +359,0 @@ correctSourceContentCount++;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.