diff --git a/modules/@angular/compiler-cli/integrationtest/test/i18n_spec.ts b/modules/@angular/compiler-cli/integrationtest/test/i18n_spec.ts index 2f4af37884..019b354ce9 100644 --- a/modules/@angular/compiler-cli/integrationtest/test/i18n_spec.ts +++ b/modules/@angular/compiler-cli/integrationtest/test/i18n_spec.ts @@ -68,7 +68,7 @@ describe('template i18n extraction output', () => { const genDir = 'out'; it('should extract i18n messages as xmb', () => { - const xmbOutput = path.join(outDir, 'messages.xmb'); + const xmbOutput = path.join(outDir, 'custom_file.xmb'); expect(fs.existsSync(xmbOutput)).toBeTruthy(); const xmb = fs.readFileSync(xmbOutput, {encoding: 'utf-8'}); expect(xmb).toEqual(EXPECTED_XMB); diff --git a/modules/@angular/compiler-cli/integrationtest/test/test_ngtools_api.ts b/modules/@angular/compiler-cli/integrationtest/test/test_ngtools_api.ts index d1ad408474..5b81e6c075 100644 --- a/modules/@angular/compiler-cli/integrationtest/test/test_ngtools_api.ts +++ b/modules/@angular/compiler-cli/integrationtest/test/test_ngtools_api.ts @@ -132,6 +132,7 @@ function i18nTest() { angularCompilerOptions: config.ngOptions, i18nFormat: 'xlf', locale: null, + outFile: null, readResource: (fileName: string) => { readResources.push(fileName); return hostContext.readResource(fileName); diff --git a/modules/@angular/compiler-cli/src/extract_i18n.ts b/modules/@angular/compiler-cli/src/extract_i18n.ts index 9582941104..9f52a123b4 100644 --- a/modules/@angular/compiler-cli/src/extract_i18n.ts +++ b/modules/@angular/compiler-cli/src/extract_i18n.ts @@ -23,7 +23,7 @@ function extract( ngOptions: tsc.AngularCompilerOptions, cliOptions: tsc.I18nExtractionCliOptions, program: ts.Program, host: ts.CompilerHost): Promise { return Extractor.create(ngOptions, program, host, cliOptions.locale) - .extract(cliOptions.i18nFormat); + .extract(cliOptions.i18nFormat, cliOptions.outFile); } // Entry point diff --git a/modules/@angular/compiler-cli/src/extractor.ts b/modules/@angular/compiler-cli/src/extractor.ts index 25db7f1132..1ff09b6416 100644 --- a/modules/@angular/compiler-cli/src/extractor.ts +++ b/modules/@angular/compiler-cli/src/extractor.ts @@ -27,7 +27,7 @@ export class Extractor { public host: ts.CompilerHost, private ngCompilerHost: CompilerHost, private program: ts.Program) {} - extract(formatName: string): Promise { + extract(formatName: string, outFile: string|null): Promise { // Checks the format and returns the extension const ext = this.getExtension(formatName); @@ -35,7 +35,8 @@ export class Extractor { return promiseBundle.then(bundle => { const content = this.serialize(bundle, ext); - const dstPath = path.join(this.options.genDir, `messages.${ext}`); + const dstFile = outFile || `messages.${ext}`; + const dstPath = path.join(this.options.genDir, dstFile); this.host.writeFile(dstPath, content, false); }); } diff --git a/modules/@angular/compiler-cli/src/ngtools_api.ts b/modules/@angular/compiler-cli/src/ngtools_api.ts index f86463a168..4a698f7c0d 100644 --- a/modules/@angular/compiler-cli/src/ngtools_api.ts +++ b/modules/@angular/compiler-cli/src/ngtools_api.ts @@ -62,6 +62,7 @@ export interface NgTools_InternalApi_NG2_ExtractI18n_Options { readResource: (fileName: string) => Promise; // Every new property under this line should be optional. locale?: string; + outFile?: string; } /** @@ -147,6 +148,6 @@ export class NgTools_InternalApi_NG_2 { const extractor = Extractor.create( options.angularCompilerOptions, options.program, options.host, locale, hostContext); - return extractor.extract(options.i18nFormat); + return extractor.extract(options.i18nFormat, options.outFile || null); } } diff --git a/scripts/ci-lite/offline_compiler_test.sh b/scripts/ci-lite/offline_compiler_test.sh index 107d308e16..cd0ada6e8d 100755 --- a/scripts/ci-lite/offline_compiler_test.sh +++ b/scripts/ci-lite/offline_compiler_test.sh @@ -49,7 +49,7 @@ cp -v package.json $TMP ./node_modules/.bin/ngc -p tsconfig-build.json --i18nFile=src/messages.fi.xlf --locale=fi --i18nFormat=xlf ./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xlf --locale=fr - ./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xmb + ./node_modules/.bin/ng-xi18n -p tsconfig-xi18n.json --i18nFormat=xmb --outFile=custom_file.xmb node test/test_summaries.js node test/test_ngtools_api.js diff --git a/tools/@angular/tsc-wrapped/src/cli_options.ts b/tools/@angular/tsc-wrapped/src/cli_options.ts index acd1db988b..c379ee5c94 100644 --- a/tools/@angular/tsc-wrapped/src/cli_options.ts +++ b/tools/@angular/tsc-wrapped/src/cli_options.ts @@ -11,13 +11,19 @@ export class CliOptions { } export class I18nExtractionCliOptions extends CliOptions { - public i18nFormat: string; - public locale: string; + i18nFormat: string|null; + locale: string|null; + outFile: string|null; - constructor({i18nFormat = null, locale = null}: {i18nFormat?: string, locale: string|null}) { + constructor({i18nFormat = null, locale = null, outFile = null}: { + i18nFormat?: string, + locale?: string, + outFile?: string, + }) { super({}); this.i18nFormat = i18nFormat; this.locale = locale; + this.outFile = outFile; } }