From b2e4a1fb6086ac157fa8599560ef514cd99d235f Mon Sep 17 00:00:00 2001 From: Bernhard Date: Thu, 4 Nov 2021 17:16:08 +0100 Subject: [PATCH] chore: dep upgrade and iface fixes --- angular.json | 3 + package.json | 101 +++++++++--------- .../ngx-i18nsupport-lib/src/api/api.spec.ts | 2 +- .../i-translation-messages-file-factory.ts | 10 +- .../api/translation-messages-file-factory.ts | 16 +-- .../abstract-translation-messages-file.ts | 6 +- .../src/impl/xliff-file.spec.ts | 2 +- .../src/impl/xliff-file.ts | 4 +- .../src/impl/xliff2-file.spec.ts | 2 +- .../src/impl/xliff2-file.ts | 4 +- .../src/impl/xmb-file.spec.ts | 2 +- .../ngx-i18nsupport-lib/src/impl/xmb-file.ts | 4 +- .../src/impl/xtb-file.spec.ts | 42 +++++--- .../ngx-i18nsupport-lib/src/impl/xtb-file.ts | 8 +- .../src/app/model/translation-file.ts | 2 +- .../src/common/common-testing_spec.ts | 2 +- .../src/common/package-json-snapshot.ts | 2 +- .../src/common/workspace-snapshot.ts | 2 +- .../common/xliffmerge-config-json-snapshot.ts | 2 +- projects/xliffmerge/ng-package.json | 9 +- projects/xliffmerge/package.json | 8 +- projects/xliffmerge/src/common/file-util.ts | 12 +-- .../xliffmerge/src/common/writer-to-string.ts | 2 +- .../src/xliffmerge/i-xliff-merge-options.ts | 2 +- .../src/xliffmerge/ngx-translate-extractor.ts | 2 +- .../translation-messages-file-reader.ts | 12 +-- .../src/xliffmerge/xlf12-merge.spec.ts | 16 +-- .../src/xliffmerge/xlf20-merge.spec.ts | 12 +-- .../src/xliffmerge/xliff-merge-parameters.ts | 10 +- .../xliffmerge/src/xliffmerge/xliff-merge.ts | 2 +- .../src/xliffmerge/xmb-merge.spec.ts | 12 +-- .../xliffmerge/src/xliffmerge/xml-reader.ts | 8 +- src/polyfills.ts | 4 + 33 files changed, 173 insertions(+), 154 deletions(-) diff --git a/angular.json b/angular.json index bd652ce..f05fff9 100644 --- a/angular.json +++ b/angular.json @@ -1,5 +1,8 @@ { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "cli": { + "analytics": false + }, "version": 1, "newProjectRoot": "projects", "newProjectRoot": "projects", diff --git a/package.json b/package.json index aa51c35..f7c95c7 100644 --- a/package.json +++ b/package.json @@ -20,60 +20,61 @@ "projects/tiny-translator" ], "dependencies": { - "@angular-devkit/architect": "^0.800.0", - "@angular-devkit/core": "~8.0.0", - "@angular-devkit/schematics": "~8.0.0", - "@angular/animations": "^8.0.0", - "@angular/cdk": "^8.0.0", - "@angular/common": "^8.0.0", - "@angular/compiler": "^8.0.0", - "@angular/core": "^8.0.0", - "@angular/flex-layout": "^8.0.0-beta.26", - "@angular/forms": "^8.0.0", - "@angular/material": "^8.0.0", - "@angular/platform-browser": "^8.0.0", - "@angular/platform-browser-dynamic": "^8.0.0", - "@angular/pwa": "^0.13.9", - "@angular/router": "~8.0.0", - "@angular/service-worker": "~8.0.0", - "core-js": "^2.6.2", + "@angular-devkit/architect": "^0.1300.1", + "@angular-devkit/core": "~13.0.1", + "@angular-devkit/schematics": "~13.0.1", + "@angular/animations": "^13.0.0", + "@angular/cdk": "^13.0.0", + "@angular/common": "^13.0.0", + "@angular/compiler": "^13.0.0", + "@angular/core": "^13.0.0", + "@angular/flex-layout": "^12.0.0-beta.35", + "@angular/forms": "^13.0.0", + "@angular/material": "^13.0.0", + "@angular/platform-browser": "^13.0.0", + "@angular/platform-browser-dynamic": "^13.0.0", + "@angular/pwa": "^13.0.1", + "@angular/router": "~13.0.0", + "@angular/service-worker": "~13.0.0", + "core-js": "^3.19.1", "hammerjs": "^2.0.8", - "rxjs": "6.5.2", - "tokenizr": "1.4.0", - "tsickle": "0.35.0", - "zone.js": "~0.9.1" + "rxjs": "7.4.0", + "tokenizr": "1.6.4", + "tsickle": "0.43.0", + "zone.js": "~0.11.4" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.800.0", - "@angular-devkit/build-ng-packagr": "~0.800.0", - "@angular/cli": "~8.0.0", - "@angular/compiler-cli": "~8.0.0", - "@angular/language-service": "~8.0.0", - "@types/jasmine": "~3.3.5", - "@types/jasminewd2": "~2.0.6", - "@types/node": "~10.12.18", - "@types/request": "^2.48.1", - "codelyzer": "~5.0.1", - "coveralls": "^3.0.0", + "@angular-devkit/build-angular": "~13.0.1", + "@angular-devkit/build-ng-packagr": "~0.1002.0", + "@angular/cli": "~13.0.1", + "@angular/compiler-cli": "~13.0.0", + "@angular/language-service": "~13.0.0", + "@angular/localize": "^13.0.0", + "@types/jasmine": "~3.10.2", + "@types/jasminewd2": "~2.0.10", + "@types/node": "~16.11.6", + "@types/request": "^2.48.7", + "codelyzer": "~6.0.2", + "coveralls": "^3.1.1", "cpx": "^1.5.0", - "cross-env": "^5.1.1", + "cross-env": "^7.0.3", "istanbul": "^0.4.5", - "jasmine-core": "~3.3.0", - "jasmine-node": "^1.14.5", - "jasmine-spec-reporter": "~4.2.1", - "karma": "~3.1.4", - "karma-chrome-launcher": "~2.2.0", - "karma-coverage-istanbul-reporter": "~2.0.1", - "karma-jasmine": "~2.0.1", - "karma-jasmine-html-reporter": "^1.4.0", + "jasmine-core": "~3.10.1", + "jasmine-node": "^3.0.0", + "jasmine-spec-reporter": "~7.0.0", + "karma": "~6.3.7", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage-istanbul-reporter": "~3.0.3", + "karma-jasmine": "~4.0.1", + "karma-jasmine-html-reporter": "^1.7.0", "lcov-result-merger": "^3.1.0", - "move-cli": "^1.2.0", - "ng-packagr": "^5.2.0", - "protractor": "~5.4.2", - "replace": "^1.0.1", - "ts-node": "~7.0.0", - "tslib": "^1.9.0", - "tslint": "~5.16.0", - "typescript": "~3.4.5" + "move-cli": "^2.0.0", + "ng-packagr": "^13.0.1", + "protractor": "~7.0.0", + "replace": "^1.2.1", + "ts-node": "~10.4.0", + "tslib": "^2.3.1", + "tslint": "~5.20.1", + "typescript": "~4.4.4" } -} \ No newline at end of file +} diff --git a/projects/ngx-i18nsupport-lib/src/api/api.spec.ts b/projects/ngx-i18nsupport-lib/src/api/api.spec.ts index 280fd1d..cb74335 100644 --- a/projects/ngx-i18nsupport-lib/src/api/api.spec.ts +++ b/projects/ngx-i18nsupport-lib/src/api/api.spec.ts @@ -12,7 +12,7 @@ describe('ngx-i18nsupport-lib API test spec', () => { const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8'; /** * Helper function to read Xliff from File diff --git a/projects/ngx-i18nsupport-lib/src/api/i-translation-messages-file-factory.ts b/projects/ngx-i18nsupport-lib/src/api/i-translation-messages-file-factory.ts index 7bc3b40..33ac430 100644 --- a/projects/ngx-i18nsupport-lib/src/api/i-translation-messages-file-factory.ts +++ b/projects/ngx-i18nsupport-lib/src/api/i-translation-messages-file-factory.ts @@ -16,8 +16,8 @@ export interface ITranslationMessagesFileFactory { createFileFromFileContent(i18nFormat: string, xmlContent: string, path: string, - encoding: string, - optionalMaster?: { xmlContent: string, path: string, encoding: string }): ITranslationMessagesFile; + encoding: BufferEncoding , + optionalMaster?: { xmlContent: string, path: string, encoding: BufferEncoding }): ITranslationMessagesFile; /** * Read file function for any file with unknown format. @@ -34,7 +34,7 @@ export interface ITranslationMessagesFileFactory { */ createFileFromUnknownFormatFileContent(xmlContent: string, path: string, - encoding: string, - optionalMaster?: { xmlContent: string, path: string, encoding: string }) + encoding: BufferEncoding , + optionalMaster?: { xmlContent: string, path: string, encoding: BufferEncoding }) : ITranslationMessagesFile; -} \ No newline at end of file +} diff --git a/projects/ngx-i18nsupport-lib/src/api/translation-messages-file-factory.ts b/projects/ngx-i18nsupport-lib/src/api/translation-messages-file-factory.ts index a5c0e11..9a8f516 100644 --- a/projects/ngx-i18nsupport-lib/src/api/translation-messages-file-factory.ts +++ b/projects/ngx-i18nsupport-lib/src/api/translation-messages-file-factory.ts @@ -31,8 +31,8 @@ export class TranslationMessagesFileFactory implements ITranslationMessagesFileF public static fromFileContent(i18nFormat: string, xmlContent: string, path: string, - encoding: string, - optionalMaster?: {xmlContent: string, path: string, encoding: string}): ITranslationMessagesFile { + encoding: BufferEncoding , + optionalMaster?: {xmlContent: string, path: string, encoding: BufferEncoding }): ITranslationMessagesFile { return new TranslationMessagesFileFactory().createFileFromFileContent(i18nFormat, xmlContent, path, encoding, optionalMaster); } @@ -51,8 +51,8 @@ export class TranslationMessagesFileFactory implements ITranslationMessagesFileF */ public static fromUnknownFormatFileContent(xmlContent: string, path: string, - encoding: string, - optionalMaster?: {xmlContent: string, path: string, encoding: string}): ITranslationMessagesFile { + encoding: BufferEncoding , + optionalMaster?: {xmlContent: string, path: string, encoding: BufferEncoding }): ITranslationMessagesFile { return new TranslationMessagesFileFactory().createFileFromUnknownFormatFileContent(xmlContent, path, encoding, optionalMaster); } @@ -71,8 +71,8 @@ export class TranslationMessagesFileFactory implements ITranslationMessagesFileF createFileFromFileContent(i18nFormat: string, xmlContent: string, path: string, - encoding: string, - optionalMaster?: { xmlContent: string, path: string, encoding: string }): ITranslationMessagesFile { + encoding: BufferEncoding , + optionalMaster?: { xmlContent: string, path: string, encoding: BufferEncoding }): ITranslationMessagesFile { if (i18nFormat === FORMAT_XLIFF12) { return new XliffFile(xmlContent, path, encoding); } @@ -104,8 +104,8 @@ export class TranslationMessagesFileFactory implements ITranslationMessagesFileF */ createFileFromUnknownFormatFileContent(xmlContent: string, path: string, - encoding: string, - optionalMaster?: { xmlContent: string, path: string, encoding: string }) + encoding: BufferEncoding , + optionalMaster?: { xmlContent: string, path: string, encoding: BufferEncoding }) : ITranslationMessagesFile { let formatCandidates = [FORMAT_XLIFF12, FORMAT_XLIFF20, FORMAT_XMB, FORMAT_XTB]; if (path && path.endsWith('xmb')) { diff --git a/projects/ngx-i18nsupport-lib/src/impl/abstract-translation-messages-file.ts b/projects/ngx-i18nsupport-lib/src/impl/abstract-translation-messages-file.ts index 8ee80c8..59f873e 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/abstract-translation-messages-file.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/abstract-translation-messages-file.ts @@ -14,7 +14,7 @@ export abstract class AbstractTranslationMessagesFile implements ITranslationMes protected _filename: string; - protected _encoding: string; + protected _encoding: BufferEncoding ; protected _parsedDocument: Document; @@ -50,8 +50,8 @@ export abstract class AbstractTranslationMessagesFile implements ITranslationMes */ protected parseContent( xmlString: string, - path: string, encoding: string, - optionalMaster?: { xmlContent: string, path: string, encoding: string }) + path: string, encoding: BufferEncoding , + optionalMaster?: { xmlContent: string, path: string, encoding: BufferEncoding }) : void { this._filename = path; this._encoding = encoding; diff --git a/projects/ngx-i18nsupport-lib/src/impl/xliff-file.spec.ts b/projects/ngx-i18nsupport-lib/src/impl/xliff-file.spec.ts index 254681f..07481a6 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xliff-file.spec.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xliff-file.spec.ts @@ -16,7 +16,7 @@ describe('ngx-i18nsupport-lib xliff 1.2 test spec', () => { const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8'; /** * Helper function to read Xliff from File diff --git a/projects/ngx-i18nsupport-lib/src/impl/xliff-file.ts b/projects/ngx-i18nsupport-lib/src/impl/xliff-file.ts index e80a3d9..92b6dfe 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xliff-file.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xliff-file.ts @@ -22,14 +22,14 @@ export class XliffFile extends AbstractTranslationMessagesFile implements ITrans * This is read from the file, but if you know it before, you can avoid reading the file twice. * @return XliffFile */ - constructor(xmlString: string, path: string, encoding: string) { + constructor(xmlString: string, path: string, encoding: BufferEncoding ) { super(); this._warnings = []; this._numberOfTransUnitsWithMissingId = 0; this.initializeFromContent(xmlString, path, encoding); } - private initializeFromContent(xmlString: string, path: string, encoding: string): XliffFile { + private initializeFromContent(xmlString: string, path: string, encoding: BufferEncoding ): XliffFile { this.parseContent(xmlString, path, encoding); const xliffList = this._parsedDocument.getElementsByTagName('xliff'); if (xliffList.length !== 1) { diff --git a/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.spec.ts b/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.spec.ts index 4c6fb10..07ea221 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.spec.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.spec.ts @@ -16,7 +16,7 @@ describe('ngx-i18nsupport-lib XLIFF 2.0 test spec', () => { const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8'; /** * Helper function to read Xliff 2.0 from File diff --git a/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.ts b/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.ts index 5e2df2c..6071938 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xliff2-file.ts @@ -24,14 +24,14 @@ export class Xliff2File extends AbstractTranslationMessagesFile implements ITran * This is read from the file, but if you know it before, you can avoid reading the file twice. * @return xliff file */ - constructor(xmlString: string, path: string, encoding: string) { + constructor(xmlString: string, path: string, encoding: BufferEncoding ) { super(); this._warnings = []; this._numberOfTransUnitsWithMissingId = 0; this.initializeFromContent(xmlString, path, encoding); } - private initializeFromContent(xmlString: string, path: string, encoding: string): Xliff2File { + private initializeFromContent(xmlString: string, path: string, encoding: BufferEncoding ): Xliff2File { this.parseContent(xmlString, path, encoding); const xliffList = this._parsedDocument.getElementsByTagName('xliff'); if (xliffList.length !== 1) { diff --git a/projects/ngx-i18nsupport-lib/src/impl/xmb-file.spec.ts b/projects/ngx-i18nsupport-lib/src/impl/xmb-file.spec.ts index 537b986..880aba0 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xmb-file.spec.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xmb-file.spec.ts @@ -11,7 +11,7 @@ describe('ngx-i18nsupport-lib xmb test spec', () => { const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8'; /** * Helper function to read Xmb from File diff --git a/projects/ngx-i18nsupport-lib/src/impl/xmb-file.ts b/projects/ngx-i18nsupport-lib/src/impl/xmb-file.ts index 0ecb24f..4d8f8f2 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xmb-file.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xmb-file.ts @@ -36,7 +36,7 @@ export class XmbFile extends AbstractTranslationMessagesFile implements ITransla */ constructor( private _translationMessageFileFactory: ITranslationMessagesFileFactory, - xmlString: string, path: string, encoding: string) { + xmlString: string, path: string, encoding: BufferEncoding ) { super(); this._warnings = []; @@ -44,7 +44,7 @@ export class XmbFile extends AbstractTranslationMessagesFile implements ITransla this.initializeFromContent(xmlString, path, encoding); } - private initializeFromContent(xmlString: string, path: string, encoding: string): XmbFile { + private initializeFromContent(xmlString: string, path: string, encoding: BufferEncoding ): XmbFile { this.parseContent(xmlString, path, encoding); if (this._parsedDocument.getElementsByTagName('messagebundle').length !== 1) { throw new Error(format('File "%s" seems to be no xmb file (should contain a messagebundle element)', path)); diff --git a/projects/ngx-i18nsupport-lib/src/impl/xtb-file.spec.ts b/projects/ngx-i18nsupport-lib/src/impl/xtb-file.spec.ts index 0891680..a36c540 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xtb-file.spec.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xtb-file.spec.ts @@ -1,5 +1,11 @@ -import {TranslationMessagesFileFactory, ITranslationMessagesFile, ITransUnit, INormalizedMessage, - STATE_NEW, STATE_FINAL} from '../api/index'; +import { + INormalizedMessage, + ITranslationMessagesFile, + ITransUnit, + STATE_FINAL, + STATE_NEW, + TranslationMessagesFileFactory +} from '../api/index'; import * as fs from 'fs'; import {DOMParser} from 'xmldom'; import {DOMUtilities} from './dom-utilities'; @@ -13,7 +19,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8' as BufferEncoding; /** * Helper function to read Xtb from 2 Files, the xtb and the master @@ -221,7 +227,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(tu.sourceReferences()[0].linenumber).toBe(7); }); - it ('should run through 3 different states while translating', () => { + it('should run through 3 different states while translating', () => { const file: ITranslationMessagesFile = readFile(TRANSLATION_EN_XTB, MASTER_DE_XMB); const tu: ITransUnit = file.transUnitWithId(ID_MY_FIRST); expect(tu).toBeTruthy(); @@ -241,7 +247,11 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(tu.supportsSetSourceReferences()).toBeFalsy(); tu.setSourceReferences([{sourcefile: 'x', linenumber: 1}]); expect(tu.sourceReferences().length).toBe(2); // shall be unchanged - const masterContent = {xmlContent: fs.readFileSync(MASTER_DE_XMB, ENCODING), path: MASTER_DE_XMB, encoding: 'UTF-8'}; + const masterContent = { + xmlContent: fs.readFileSync(MASTER_DE_XMB, ENCODING), + path: MASTER_DE_XMB, + encoding: 'utf-8' as BufferEncoding + }; const file2: ITranslationMessagesFile = TranslationMessagesFileFactory.fromUnknownFormatFileContent(file.editedContent(), null, null, masterContent); const tu2: ITransUnit = file2.transUnitWithId(ID_WITH_TWO_SOURCEREFS); @@ -258,7 +268,11 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(tu).toBeTruthy(); expect(tu.sourceReferences().length).toBe(2); tu.translate('a translated value'); - const masterContent = {xmlContent: fs.readFileSync(MASTER_DE_XMB, ENCODING), path: MASTER_DE_XMB, encoding: 'UTF-8'}; + const masterContent = { + xmlContent: fs.readFileSync(MASTER_DE_XMB, ENCODING), + path: MASTER_DE_XMB, + encoding: 'utf-8' as BufferEncoding + }; const file2: ITranslationMessagesFile = TranslationMessagesFileFactory.fromUnknownFormatFileContent(file.editedContent(), null, null, masterContent); const tu2: ITransUnit = file2.transUnitWithId(ID_WITH_TWO_SOURCEREFS); @@ -317,7 +331,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(tu2).toBeFalsy(); // should not exist any more }); - it ('should copy a transunit from file a to file b', () => { + it('should copy a transunit from file a to file b', () => { const file: ITranslationMessagesFile = readUnknownFormatFile(MASTER_1_XMB); const tu: ITransUnit = file.transUnitWithId(ID_TO_MERGE); expect(tu).toBeTruthy(); @@ -331,7 +345,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(targetTu.targetContent()).toBe('Test for merging units'); }); - it ('should not copy source to target for non default lang if not wanted', () => { + it('should not copy source to target for non default lang if not wanted', () => { const file: ITranslationMessagesFile = readUnknownFormatFile(MASTER_1_XMB); const tu: ITransUnit = file.transUnitWithId(ID_UNTRANSLATED_DESCRIPTION); expect(tu).toBeTruthy(); @@ -345,7 +359,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(tu2.targetContent()).toBeFalsy(); }); - it ('should copy a transunit from file a to file b and leave content blank (xliffmerge #103)', () => { + it('should copy a transunit from file a to file b and leave content blank (xliffmerge #103)', () => { const file: ITranslationMessagesFile = readUnknownFormatFile(MASTER_1_XMB); const tu: ITransUnit = file.transUnitWithId(ID_TO_MERGE); expect(tu).toBeTruthy(); @@ -360,7 +374,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(targetTu.targetContent()).toBe(''); }); - it ('should copy a transunit to a specified position (#53)', () => { + it('should copy a transunit to a specified position (#53)', () => { const file: ITranslationMessagesFile = readUnknownFormatFile(MASTER_1_XMB); const tu: ITransUnit = file.transUnitWithId(ID_TO_MERGE); expect(tu).toBeTruthy(); @@ -381,7 +395,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(targetTu.targetContent()).toBe('Test for merging units'); }); - it ('should copy a transunit to first position (#53)', () => { + it('should copy a transunit to first position (#53)', () => { const file: ITranslationMessagesFile = readUnknownFormatFile(MASTER_1_XMB); const tu: ITransUnit = file.transUnitWithId(ID_TO_MERGE); expect(tu).toBeTruthy(); @@ -400,7 +414,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(targetTu.targetContent()).toBe('Test for merging units'); }); - it ('should copy a transunit from file a to file b and set a praefix and suffix', () => { + it('should copy a transunit from file a to file b and set a praefix and suffix', () => { const file: ITranslationMessagesFile = readUnknownFormatFile(MASTER_1_XMB); const tu: ITransUnit = file.transUnitWithId(ID_TO_MERGE); expect(tu).toBeTruthy(); @@ -416,7 +430,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(targetTu.targetContent()).toBe('%%Test for merging units!!'); }); - it ('should copy a transunit from file a to file b, but should not set a praefix and suffix for ICU messages', () => { + it('should copy a transunit from file a to file b, but should not set a praefix and suffix for ICU messages', () => { const file: ITranslationMessagesFile = readUnknownFormatFile(MASTER_1_XMB); const tu: ITransUnit = file.transUnitWithId(ID_ICU_SELECT_2); expect(tu).toBeTruthy(); @@ -433,7 +447,7 @@ describe('ngx-i18nsupport-lib xtb test spec', () => { expect(targetTu.targetContent()).not.toContain('!!'); }); - it ('should translate using NormalizedMessage (plain text case, no placeholders, no markup)', () => { + it('should translate using NormalizedMessage (plain text case, no placeholders, no markup)', () => { const file: ITranslationMessagesFile = readFile(TRANSLATION_EN_XTB, MASTER_DE_XMB); const tu: ITransUnit = file.transUnitWithId(ID_MY_FIRST); expect(tu).toBeTruthy(); diff --git a/projects/ngx-i18nsupport-lib/src/impl/xtb-file.ts b/projects/ngx-i18nsupport-lib/src/impl/xtb-file.ts index ff840df..5c61faa 100644 --- a/projects/ngx-i18nsupport-lib/src/impl/xtb-file.ts +++ b/projects/ngx-i18nsupport-lib/src/impl/xtb-file.ts @@ -31,16 +31,16 @@ export class XtbFile extends AbstractTranslationMessagesFile implements ITransla * @return XmbFile */ constructor(private _translationMessageFileFactory: ITranslationMessagesFileFactory, - xmlString: string, path: string, encoding: string, - optionalMaster?: { xmlContent: string, path: string, encoding: string }) { + xmlString: string, path: string, encoding: BufferEncoding , + optionalMaster?: { xmlContent: string, path: string, encoding: BufferEncoding }) { super(); this._warnings = []; this._numberOfTransUnitsWithMissingId = 0; this.initializeFromContent(xmlString, path, encoding, optionalMaster); } - private initializeFromContent(xmlString: string, path: string, encoding: string, - optionalMaster?: { xmlContent: string, path: string, encoding: string }): XtbFile { + private initializeFromContent(xmlString: string, path: string, encoding: BufferEncoding , + optionalMaster?: { xmlContent: string, path: string, encoding: BufferEncoding }): XtbFile { this.parseContent(xmlString, path, encoding); if (this._parsedDocument.getElementsByTagName('translationbundle').length !== 1) { throw new Error(format('File "%s" seems to be no xtb file (should contain a translationbundle element)', path)); diff --git a/projects/tiny-translator/src/app/model/translation-file.ts b/projects/tiny-translator/src/app/model/translation-file.ts index af66c53..cdd8729 100644 --- a/projects/tiny-translator/src/app/model/translation-file.ts +++ b/projects/tiny-translator/src/app/model/translation-file.ts @@ -139,7 +139,7 @@ export class TranslationFile { newInstance._explicitSourceLanguage = deserializedObject.explicitSourceLanguage; try { const encoding = null; // unknown, lib can find it - let optionalMaster: {xmlContent: string, path: string, encoding: string} = null; + let optionalMaster: {xmlContent: string, path: string, encoding: BufferEncoding } = null; if (deserializedObject.master) { newInstance._master = serializationService.deserializeIFile(deserializedObject.master); optionalMaster = { diff --git a/projects/tooling/src/schematics/src/common/common-testing_spec.ts b/projects/tooling/src/schematics/src/common/common-testing_spec.ts index fb8778b..3f608d0 100644 --- a/projects/tooling/src/schematics/src/common/common-testing_spec.ts +++ b/projects/tooling/src/schematics/src/common/common-testing_spec.ts @@ -43,7 +43,7 @@ export function readAsJson(tree: UnitTestTree, path: string): T { if (!content) { throw new Error('file ' + path + ' not found in tree'); } - const contentString = content.toString('UTF-8'); + const contentString = content.toString('utf-8'); return JSON.parse(contentString) as T; } diff --git a/projects/tooling/src/schematics/src/common/package-json-snapshot.ts b/projects/tooling/src/schematics/src/common/package-json-snapshot.ts index bac2721..ea16cfc 100644 --- a/projects/tooling/src/schematics/src/common/package-json-snapshot.ts +++ b/projects/tooling/src/schematics/src/common/package-json-snapshot.ts @@ -195,7 +195,7 @@ export class PackageJsonSnapshot { if (!content) { throw new SchematicsException(`${packageJsonPath} does not exist`); } - const contentString = content.toString('UTF-8'); + const contentString = content.toString('utf-8'); return JSON.parse(contentString) as IPackageJson; } } diff --git a/projects/tooling/src/schematics/src/common/workspace-snapshot.ts b/projects/tooling/src/schematics/src/common/workspace-snapshot.ts index b3d7cb9..11b1e88 100644 --- a/projects/tooling/src/schematics/src/common/workspace-snapshot.ts +++ b/projects/tooling/src/schematics/src/common/workspace-snapshot.ts @@ -216,7 +216,7 @@ export class WorkspaceSnaphot { if (!content) { return null; } - const contentString = content.toString('UTF-8'); + const contentString = content.toString('utf-8'); const profileContent = JSON.parse(contentString) as {xliffmergeOptions: IXliffMergeOptions}; return { xliffmergeOptions: profileContent.xliffmergeOptions, diff --git a/projects/tooling/src/schematics/src/common/xliffmerge-config-json-snapshot.ts b/projects/tooling/src/schematics/src/common/xliffmerge-config-json-snapshot.ts index 532dc61..26400a7 100644 --- a/projects/tooling/src/schematics/src/common/xliffmerge-config-json-snapshot.ts +++ b/projects/tooling/src/schematics/src/common/xliffmerge-config-json-snapshot.ts @@ -73,7 +73,7 @@ export class XliffmergeConfigJsonSnapshot { } throw new SchematicsException(msg); } - const contentString = content.toString('UTF-8'); + const contentString = content.toString('utf-8'); return JSON.parse(contentString) as IConfigFile; } } diff --git a/projects/xliffmerge/ng-package.json b/projects/xliffmerge/ng-package.json index 6752e81..af69c7e 100644 --- a/projects/xliffmerge/ng-package.json +++ b/projects/xliffmerge/ng-package.json @@ -2,14 +2,13 @@ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", "dest": "../../dist/ngx-i18nsupport", "lib": { - "entryFile": "src/public_api.ts", - "umdModuleIds": { - } + "entryFile": "src/public_api.ts" }, - "whitelistedNonPeerDependencies": [ + + "allowedNonPeerDependencies": [ "@ngx-i18nsupport/ngx-i18nsupport-lib", "chalk", "he", "request" ] -} \ No newline at end of file +} diff --git a/projects/xliffmerge/package.json b/projects/xliffmerge/package.json index f68d6e7..9b476da 100644 --- a/projects/xliffmerge/package.json +++ b/projects/xliffmerge/package.json @@ -40,15 +40,13 @@ }, "homepage": "https://github.com/martinroob/ngx-i18nsupport#readme", "dependencies": { + "@ngx-i18nsupport/ngx-i18nsupport-lib": "^1.12.1", "chalk": "^2.4.1", "he": "^1.1.1", - "@ngx-i18nsupport/ngx-i18nsupport-lib": "^1.12.1", "request": "^2.85.0" }, - "devDependencies": { - }, - "peerDependencies": { - }, + "devDependencies": {}, + "peerDependencies": {}, "xliffmergeOptions": { "description": "just for some tests here" } diff --git a/projects/xliffmerge/src/common/file-util.ts b/projects/xliffmerge/src/common/file-util.ts index 17e98fb..1f547d9 100644 --- a/projects/xliffmerge/src/common/file-util.ts +++ b/projects/xliffmerge/src/common/file-util.ts @@ -23,7 +23,7 @@ export class FileUtil { * @param encoding encoding * @return content of file */ - public static read(filename: string, encoding: string) { + public static read(filename: string, encoding: BufferEncoding) { return fs.readFileSync(filename, encoding); } @@ -33,7 +33,7 @@ export class FileUtil { * @param newContent newContent * @param encoding encoding */ - public static replaceContent(filename: string, newContent: string, encoding: string) { + public static replaceContent(filename: string, newContent: string, encoding: BufferEncoding) { fs.writeFileSync(filename, newContent, {encoding: encoding}); } @@ -59,9 +59,9 @@ export class FileUtil { */ public static deleteFolderRecursive(path: string) { let files = []; - if (fs.existsSync(path) ) { + if (fs.existsSync(path)) { files = fs.readdirSync(path); - files.forEach(function(file) { + files.forEach(function (file) { const curPath = path + '/' + file; if (fs.lstatSync(curPath).isDirectory()) { // recurse FileUtil.deleteFolderRecursive(curPath); @@ -80,9 +80,9 @@ export class FileUtil { */ public static deleteFolderContentRecursive(path: string) { let files = []; - if (fs.existsSync(path) ) { + if (fs.existsSync(path)) { files = fs.readdirSync(path); - files.forEach(function(file) { + files.forEach(function (file) { const curPath = path + '/' + file; if (fs.lstatSync(curPath).isDirectory()) { // recurse FileUtil.deleteFolderRecursive(curPath); diff --git a/projects/xliffmerge/src/common/writer-to-string.ts b/projects/xliffmerge/src/common/writer-to-string.ts index d005cd9..48a21c1 100644 --- a/projects/xliffmerge/src/common/writer-to-string.ts +++ b/projects/xliffmerge/src/common/writer-to-string.ts @@ -16,7 +16,7 @@ export class WriterToString extends Writable { this.resultString = ''; } - public _write(chunk: any, encoding: string, callback: Function): void { + public _write(chunk: any, encoding: BufferEncoding, callback: Function): void { let chunkString; if (isString(chunk)) { chunkString = chunk; diff --git a/projects/xliffmerge/src/xliffmerge/i-xliff-merge-options.ts b/projects/xliffmerge/src/xliffmerge/i-xliff-merge-options.ts index cb76fbd..270b556 100644 --- a/projects/xliffmerge/src/xliffmerge/i-xliff-merge-options.ts +++ b/projects/xliffmerge/src/xliffmerge/i-xliff-merge-options.ts @@ -31,7 +31,7 @@ export interface IXliffMergeOptions { i18nBaseFile?: string; // Basename for i18n input and output, default is 'messages' i18nFile?: string; // master file, if not absolute, it is relative to srcDir i18nFormat?: string; // xlf or xmb - encoding?: string; // encoding to write xml + encoding?: BufferEncoding; // encoding to write xml genDir?: string; // directory, where the files are written to angularCompilerOptions?: { genDir?: string; // same as genDir, just to be compatible with ng-xi18n diff --git a/projects/xliffmerge/src/xliffmerge/ngx-translate-extractor.ts b/projects/xliffmerge/src/xliffmerge/ngx-translate-extractor.ts index 5f29031..d6776e5 100644 --- a/projects/xliffmerge/src/xliffmerge/ngx-translate-extractor.ts +++ b/projects/xliffmerge/src/xliffmerge/ngx-translate-extractor.ts @@ -61,7 +61,7 @@ export class NgxTranslateExtractor { public extractTo(outputFile: string) { const translations: NgxTranslations = this.toNgxTranslations(this.extract()); if (translations && Object.keys(translations).length > 0) { - FileUtil.replaceContent(outputFile, JSON.stringify(translations, null, 4), 'UTF-8'); + FileUtil.replaceContent(outputFile, JSON.stringify(translations, null, 4), 'utf-8'); } else { if (FileUtil.exists(outputFile)) { FileUtil.deleteFile(outputFile); diff --git a/projects/xliffmerge/src/xliffmerge/translation-messages-file-reader.ts b/projects/xliffmerge/src/xliffmerge/translation-messages-file-reader.ts index 65b175b..97e9dc9 100644 --- a/projects/xliffmerge/src/xliffmerge/translation-messages-file-reader.ts +++ b/projects/xliffmerge/src/xliffmerge/translation-messages-file-reader.ts @@ -1,7 +1,7 @@ /** * Created by roobm on 21.03.2017. */ -import {TranslationMessagesFileFactory, ITranslationMessagesFile} from '@ngx-i18nsupport/ngx-i18nsupport-lib'; +import {ITranslationMessagesFile, TranslationMessagesFileFactory} from '@ngx-i18nsupport/ngx-i18nsupport-lib'; import {FileUtil} from '../common/file-util'; import {XmlReader} from './xml-reader'; @@ -20,7 +20,7 @@ export class TranslationMessagesFileReader { */ public static fromFile(i18nFormat: string, path: string, - encoding: string, + encoding: BufferEncoding, optionalMasterFilePath?: string): ITranslationMessagesFile { const xmlContent = XmlReader.readXmlFileContent(path, encoding); const optionalMaster = TranslationMessagesFileReader.masterFileContent(optionalMasterFilePath, encoding); @@ -35,7 +35,7 @@ export class TranslationMessagesFileReader { * @return XliffFile */ public static fromUnknownFormatFile(path: string, - encoding: string, + encoding: BufferEncoding, optionalMasterFilePath?: string): ITranslationMessagesFile { const xmlContent = XmlReader.readXmlFileContent(path, encoding); const optionalMaster = TranslationMessagesFileReader.masterFileContent(optionalMasterFilePath, encoding); @@ -48,8 +48,8 @@ export class TranslationMessagesFileReader { * @param encoding encoding * @return content and encoding of file */ - private static masterFileContent(optionalMasterFilePath: string, encoding: string) - : {xmlContent: string, path: string, encoding: string} { + private static masterFileContent(optionalMasterFilePath: string, encoding: BufferEncoding) + : { xmlContent: string, path: string, encoding: BufferEncoding } { if (optionalMasterFilePath) { const masterXmlContent = XmlReader.readXmlFileContent(optionalMasterFilePath, encoding); return { @@ -71,7 +71,7 @@ export class TranslationMessagesFileReader { * Default is false. */ public static save(messagesFile: ITranslationMessagesFile, beautifyOutput?: boolean) { - FileUtil.replaceContent(messagesFile.filename(), messagesFile.editedContent(beautifyOutput), messagesFile.encoding()); + FileUtil.replaceContent(messagesFile.filename(), messagesFile.editedContent(beautifyOutput), messagesFile.encoding() as BufferEncoding); } } diff --git a/projects/xliffmerge/src/xliffmerge/xlf12-merge.spec.ts b/projects/xliffmerge/src/xliffmerge/xlf12-merge.spec.ts index f6030aa..b1fcfd6 100644 --- a/projects/xliffmerge/src/xliffmerge/xlf12-merge.spec.ts +++ b/projects/xliffmerge/src/xliffmerge/xlf12-merge.spec.ts @@ -25,7 +25,7 @@ describe('XliffMerge XLIFF 1.2 format tests', () => { const WORKDIR = 'test/work/'; const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8'; /** * Helper function to read Xliff from File @@ -854,10 +854,10 @@ describe('XliffMerge XLIFF 1.2 format tests', () => { FileUtil.copy(SRCDIR + 'issue128master.xlf', MASTER); const langfileName = WORKDIR + 'messages.en.xlf'; FileUtil.copy(SRCDIR + 'issue128translated.xlf', langfileName); - const originalContent = FileUtil.read(langfileName, 'UTF-8'); + const originalContent = FileUtil.read(langfileName, 'utf-8'); const contentWithoutCRLF = originalContent.replace(/[\n\r]/g, ''); expect(originalContent).not.toBe(contentWithoutCRLF); - FileUtil.replaceContent(langfileName, contentWithoutCRLF, 'UTF-8'); + FileUtil.replaceContent(langfileName, contentWithoutCRLF, 'utf-8'); const ws: WriterToString = new WriterToString(); const commandOut = new CommandOutput(ws); const profileContent: IConfigFile = { @@ -1184,7 +1184,7 @@ describe('XliffMerge XLIFF 1.2 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.myapp).toBeTruthy(); @@ -1212,7 +1212,7 @@ describe('XliffMerge XLIFF 1.2 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.placeholders).toBeTruthy(); @@ -1240,7 +1240,7 @@ describe('XliffMerge XLIFF 1.2 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.embeddedhtml).toBeTruthy(); @@ -1290,7 +1290,7 @@ describe('XliffMerge XLIFF 1.2 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.dateservice.monday).toBe('Montag'); @@ -1319,7 +1319,7 @@ describe('XliffMerge XLIFF 1.2 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.dateservice.monday).toBe('Montag'); diff --git a/projects/xliffmerge/src/xliffmerge/xlf20-merge.spec.ts b/projects/xliffmerge/src/xliffmerge/xlf20-merge.spec.ts index ad8f7d6..222f958 100644 --- a/projects/xliffmerge/src/xliffmerge/xlf20-merge.spec.ts +++ b/projects/xliffmerge/src/xliffmerge/xlf20-merge.spec.ts @@ -24,7 +24,7 @@ describe('XliffMerge XLIFF 2.0 format tests', () => { const WORKDIR = 'test/work/'; const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8'; /** * Helper function to read XLIFF 2.0 from File @@ -737,7 +737,7 @@ describe('XliffMerge XLIFF 2.0 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.myapp).toBeTruthy(); @@ -766,7 +766,7 @@ describe('XliffMerge XLIFF 2.0 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.placeholders).toBeTruthy(); @@ -795,7 +795,7 @@ describe('XliffMerge XLIFF 2.0 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.embeddedhtml).toBeTruthy(); @@ -825,7 +825,7 @@ describe('XliffMerge XLIFF 2.0 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.dateservice.monday).toBe('Montag'); @@ -855,7 +855,7 @@ describe('XliffMerge XLIFF 2.0 format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.dateservice.monday).toBe('Montag'); diff --git a/projects/xliffmerge/src/xliffmerge/xliff-merge-parameters.ts b/projects/xliffmerge/src/xliffmerge/xliff-merge-parameters.ts index 19407ac..a90dc1e 100644 --- a/projects/xliffmerge/src/xliffmerge/xliff-merge-parameters.ts +++ b/projects/xliffmerge/src/xliffmerge/xliff-merge-parameters.ts @@ -28,7 +28,7 @@ export class XliffMergeParameters { private _i18nBaseFile: string; private _i18nFile: string; private _i18nFormat: string; - private _encoding: string; + private _encoding: BufferEncoding ; private _genDir: string; private _languages: string[]; private _removeUnusedIds: boolean; @@ -71,7 +71,7 @@ export class XliffMergeParameters { private static readProfileCandidate(profilePath: string): IConfigFile { let content: string; try { - content = fs.readFileSync(profilePath, 'UTF-8'); + content = fs.readFileSync(profilePath, 'utf-8'); } catch (err) { return null; } @@ -134,7 +134,7 @@ export class XliffMergeParameters { } let content: string; try { - content = fs.readFileSync(profilePath, 'UTF-8'); + content = fs.readFileSync(profilePath, 'utf-8'); } catch (err) { this.errorsFound.push(new XliffMergeError('could not read profile "' + profilePath + '"')); return null; @@ -463,8 +463,8 @@ export class XliffMergeParameters { * The encoding used to write new XLIFF-files. * @return encoding */ - public encoding(): string { - return this._encoding ? this._encoding : 'UTF-8'; + public encoding(): BufferEncoding { + return this._encoding ? this._encoding : 'utf-8'; } /** diff --git a/projects/xliffmerge/src/xliffmerge/xliff-merge.ts b/projects/xliffmerge/src/xliffmerge/xliff-merge.ts index ad596be..7c610f0 100644 --- a/projects/xliffmerge/src/xliffmerge/xliff-merge.ts +++ b/projects/xliffmerge/src/xliffmerge/xliff-merge.ts @@ -215,7 +215,7 @@ export class XliffMerge { this.master = TranslationMessagesFileReader.fromFile( this.parameters.i18nFormat(), this.parameters.i18nFile(), - this.parameters.encoding()); + this.parameters.encoding() as BufferEncoding); this.master.warnings().forEach((warning: string) => { this.commandOutput.warn(warning); }); diff --git a/projects/xliffmerge/src/xliffmerge/xmb-merge.spec.ts b/projects/xliffmerge/src/xliffmerge/xmb-merge.spec.ts index 2f9f75f..2507ba3 100644 --- a/projects/xliffmerge/src/xliffmerge/xmb-merge.spec.ts +++ b/projects/xliffmerge/src/xliffmerge/xmb-merge.spec.ts @@ -23,7 +23,7 @@ describe('XliffMerge XMB format tests', () => { const WORKDIR = 'test/work/'; const SRCDIR = 'test/testdata/i18n/'; - const ENCODING = 'UTF-8'; + const ENCODING = 'utf-8'; /** * Helper function to read Xmb from File @@ -491,7 +491,7 @@ describe('XliffMerge XMB format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.myapp).toBeTruthy(); @@ -521,7 +521,7 @@ describe('XliffMerge XMB format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.placeholders).toBeTruthy(); @@ -550,7 +550,7 @@ describe('XliffMerge XMB format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.embeddedhtml).toBeTruthy(); @@ -602,7 +602,7 @@ describe('XliffMerge XMB format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.dateservice.monday).toBe('Montag'); @@ -632,7 +632,7 @@ describe('XliffMerge XMB format tests', () => { expect(ws.writtenData()).not.toContain('ERROR'); const translationJsonFilename = xliffMergeCmd.generatedNgxTranslateFile('de'); expect(FileUtil.exists(translationJsonFilename)).toBeTruthy(); - const fileContent = FileUtil.read(translationJsonFilename, 'UTF-8'); + const fileContent = FileUtil.read(translationJsonFilename, 'utf-8'); const translation: any = JSON.parse(fileContent); expect(translation).toBeTruthy(); expect(translation.dateservice.monday).toBe('Montag'); diff --git a/projects/xliffmerge/src/xliffmerge/xml-reader.ts b/projects/xliffmerge/src/xliffmerge/xml-reader.ts index 75ba9d5..97b93b4 100644 --- a/projects/xliffmerge/src/xliffmerge/xml-reader.ts +++ b/projects/xliffmerge/src/xliffmerge/xml-reader.ts @@ -5,7 +5,7 @@ import {FileUtil} from '../common/file-util'; */ export class XmlReader { - static DEFAULT_ENCODING = 'UTF-8'; + static DEFAULT_ENCODING = 'utf-8' as BufferEncoding; /** * Read an xml-File. @@ -14,12 +14,12 @@ export class XmlReader { * This is read from the file, but if you know it before, you can avoid reading the file twice. * @return file content and encoding found in the file. */ - public static readXmlFileContent(path: string, encoding?: string): {content: string, encoding: string} { + public static readXmlFileContent(path: string, encoding?: BufferEncoding): {content: string, encoding: BufferEncoding } { if (!encoding) { - encoding = XmlReader.DEFAULT_ENCODING; + encoding = XmlReader.DEFAULT_ENCODING as BufferEncoding; } let content: string = FileUtil.read(path, encoding); - const foundEncoding = XmlReader.encodingFromXml(content); + const foundEncoding = XmlReader.encodingFromXml(content) as BufferEncoding; if (foundEncoding !== encoding) { // read again with the correct encoding content = FileUtil.read(path, foundEncoding); diff --git a/src/polyfills.ts b/src/polyfills.ts index 20fe40f..28ee489 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -1,3 +1,7 @@ +/*************************************************************************************************** + * Load `$localize` onto the global scope - used if i18n tags appear in Angular templates. + */ +import '@angular/localize/init'; /** * This file includes polyfills needed by Angular and is loaded before the app. * You can add your own extra polyfills to this file.