server: Implement basic restore of language

This commit is contained in:
Elian Doran 2024-09-08 18:01:08 +03:00
parent 68042994e0
commit 317b7b4c59
No known key found for this signature in database

View File

@ -1,10 +1,11 @@
import i18next from "i18next";
import Backend from "i18next-fs-backend";
import options from "./options.js";
export async function initializeTranslations() {
// Initialize translations
await i18next.use(Backend).init({
lng: "ro",
lng: await getCurrentLanguage(),
fallbackLng: "en",
ns: "server",
backend: {
@ -13,3 +14,15 @@ export async function initializeTranslations() {
debug: true
});
}
function getCurrentLanguage() {
let language;
language = options.getOption("locale");
if (!language) {
console.info("Language option not found, falling back to en.");
language = "en";
}
return language;
}