mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 20:36:13 +01:00
feat(i18n): add an option to automatically match formatting locale to set locale
This commit is contained in:
@@ -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 <a href=\"https://en.wikipedia.org/wiki/ISO_week_date#First_week\">ISO 8601</a> 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",
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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)
|
||||
]
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user