UNPKG

@openinc/parse-server-opendash

Version:
46 lines (45 loc) 1.91 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.initTranslations = initTranslations; const i18next_1 = __importDefault(require("i18next")); const i18next_fs_backend_1 = __importDefault(require("i18next-fs-backend")); const path_1 = __importDefault(require("path")); /** * @file Init Translations * @description Initializes the translation service for the application. */ async function initTranslations() { try { console.log("[@openinc/parse-server-opendash] Init translations"); const i18npath = path_1.default.join(__dirname, "../../../i18n"); const loadPath = path_1.default.join(i18npath, "{{lng}}/{{ns}}.json"); const addPath = path_1.default.join(i18npath, "{{lng}}/{{ns}}.missing.json"); // Initialize i18next with backend configuration await i18next_1.default.use(i18next_fs_backend_1.default).init({ // Backend configuration backend: { loadPath: loadPath, addPath: addPath, }, // Use the correct language codes that match your directory names lng: "de-DE", fallbackLng: "en-US", // Specify available languages to match your directories supportedLngs: ["de-DE", "en-US"], ns: ["maintenance"], defaultNS: "server", debug: false, // Ensure resources are loaded initImmediate: false, }); console.log("[@openinc/parse-server-opendash] Current language:", i18next_1.default.language); } catch (error) { console.error("[@openinc/parse-server-opendash] Error while initializing translations"); console.error(error); process.exit(1); } }