fix: show the resolved date format on the automatic region option

This commit is contained in:
Linus Rath
2026-10-11 17:04:19 +02:00
parent bf00ea27cf
commit efefbd1358
28 changed files with 46 additions and 28 deletions
+19 -1
View File
@@ -7,6 +7,7 @@ import { useLocaleStore } from '@/stores/locale-store';
import { useSettingsStore } from '@/stores/settings-store';
import type { DateFormat, DateLocale, TimeFormat, FirstDayOfWeek } from '@/stores/settings-store';
import { formatDate } from '@/lib/utils';
import { getEffectiveLocale } from '@/i18n/detect-locale';
import { AUTO_TIME_ZONE, getBrowserTimeZone, getEffectiveTimeZone, listTimeZones } from '@/lib/timezone';
import { SettingsSection, SettingItem, Select, RadioGroup } from './settings-section';
@@ -60,6 +61,23 @@ export function LanguageSettings() {
};
}, [locale, dateFormat, dateLocale, timeFormat, timeZone]);
// Today's date in the UI language's numeric order, so "Automatic" names
// the format it resolves to instead of a vague "match language".
const autoDateExample = useMemo(() => {
void locale; void timeZone;
const uiLocale = getEffectiveLocale();
try {
return new Date().toLocaleDateString(uiLocale === 'en' ? 'en-US' : uiLocale, {
timeZone: getEffectiveTimeZone(),
year: 'numeric',
month: '2-digit',
day: '2-digit',
});
} catch {
return '';
}
}, [locale, timeZone]);
// Current wall-clock in the effective zone so a pick can be sanity-checked.
const timeZonePreview = useMemo(() => {
void timeZone; void timeFormat; void locale;
@@ -115,7 +133,7 @@ export function LanguageSettings() {
value={dateLocale}
onChange={(value) => updateSetting('dateLocale', value as DateLocale)}
options={[
{ value: 'auto', label: t('date_locale.auto') },
{ value: 'auto', label: t('date_locale.auto', { example: autoDateExample }) },
{ value: 'iso', label: t('date_locale.iso') },
{ value: 'en-GB', label: t('date_locale.dmy') },
{ value: 'en-US', label: t('date_locale.mdy') },
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "منطقة تنسيق التاريخ",
"description": "كيفية ترتيب التاريخ الرقمي (يوم، شهر، سنة)",
"auto": "تلقائي (يطابق اللغة)",
"auto": "تلقائي ({example})",
"iso": "ISO 8601 (سنة-شهر-يوم)",
"dmy": "يوم/شهر/سنة",
"mdy": "شهر/يوم/سنة"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Regió del format de data",
"description": "Com s'ordenen les dates numèriques (dia, mes, any)",
"auto": "Automàtic (segons l'idioma)",
"auto": "Automàtic ({example})",
"iso": "ISO 8601 (AAAA-MM-DD)",
"dmy": "Dia/Mes/Any",
"mdy": "Mes/Dia/Any"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Region formátu data",
"description": "Pořadí částí číselného data (den, měsíc, rok)",
"auto": "Automaticky (podle jazyka)",
"auto": "Automaticky ({example})",
"iso": "ISO 8601 (RRRR-MM-DD)",
"dmy": "Den/měsíc/rok",
"mdy": "Měsíc/den/rok"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Region für Datumsformat",
"description": "Legt fest, in welcher Reihenfolge numerische Datumsangaben angezeigt werden (Tag, Monat, Jahr).",
"auto": "Automatisch (passend zur Sprache)",
"auto": "Automatisch ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Tag/Monat/Jahr",
"mdy": "Monat/Tag/Jahr"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1291,7 +1291,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Огнооны форматын бүс",
"description": "Тоон огноог хэрхэн эрэмбэлэх вэ (өдөр, сар, жил)",
"auto": "Автомат (тохирох хэл)",
"auto": "Автомат ({example})",
"iso": "ISO",
"dmy": "Өдөр/Сар/Жил",
"mdy": "Сар/Өдөр/Жил"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Regionalt datoformat",
"description": "Rekkefølgen i numeriske datoer (dag, måned og år)",
"auto": "Automatisk (følger språket)",
"auto": "Automatisk ({example})",
"iso": "ISO 8601 (ÅÅÅÅ-MM-DD)",
"dmy": "Dag/måned/år",
"mdy": "Måned/dag/år"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Formato de data da região",
"description": "Como as datas numéricas são ordenadas (dia, mês, ano)",
"auto": "Automático (corresponder ao idioma)",
"auto": "Automático ({example})",
"iso": "ISO 8601 (AAAA-MM-DD)",
"dmy": "Dia/Mês/Ano",
"mdy": "Mês/Dia/Ano"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"
+1 -1
View File
@@ -1329,7 +1329,7 @@
"date_locale": {
"label": "日期格式地區",
"description": "數字日期的排列順序(日、月、年)",
"auto": "自動(與語言相符)",
"auto": "自動({example})",
"iso": "ISO 8601(YYYY-MM-DD)",
"dmy": "日/月/年",
"mdy": "月/日/年"
+1 -1
View File
@@ -1326,7 +1326,7 @@
"date_locale": {
"label": "Date format region",
"description": "How numeric dates are ordered (day, month, year)",
"auto": "Automatic (match language)",
"auto": "Automatic ({example})",
"iso": "ISO 8601 (YYYY-MM-DD)",
"dmy": "Day/Month/Year",
"mdy": "Month/Day/Year"