| 123456789101112131415161718192021222324252627 |
- import localesData from "../state/locales.js";
- import translateText from "../models/Translation.js";
- const getTranslation = async (names) => {
- const translated = {};
- const untranslated = [];
- const localesMap = await localesData.get(names);
- Object.keys(localesMap).forEach(key => {
- if (localesMap[key]) {
- translated[key] = localesMap[key];
- }
- else {
- untranslated.push(key);
- }
- });
- if (untranslated.length === 0) {
- return translated;
- }
- const translations = await translateText(untranslated);
- await localesData.set(translations);
- Object.assign(translated, translations);
- return translated;
- }
- export default getTranslation;
|