From fd76caa6f4168ca345b6f847f85e5fc9bb6543b2 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Mon, 24 Jun 2024 13:58:01 +0200 Subject: [PATCH] Auto-detect timezone offset from system --- src/lib/locales/de.json | 3 ++- src/lib/locales/en.json | 3 ++- src/lib/locales/es.json | 3 ++- src/lib/locales/nl.json | 3 ++- src/routes/+layout.svelte | 8 +++++--- src/routes/Settings.svelte | 9 +++++++++ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/lib/locales/de.json b/src/lib/locales/de.json index f43709a..7541a63 100644 --- a/src/lib/locales/de.json +++ b/src/lib/locales/de.json @@ -100,5 +100,6 @@ "rssiBar": { "tooltip": "Werte > -67 dBm gelten als gut. > -30 dBm ist erstaunlich" }, - "warning": "Achtung" + "warning": "Achtung", + "auto-detect": "Automatische Erkennung" } diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json index 181154c..68fe9f3 100644 --- a/src/lib/locales/en.json +++ b/src/lib/locales/en.json @@ -102,5 +102,6 @@ "rssiBar": { "tooltip": "Values > -67 dBm are considered good. > -30 dBm is amazing" }, - "warning": "Warning" + "warning": "Warning", + "auto-detect": "Auto-detect" } diff --git a/src/lib/locales/es.json b/src/lib/locales/es.json index 1982f2b..9e18a4b 100644 --- a/src/lib/locales/es.json +++ b/src/lib/locales/es.json @@ -99,5 +99,6 @@ "rssiBar": { "tooltip": "Se consideran buenos valores > -67 dBm. > -30 dBm es increíble" }, - "warning": "Aviso" + "warning": "Aviso", + "auto-detect": "Detección automática" } diff --git a/src/lib/locales/nl.json b/src/lib/locales/nl.json index aa5dbe9..a46bf4f 100644 --- a/src/lib/locales/nl.json +++ b/src/lib/locales/nl.json @@ -99,5 +99,6 @@ "rssiBar": { "tooltip": "Waarden > -67 dBm zijn goed. > -30 dBm is verbazingwekkend" }, - "warning": "Waarschuwing" + "warning": "Waarschuwing", + "auto-detect": "Automatische detectie" } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 98c83de..e97abc4 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -43,10 +43,12 @@ let languageNames = {}; locale.subscribe(() => { - let newLanguageNames = new Intl.DisplayNames([$locale], { type: 'language' }); + if ($locale) { + let newLanguageNames = new Intl.DisplayNames([$locale], { type: 'language' }); - for (let l: string of $locales) { - languageNames[l] = newLanguageNames.of(l); + for (let l: string of $locales) { + languageNames[l] = newLanguageNames.of(l); + } } }); diff --git a/src/routes/Settings.svelte b/src/routes/Settings.svelte index bc0fb1f..8a61fdb 100644 --- a/src/routes/Settings.svelte +++ b/src/routes/Settings.svelte @@ -43,6 +43,12 @@ dispatch('formReset'); }; + const getTzOffsetFromSystem = () => { + const dt = new Date(); + let diffTZ = dt.getTimezoneOffset(); + $settings.tzOffset = diffTZ * -1; + }; + const onSave = async (e: Event) => { e.preventDefault(); let formSettings = $settings; @@ -191,6 +197,9 @@ bind:value={$settings.tzOffset} /> {$_('time.minutes')} + {$_('section.settings.tzOffsetHelpText')}