@awesome-fe/translate
Version:
Translation utils
32 lines • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Exporter = void 0;
var html_1 = require("../dom/parse5/html");
var common_1 = require("../dom/common");
var lodash_1 = require("lodash");
var markdown_1 = require("../dom/unified/markdown");
var Exporter = /** @class */ (function () {
function Exporter() {
}
Exporter.prototype.export = function (entries) {
return (0, lodash_1.uniqBy)(entries
.map(function (it) {
return { english: mdToText(it.english), chinese: mdToText(it.chinese) };
})
.filter(function (it) { return (0, common_1.containsChinese)(it.chinese); }), function (it) { return "".concat(it.english, "\t").concat(it.chinese); });
};
return Exporter;
}());
exports.Exporter = Exporter;
function mdToText(md) {
if (!md) {
return md;
}
return html_1.html.toText(markdown_1.markdown.toHtml(md))
.replace(/\n/g, ' ')
.replace(/\t/g, ' ')
.replace(/^[\d.]+ */g, '')
.replace(//g, '')
.trim();
}
//# sourceMappingURL=exporter.js.map