UNPKG

rucken

Version:

Console tools and scripts for nx and not only that I (EndyKaufman) use to automate the workflow and speed up the development process

26 lines (25 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.i18nextToMo = exports.i18nextToPot = exports.i18nextToPo = void 0; /* eslint-disable @typescript-eslint/no-explicit-any */ const gettext_parser_1 = require("gettext-parser"); const gettext_converter_1 = require("gettext-converter"); function i18nextToPo(locale, body, options = {}) { return i18nextToGettext(locale, body, gettext_parser_1.po, options); } exports.i18nextToPo = i18nextToPo; function i18nextToPot(locale, body, options = {}) { return i18nextToGettext(locale, body, gettext_parser_1.po, options); } exports.i18nextToPot = i18nextToPot; function i18nextToMo(locale, body, options = {}) { return i18nextToGettext(locale, body, gettext_parser_1.mo, options); } exports.i18nextToMo = i18nextToMo; function i18nextToGettext(locale, body, parser, options) { var _a; const parserOptions = options.foldLength === undefined ? {} : { foldLength: options.foldLength }; return Promise.resolve(parser.compile((0, gettext_converter_1.i18next2js)(locale, // i18next2js does not support buffers Buffer.isBuffer(body) ? body.toString('utf8') : body, Object.assign(Object.assign({}, options), { project: (_a = options.project) !== null && _a !== void 0 ? _a : 'i18next-conv', setLocaleAsLanguageHeader: false })), parserOptions)); }