diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 49090efa7..0d962270d 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1424,7 +1424,8 @@ "min-days-in-first-week": "Minimum days in first week", "first-week-info": "First week contains first Thursday of the year is based on ISO 8601 standard.", "first-week-warning": "Changing first week options may cause duplicate with existing Week Notes and the existing Week Notes will not be updated accordingly.", - "formatting-locale": "Date & number format" + "formatting-locale": "Date & number format", + "formatting-locale-auto": "Based on the application's language" }, "backup": { "automatic_backup": "Automatic backup", diff --git a/apps/client/src/utils/formatters.ts b/apps/client/src/utils/formatters.ts index 664580c65..40f97e673 100644 --- a/apps/client/src/utils/formatters.ts +++ b/apps/client/src/utils/formatters.ts @@ -10,7 +10,7 @@ export function formatDateTime(date: string | Date | number | null | undefined, return ""; } - const locale = options.get("formattingLocale") ?? options.get("locale") ?? navigator.language; + const locale = options.get("formattingLocale") || options.get("locale") || navigator.language; let parsedDate; if (typeof date === "string" || typeof date === "number") { diff --git a/apps/client/src/widgets/type_widgets/options/i18n.tsx b/apps/client/src/widgets/type_widgets/options/i18n.tsx index 9ebca626b..1084a05a8 100644 --- a/apps/client/src/widgets/type_widgets/options/i18n.tsx +++ b/apps/client/src/widgets/type_widgets/options/i18n.tsx @@ -23,7 +23,7 @@ export default function InternationalizationOptions() { } function LocalizationOptions() { - const { uiLocales, formattingLocales: contentLocales } = useMemo(() => { + const { uiLocales, formattingLocales: contentLocales } = useMemo<{ uiLocales: Locale[], formattingLocales: Locale[] }>(() => { const allLocales = getAvailableLocales(); return { uiLocales: allLocales.filter(locale => { @@ -31,7 +31,10 @@ function LocalizationOptions() { if (locale.devOnly && !glob.isDev) return false; return true; }), - formattingLocales: allLocales.filter(locale => locale.electronLocale), + formattingLocales: [ + { id: "", name: t("i18n.formatting-locale-auto") }, + ...allLocales.filter(locale => locale.electronLocale) + ] } }, []); diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index 000d4c458..52ebe458b 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -30,7 +30,7 @@ async function main() { // needed for excalidraw export https://github.com/zadam/trilium/issues/4271 app.commandLine.appendSwitch("enable-experimental-web-platform-features"); - app.commandLine.appendSwitch("lang", options.getOptionOrNull("formattingLocale") ?? "en"); + app.commandLine.appendSwitch("lang", options.getOptionOrNull("formattingLocale") || options.getOptionOrNull("locale") || "en"); // Disable smooth scroll if the option is set const smoothScrollEnabled = options.getOptionOrNull("smoothScrollEnabled"); diff --git a/apps/server/src/services/options_init.ts b/apps/server/src/services/options_init.ts index 0908a0512..c6e0231c5 100644 --- a/apps/server/src/services/options_init.ts +++ b/apps/server/src/services/options_init.ts @@ -159,7 +159,7 @@ const defaultOptions: DefaultOption[] = [ // Internationalization { name: "locale", value: "en", isSynced: true }, - { name: "formattingLocale", value: "en", isSynced: true }, + { name: "formattingLocale", value: "", isSynced: true }, // no value means auto-detect { name: "firstDayOfWeek", value: "1", isSynced: true }, { name: "firstWeekOfYear", value: "0", isSynced: true }, { name: "minDaysInFirstWeek", value: "4", isSynced: true },