@softkit/i18n
Version:
This library is a simple wrapper based on [nestjs-i18n](https://nestjs-i18n.com/)
35 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.processLanguages = exports.processTranslations = void 0;
const i18n_module_1 = require("../i18n.module");
const merge_1 = require("./merge");
async function processTranslations(loaders) {
try {
const loadedTranslations = await Promise.all(loaders.map((loader) => loader.load()));
return loadedTranslations
.filter((translation) => translation !== undefined)
.reduce((acc, translation) => {
return (0, merge_1.mergeTranslations)(acc, translation);
}, {});
}
catch (error) {
i18n_module_1.logger.error('parsing translations files or processing error', error);
throw error;
}
}
exports.processTranslations = processTranslations;
async function processLanguages(loaders) {
try {
const allLanguages = await Promise.all(loaders.map((loader) => loader.languages()));
const languagesToRespond = allLanguages
.filter((languages) => languages !== undefined)
.flat();
return [...new Set(languagesToRespond)];
}
catch (error) {
i18n_module_1.logger.error('parsing languages or processing error', error);
throw error;
}
}
exports.processLanguages = processLanguages;
//# sourceMappingURL=loaders-utils.js.map