ngx-i18nsupport
Advanced tools
Comparing version 0.8.3 to 0.8.4
@@ -0,1 +1,8 @@ | ||
<a name="0.8.4"></a> | ||
# [0.8.4](https://github.com/martinroob/ngx-i18nsupport/compare/v0.8.3...v0.8.4) (2017-08-22) | ||
### Bug Fixes | ||
* **xliffmerge:** When autotranslate is disabled, there should be no warning "Auto translation from..." ([#49](https://github.com/martinroob/ngx-i18nsupport/issues/49)). | ||
<a name="0.8.3"></a> | ||
@@ -2,0 +9,0 @@ # [0.8.3](https://github.com/martinroob/ngx-i18nsupport/compare/v0.8.0...v0.8.3) (2017-08-18) |
@@ -10,2 +10,3 @@ "use strict"; | ||
var dist_1 = require("ngx-i18nsupport-lib/dist"); | ||
var auto_translate_service_spec_1 = require("../autotranslate/auto-translate-service.spec"); | ||
/** | ||
@@ -306,2 +307,32 @@ * Created by martin on 18.02.2017. | ||
}); | ||
it('should not output a warning when autotranslate is not enabled for a language (issue #49)', function (done) { | ||
file_util_1.FileUtil.copy(MASTER2SRC, MASTER); | ||
var ws = new writer_to_string_1.WriterToString(); | ||
var commandOut = new command_output_1.CommandOutput(ws); | ||
var apiKey = auto_translate_service_spec_1.getApiKey(); | ||
var profileContent = { | ||
xliffmergeOptions: { | ||
defaultLanguage: 'de', | ||
languages: ['de', 'ru', 'en'], | ||
autotranslate: ['ru'], | ||
apikey: apiKey, | ||
srcDir: WORKDIR, | ||
genDir: WORKDIR, | ||
i18nFormat: 'xlf2', | ||
i18nFile: MASTERFILE | ||
} | ||
}; | ||
var xliffMergeCmd = xliff_merge_1.XliffMerge.createFromOptions(commandOut, {}, profileContent); | ||
xliffMergeCmd.run(function () { | ||
if (apiKey) { | ||
expect(ws.writtenData()).not.toContain('ERROR'); | ||
expect(ws.writtenData()).not.toContain('Auto translation from "de" to "en"'); | ||
expect(ws.writtenData()).toContain('Auto translation from "de" to "ru"'); | ||
} | ||
else { | ||
expect(ws.writtenData()).toContain('ERROR: autotranslate requires an API key'); | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -308,0 +339,0 @@ describe('ngx-translate processing for format XLIFF 2.0', function () { |
@@ -415,3 +415,4 @@ "use strict"; | ||
var serviceCall; | ||
if (this.parameters.autotranslateLanguage(to)) { | ||
var autotranslateEnabled = this.parameters.autotranslateLanguage(to); | ||
if (autotranslateEnabled) { | ||
serviceCall = this.autoTranslateService.autoTranslate(from, to, languageSpecificMessagesFile); | ||
@@ -423,8 +424,10 @@ } | ||
return serviceCall.map(function (summary) { | ||
if (summary.error() || summary.failed() > 0) { | ||
_this.commandOutput.error(summary.content()); | ||
if (autotranslateEnabled) { | ||
if (summary.error() || summary.failed() > 0) { | ||
_this.commandOutput.error(summary.content()); | ||
} | ||
else { | ||
_this.commandOutput.warn(summary.content()); | ||
} | ||
} | ||
else { | ||
_this.commandOutput.warn(summary.content()); | ||
} | ||
return summary; | ||
@@ -431,0 +434,0 @@ }); |
{ | ||
"name": "ngx-i18nsupport", | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"description": "Some tooling to be used with the Angular 2 i18n workflow", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,2 +11,3 @@ import * as fs from "fs"; | ||
import {STATE_NEW, STATE_TRANSLATED} from 'ngx-i18nsupport-lib/dist'; | ||
import {getApiKey} from '../autotranslate/auto-translate-service.spec'; | ||
@@ -333,2 +334,33 @@ /** | ||
it('should not output a warning when autotranslate is not enabled for a language (issue #49)', (done) => { | ||
FileUtil.copy(MASTER2SRC, MASTER); | ||
let ws: WriterToString = new WriterToString(); | ||
let commandOut = new CommandOutput(ws); | ||
const apiKey = getApiKey(); | ||
let profileContent: IConfigFile = { | ||
xliffmergeOptions: { | ||
defaultLanguage: 'de', | ||
languages: ['de', 'ru', 'en'], | ||
autotranslate: ['ru'], | ||
apikey: apiKey, | ||
srcDir: WORKDIR, | ||
genDir: WORKDIR, | ||
i18nFormat: 'xlf2', | ||
i18nFile: MASTERFILE | ||
} | ||
}; | ||
let xliffMergeCmd = XliffMerge.createFromOptions(commandOut, {}, profileContent); | ||
xliffMergeCmd.run(() => { | ||
if (apiKey) { | ||
expect(ws.writtenData()).not.toContain('ERROR'); | ||
expect(ws.writtenData()).not.toContain('Auto translation from "de" to "en"'); | ||
expect(ws.writtenData()).toContain('Auto translation from "de" to "ru"'); | ||
} else { | ||
expect(ws.writtenData()).toContain('ERROR: autotranslate requires an API key'); | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -335,0 +367,0 @@ |
@@ -274,3 +274,2 @@ import * as program from 'commander'; | ||
let languageSpecificMessagesFile: ITranslationMessagesFile = this.master.createTranslationFileForLang(lang, languageXliffFilePath, isDefaultLang, this.parameters.useSourceAsTarget()); | ||
return this.autoTranslate(this.master.sourceLanguage(), lang, languageSpecificMessagesFile).map((summary) => { | ||
@@ -436,3 +435,4 @@ // write it to file | ||
let serviceCall: Observable<AutoTranslateSummaryReport>; | ||
if (this.parameters.autotranslateLanguage(to)) { | ||
let autotranslateEnabled: boolean = this.parameters.autotranslateLanguage(to); | ||
if (autotranslateEnabled) { | ||
serviceCall = this.autoTranslateService.autoTranslate(from, to, languageSpecificMessagesFile); | ||
@@ -443,6 +443,8 @@ } else { | ||
return serviceCall.map((summary) => { | ||
if (summary.error() || summary.failed() > 0) { | ||
this.commandOutput.error(summary.content()); | ||
} else { | ||
this.commandOutput.warn(summary.content()); | ||
if (autotranslateEnabled) { | ||
if (summary.error() || summary.failed() > 0) { | ||
this.commandOutput.error(summary.content()); | ||
} else { | ||
this.commandOutput.warn(summary.content()); | ||
} | ||
} | ||
@@ -449,0 +451,0 @@ return summary; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
623679
7565