[6a3a178] | 1 | #!/usr/bin/env node
|
---|
| 2 | /**
|
---|
| 3 | * @license
|
---|
| 4 | * Copyright Google LLC All Rights Reserved.
|
---|
| 5 | *
|
---|
| 6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 7 | * found in the LICENSE file at https://angular.io/license
|
---|
| 8 | */
|
---|
| 9 | (function (factory) {
|
---|
| 10 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
| 11 | var v = factory(require, exports);
|
---|
| 12 | if (v !== undefined) module.exports = v;
|
---|
| 13 | }
|
---|
| 14 | else if (typeof define === "function" && define.amd) {
|
---|
| 15 | define("@angular/compiler-cli/src/extract_i18n", ["require", "exports", "tslib", "reflect-metadata", "@angular/compiler-cli/src/transformers/api", "@angular/compiler-cli/src/main", "@angular/compiler-cli/src/ngtsc/file_system"], factory);
|
---|
| 16 | }
|
---|
| 17 | })(function (require, exports) {
|
---|
| 18 | "use strict";
|
---|
| 19 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 20 | exports.mainXi18n = void 0;
|
---|
| 21 | var tslib_1 = require("tslib");
|
---|
| 22 | /**
|
---|
| 23 | * Extract i18n messages from source code
|
---|
| 24 | */
|
---|
| 25 | // Must be imported first, because Angular decorators throw on load.
|
---|
| 26 | require("reflect-metadata");
|
---|
| 27 | var api = require("@angular/compiler-cli/src/transformers/api");
|
---|
| 28 | var main_1 = require("@angular/compiler-cli/src/main");
|
---|
| 29 | var file_system_1 = require("@angular/compiler-cli/src/ngtsc/file_system");
|
---|
| 30 | function mainXi18n(args, consoleError) {
|
---|
| 31 | if (consoleError === void 0) { consoleError = console.error; }
|
---|
| 32 | var config = readXi18nCommandLineAndConfiguration(args);
|
---|
| 33 | return main_1.main(args, consoleError, config, undefined, undefined, undefined);
|
---|
| 34 | }
|
---|
| 35 | exports.mainXi18n = mainXi18n;
|
---|
| 36 | function readXi18nCommandLineAndConfiguration(args) {
|
---|
| 37 | var options = {};
|
---|
| 38 | var parsedArgs = require('minimist')(args);
|
---|
| 39 | if (parsedArgs.outFile)
|
---|
| 40 | options.i18nOutFile = parsedArgs.outFile;
|
---|
| 41 | if (parsedArgs.i18nFormat)
|
---|
| 42 | options.i18nOutFormat = parsedArgs.i18nFormat;
|
---|
| 43 | if (parsedArgs.locale)
|
---|
| 44 | options.i18nOutLocale = parsedArgs.locale;
|
---|
| 45 | var config = main_1.readCommandLineAndConfiguration(args, options, [
|
---|
| 46 | 'outFile',
|
---|
| 47 | 'i18nFormat',
|
---|
| 48 | 'locale',
|
---|
| 49 | ]);
|
---|
| 50 | // only emit the i18nBundle but nothing else.
|
---|
| 51 | return tslib_1.__assign(tslib_1.__assign({}, config), { emitFlags: api.EmitFlags.I18nBundle });
|
---|
| 52 | }
|
---|
| 53 | // Entry point
|
---|
| 54 | if (require.main === module) {
|
---|
| 55 | process.title = 'Angular i18n Message Extractor (ng-xi18n)';
|
---|
| 56 | var args = process.argv.slice(2);
|
---|
| 57 | // We are running the real compiler so run against the real file-system
|
---|
| 58 | file_system_1.setFileSystem(new file_system_1.NodeJSFileSystem());
|
---|
| 59 | process.exitCode = mainXi18n(args);
|
---|
| 60 | }
|
---|
| 61 | });
|
---|
| 62 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0cmFjdF9pMThuLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXItY2xpL3NyYy9leHRyYWN0X2kxOG4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBOzs7Ozs7R0FNRzs7Ozs7Ozs7Ozs7Ozs7SUFFSDs7T0FFRztJQUNILG9FQUFvRTtJQUNwRSw0QkFBMEI7SUFDMUIsZ0VBQTBDO0lBRTFDLHVEQUE2RDtJQUM3RCwyRUFBb0U7SUFFcEUsU0FBZ0IsU0FBUyxDQUNyQixJQUFjLEVBQUUsWUFBbUQ7UUFBbkQsNkJ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