Skip to content

Build your personal knowledge base with Trilium Notes

feat(settings): make the formatting locale value adjustable

Elian Doranb923a23d956e
diff --git a/src/public/app/widgets/type_widgets/options/i18n/i18n.ts b/src/public/app/widgets/type_widgets/options/i18n/i18n.ts
index e3bf86837e..57cabc00ce 100644
--- a/src/public/app/widgets/type_widgets/options/i18n/i18n.ts
+++ b/src/public/app/widgets/type_widgets/options/i18n/i18n.ts
@@ -56,6 +56,10 @@ export default class LocalizationOptions extends OptionsWidget {
});
this.$formattingLocaleSelect = this.$widget.find(".formatting-locale-select");
+ this.$formattingLocaleSelect.on("change", async () => {
+ const newLocale = this.$formattingLocaleSelect.val();
+ await server.put(`options/formattingLocale/${newLocale}`);
+ });
this.$widget.find(`input[name="first-day-of-week"]`).on("change", () => {
const firstDayOfWeek = String(this.$widget.find(`input[name="first-day-of-week"]:checked`).val());
@@ -84,6 +88,7 @@ export default class LocalizationOptions extends OptionsWidget {
for (const locale of allLocales.filter(l => l.electronLocale)) {
this.$formattingLocaleSelect.append(buildLocaleItem(locale));
}
+ this.$formattingLocaleSelect.val(options.formattingLocale);
this.$widget.find(`input[name="first-day-of-week"][value="${options.firstDayOfWeek}"]`)
.prop("checked", "true");
diff --git a/src/routes/api/options.ts b/src/routes/api/options.ts
index d4f480615c..1716d51268 100644
--- a/src/routes/api/options.ts
+++ b/src/routes/api/options.ts
@@ -70,6 +70,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([
"promotedAttributesOpenInRibbon",
"editedNotesOpenInRibbon",
"locale",
+ "formattingLocale",
"firstDayOfWeek",
"languages",
"textNoteEditorType",
diff --git a/src/services/options_init.ts b/src/services/options_init.ts
index e088338200..491edc65f9 100644
--- a/src/services/options_init.ts
+++ b/src/services/options_init.ts
@@ -137,6 +137,7 @@ const defaultOptions: DefaultOption[] = [
// Internationalization
{ name: "locale", value: "en", isSynced: true },
+ { name: "formattingLocale", value: "en", isSynced: true },
{ name: "firstDayOfWeek", value: "1", isSynced: true },
{ name: "languages", value: "[]", isSynced: true },
diff --git a/src/services/options_interface.ts b/src/services/options_interface.ts
index f7241956bd..26c4f1b40f 100644
--- a/src/services/options_interface.ts
+++ b/src/services/options_interface.ts
@@ -35,6 +35,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
customSearchEngineName: string;
customSearchEngineUrl: string;
locale: string;
+ formattingLocale: string;
codeBlockTheme: string;
textNoteEditorType: string;
layoutOrientation: string;