server: Update locale when switching language from settings

This commit is contained in:
Elian Doran 2024-10-23 19:56:06 +03:00
parent af67362ad6
commit 9f6f0f5d60
No known key found for this signature in database
2 changed files with 11 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import log from "../../services/log.js";
import searchService from "../../services/search/services/search.js";
import ValidationError from "../../errors/validation_error.js";
import { Request } from 'express';
import { changeLanguage } from "../../services/i18n.js";
// options allowed to be updated directly in the Options dialog
const ALLOWED_OPTIONS = new Set([
@ -108,6 +109,11 @@ function update(name: string, value: string) {
optionService.setOption(name, value);
if (name === "locale") {
// This runs asynchronously, so it's not perfect, but it does the trick for now.
changeLanguage(value);
}
return true;
}

View File

@ -41,4 +41,8 @@ function getCurrentLanguage() {
}
return language;
}
}
export function changeLanguage(locale: string) {
return i18next.changeLanguage(locale);
}