source: trip-planner-front/node_modules/@angular/compiler-cli/src/transformers/i18n.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 8.3 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8(function (factory) {
9 if (typeof module === "object" && typeof module.exports === "object") {
10 var v = factory(require, exports);
11 if (v !== undefined) module.exports = v;
12 }
13 else if (typeof define === "function" && define.amd) {
14 define("@angular/compiler-cli/src/transformers/i18n", ["require", "exports", "@angular/compiler", "path"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.i18nSerialize = exports.i18nExtract = exports.i18nGetExtension = void 0;
20 var compiler_1 = require("@angular/compiler");
21 var path = require("path");
22 function i18nGetExtension(formatName) {
23 var format = formatName.toLowerCase();
24 switch (format) {
25 case 'xmb':
26 return 'xmb';
27 case 'xlf':
28 case 'xlif':
29 case 'xliff':
30 case 'xlf2':
31 case 'xliff2':
32 return 'xlf';
33 }
34 throw new Error("Unsupported format \"" + formatName + "\"");
35 }
36 exports.i18nGetExtension = i18nGetExtension;
37 function i18nExtract(formatName, outFile, host, options, bundle, pathResolve) {
38 if (pathResolve === void 0) { pathResolve = path.resolve; }
39 formatName = formatName || 'xlf';
40 // Checks the format and returns the extension
41 var ext = i18nGetExtension(formatName);
42 var content = i18nSerialize(bundle, formatName, options);
43 var dstFile = outFile || "messages." + ext;
44 var dstPath = pathResolve(options.outDir || options.basePath, dstFile);
45 host.writeFile(dstPath, content, false, undefined, []);
46 return [dstPath];
47 }
48 exports.i18nExtract = i18nExtract;
49 function i18nSerialize(bundle, formatName, options) {
50 var format = formatName.toLowerCase();
51 var serializer;
52 switch (format) {
53 case 'xmb':
54 serializer = new compiler_1.Xmb();
55 break;
56 case 'xliff2':
57 case 'xlf2':
58 serializer = new compiler_1.Xliff2();
59 break;
60 case 'xlf':
61 case 'xliff':
62 default:
63 serializer = new compiler_1.Xliff();
64 }
65 return bundle.write(serializer, getPathNormalizer(options.basePath));
66 }
67 exports.i18nSerialize = i18nSerialize;
68 function getPathNormalizer(basePath) {
69 // normalize source paths by removing the base path and always using "/" as a separator
70 return function (sourcePath) {
71 sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
72 return sourcePath.split(path.sep).join('/');
73 };
74 }
75});
76//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaTE4bi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyLWNsaS9zcmMvdHJhbnNmb3JtZXJzL2kxOG4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOzs7Ozs7Ozs7Ozs7O0lBRUgsOENBQWdGO0lBQ2hGLDJCQUE2QjtJQUs3QixTQUFnQixnQkFBZ0IsQ0FBQyxVQUFrQjtRQUNqRCxJQUFNLE1BQU0sR0FBRyxVQUFVLENBQUMsV0FBVyxFQUFFLENBQUM7UUFFeEMsUUFBUSxNQUFNLEVBQUU7WUFDZCxLQUFLLEtBQUs7Z0JBQ1IsT0FBTyxLQUFLLENBQUM7WUFDZixLQUFLLEtBQUssQ0FBQztZQUNYLEtBQUssTUFBTSxDQUFDO1lBQ1osS0FBSyxPQUFPLENBQUM7WUFDYixLQUFLLE1BQU0sQ0FBQztZQUNaLEtBQUssUUFBUTtnQkFDWCxPQUFPLEtBQUssQ0FBQztTQUNoQjtRQUVELE1BQU0sSUFBSSxLQUFLLENBQUMsMEJBQXVCLFVBQVUsT0FBRyxDQUFDLENBQUM7SUFDeEQsQ0FBQztJQWZELDRDQWVDO0lBRUQsU0FBZ0IsV0FBVyxDQUN2QixVQUF1QixFQUFFLE9BQW9CLEVBQU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W9ucy5iYXNlUGF0aCkpO1xufVxuXG5mdW5jdGlvbiBnZXRQYXRoTm9ybWFsaXplcihiYXNlUGF0aD86IHN0cmluZykge1xuICAvLyBub3JtYWxpemUgc291cmNlIHBhdGhzIGJ5IHJlbW92aW5nIHRoZSBiYXNlIHBhdGggYW5kIGFsd2F5cyB1c2luZyBcIi9cIiBhcyBhIHNlcGFyYXRvclxuICByZXR1cm4gKHNvdXJjZVBhdGg6IHN0cmluZykgPT4ge1xuICAgIHNvdXJjZVBhdGggPSBiYXNlUGF0aCA/IHBhdGgucmVsYXRpdmUoYmFzZVBhdGgsIHNvdXJjZVBhdGgpIDogc291cmNlUGF0aDtcbiAgICByZXR1cm4gc291cmNlUGF0aC5zcGxpdChwYXRoLnNlcCkuam9pbignLycpO1xuICB9O1xufVxuIl19
Note: See TracBrowser for help on using the repository browser.