mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-18 16:32:33 +08:00
server: Update locale when switching language from settings
This commit is contained in:
parent
af67362ad6
commit
9f6f0f5d60
@ -5,6 +5,7 @@ import log from "../../services/log.js";
|
|||||||
import searchService from "../../services/search/services/search.js";
|
import searchService from "../../services/search/services/search.js";
|
||||||
import ValidationError from "../../errors/validation_error.js";
|
import ValidationError from "../../errors/validation_error.js";
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
|
import { changeLanguage } from "../../services/i18n.js";
|
||||||
|
|
||||||
// options allowed to be updated directly in the Options dialog
|
// options allowed to be updated directly in the Options dialog
|
||||||
const ALLOWED_OPTIONS = new Set([
|
const ALLOWED_OPTIONS = new Set([
|
||||||
@ -108,6 +109,11 @@ function update(name: string, value: string) {
|
|||||||
|
|
||||||
optionService.setOption(name, value);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,4 +41,8 @@ function getCurrentLanguage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function changeLanguage(locale: string) {
|
||||||
|
return i18next.changeLanguage(locale);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user