Skip to content

Commit

Permalink
Merge pull request #89 from martinroob/bugfix-0.16.1
Browse files Browse the repository at this point in the history
Bugfix 0.16.1
  • Loading branch information
martinroob committed May 25, 2018
2 parents 2b342e0 + 032446c commit ba20a72
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<a name="0.16.1"></a>
# [0.16.1](https://github.com/martinroob/ngx-i18nsupport/compare/v0.16.1...v0.16.0) (2018-05-25)

### Bug fixes
* **xliffmerge:** New configuration flag `beautifyOutput` now working. When set to `true` now [pretty-data](https://github.com/vkiryukhin/pretty-data) (the library beyond pretty-xml) will be used to format the output.
([#64](https://github.com/martinroob/ngx-i18nsupport/issues/64))
([#88](https://github.com/martinroob/ngx-i18nsupport/issues/88))

<a name="0.16.0"></a>
# [0.16.0](https://github.com/martinroob/ngx-i18nsupport/compare/v0.16.0...v0.15.0) (2018-05-01)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-i18nsupport",
"version": "0.16.0",
"version": "0.16.1",
"description": "Some tooling to be used with the Angular 2 i18n workflow",
"main": "index.js",
"module": "./src",
Expand Down
2 changes: 1 addition & 1 deletion src/xliffmerge/translation-messages-file-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class TranslationMessagesFileReader {
* Default is false.
*/
public static save(messagesFile: ITranslationMessagesFile, beautifyOutput?: boolean) {
FileUtil.replaceContent(messagesFile.filename(), messagesFile.editedContent(), messagesFile.encoding());
FileUtil.replaceContent(messagesFile.filename(), messagesFile.editedContent(beautifyOutput), messagesFile.encoding());
}
}

42 changes: 42 additions & 0 deletions src/xliffmerge/xlf12-merge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,48 @@ describe('XliffMerge XLIFF 1.2 format tests', () => {
done();
});

it('should use beautify when requested (#64, #88)', (done) => {
FileUtil.copy(MASTER1SRC, MASTER);
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']}, profileContent);
xliffMergeCmd.run();
expect(ws.writtenData()).not.toContain('ERROR');

const unformattedContent = XmlReader.readXmlFileContent(xliffMergeCmd.generatedI18nFile('en'));
expect(unformattedContent.content).toContain('<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">');
// to debug formatting: FileUtil.copy(xliffMergeCmd.generatedI18nFile('en'), SRCDIR + 'nobeautify');

// next step, same with beautify
FileUtil.deleteFile(xliffMergeCmd.generatedI18nFile('en'));
ws = new WriterToString();
commandOut = new CommandOutput(ws);
profileContent = {
xliffmergeOptions: {
defaultLanguage: 'de',
srcDir: WORKDIR,
genDir: WORKDIR,
i18nFile: MASTERFILE,
beautifyOutput: true
}
};
xliffMergeCmd = XliffMerge.createFromOptions(commandOut, {languages: ['de', 'en']}, profileContent);
xliffMergeCmd.run();
expect(ws.writtenData()).not.toContain('ERROR');
const formattedContent = XmlReader.readXmlFileContent(xliffMergeCmd.generatedI18nFile('en'));
expect(formattedContent.content).toContain('<xliff version="1.2" \n xmlns="urn:oasis:names:tc:xliff:document:1.2">');
// to debug formatting: FileUtil.copy(xliffMergeCmd.generatedI18nFile('en'), SRCDIR + 'beautify');
done();
});

describe('autotranslate via google translate', () => {

let apikey: string;
Expand Down

0 comments on commit ba20a72

Please sign in to comment.