UNPKG

@awesome-fe/translate

Version:
56 lines 2.69 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AngularJsonExtractor = void 0; var extractor_1 = require("./extractor"); var html_extractor_1 = require("./html-extractor"); var AngularJsonExtractor = /** @class */ (function (_super) { __extends(AngularJsonExtractor, _super); function AngularJsonExtractor() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.htmlExtractor = new html_extractor_1.HtmlExtractor(); return _this; } AngularJsonExtractor.prototype.extractSentencePairsFromContent = function (content) { var json = JSON.parse(content); return __spreadArray(__spreadArray([], this.htmlExtractor.extractSentencePairsFromContent(json.contents), true), this.extractProperties(json), true).filter(function (it) { return !!it; }); }; AngularJsonExtractor.prototype.extractProperties = function (json) { var _this = this; return Object.entries(json).map(function (_a) { var key = _a[0], value = _a[1]; if (['title', 'desc', 'tooltip'].includes(key)) { return { english: value, chinese: json["".concat(key, "Cn")], format: 'plain' }; } if (typeof value === 'object') { return _this.extractProperties(value); } }).flat(9); }; return AngularJsonExtractor; }(extractor_1.AbstractExtractor)); exports.AngularJsonExtractor = AngularJsonExtractor; //# sourceMappingURL=angular-json-extractor.js.map