UNPKG

4.8 kBSource Map (JSON)View Raw
1{"version":3,"file":"extract_i18n.js","sourceRoot":"","sources":["../../../../modules/@angular/compiler-cli/src/extract_i18n.ts"],"names":[],"mappings":";;AAcA,QAAO,kBAAkB,CAAC,CAAA;AAE1B,IAAY,QAAQ,WAAM,mBAAmB,CAAC,CAAA;AAC9C,IAAY,GAAG,WAAM,sBAAsB,CAAC,CAAA;AAC5C,IAAY,IAAI,WAAM,MAAM,CAAC,CAAA;AAG7B,0BAAwB,aAAa,CAAC,CAAA;AAEtC,iBACI,SAAqC,EAAE,UAAwC,EAC/E,OAAmB,EAAE,IAAqB;IAC5C,IAAM,cAAc,GAA4B;QAC9C,GAAG,EAAE,UAAC,CAAS;YACb,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxB,gEAAgE;gBAChE,MAAM,IAAI,KAAK,CAAC,kDAAgD,CAAG,CAAC,CAAC;YACvE,CAAC;YACD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;IACF,IAAM,SAAS,GACX,qBAAS,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAEtF,IAAM,aAAa,GAAoC,SAAS,CAAC,OAAO,EAAE,CAAC;IAE3E,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,UAAA,aAAa;QACvC,IAAI,GAAW,CAAC;QAChB,IAAI,UAA+B,CAAC;QACpC,IAAM,MAAM,GAAG,CAAC,UAAU,CAAC,UAAU,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9D,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACf,KAAK,KAAK;gBACR,GAAG,GAAG,KAAK,CAAC;gBACZ,UAAU,GAAG,I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AAK,CAAC,mBAAmB,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACT,CAAC","sourcesContent":["#!/usr/bin/env node\n/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n\n/**\n * Extract i18n messages from source code\n */\n// Must be imported first, because angular2 decorators throws on load.\nimport 'reflect-metadata';\n\nimport * as compiler from '@angular/compiler';\nimport * as tsc from '@angular/tsc-wrapped';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nimport {Extractor} from './extractor';\n\nfunction extract(\n ngOptions: tsc.AngularCompilerOptions, cliOptions: tsc.I18nExtractionCliOptions,\n program: ts.Program, host: ts.CompilerHost) {\n const resourceLoader: compiler.ResourceLoader = {\n get: (s: string) => {\n if (!host.fileExists(s)) {\n // TODO: We should really have a test for error cases like this!\n throw new Error(`Compilation failed. Resource file not found: ${s}`);\n }\n return Promise.resolve(host.readFile(s));\n }\n };\n const extractor =\n Extractor.create(ngOptions, cliOptions.i18nFormat, program, host, resourceLoader);\n\n const bundlePromise: Promise<compiler.MessageBundle> = extractor.extract();\n\n return (bundlePromise).then(messageBundle => {\n let ext: string;\n let serializer: compiler.Serializer;\n const format = (cliOptions.i18nFormat || 'xlf').toLowerCase();\n\n switch (format) {\n case 'xmb':\n ext = 'xmb';\n serializer = new compiler.Xmb();\n break;\n case 'xliff':\n case 'xlf':\n default:\n const htmlParser = new compiler.I18NHtmlParser(new compiler.HtmlParser());\n ext = 'xlf';\n serializer = new compiler.Xliff(htmlParser, compiler.DEFAULT_INTERPOLATION_CONFIG);\n break;\n }\n\n const dstPath = path.join(ngOptions.genDir, `messages.${ext}`);\n host.writeFile(dstPath, messageBundle.write(serializer), false);\n });\n}\n\n// Entry point\nif (require.main === module) {\n const args = require('minimist')(process.argv.slice(2));\n const project = args.p || args.project || '.';\n const cliOptions = new tsc.I18nExtractionCliOptions(args);\n tsc.main(project, cliOptions, extract)\n .then((exitCode: any) => process.exit(exitCode))\n .catch((e: any) => {\n console.error(e.stack);\n console.error('Extraction failed');\n process.exit(1);\n });\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file