mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/settings: refresh the locale state when auto mode is toggled
This commit is contained in:
parent
82ac838655
commit
496d440e5b
3 changed files with 32 additions and 4 deletions
29
web/src/components/settings/LanguageAutoToggle.svelte
Normal file
29
web/src/components/settings/LanguageAutoToggle.svelte
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import settings from "$lib/settings";
|
||||||
|
import { device } from "$lib/device";
|
||||||
|
import { locale, locales } from "$lib/i18n/translations";
|
||||||
|
|
||||||
|
import SettingsToggle from "$components/buttons/SettingsToggle.svelte";
|
||||||
|
|
||||||
|
export let title: string;
|
||||||
|
export let description: string;
|
||||||
|
|
||||||
|
const updateLocale = () => {
|
||||||
|
if ($settings.appearance.autoLanguage) {
|
||||||
|
if ($locales.includes(device.preferredLocale)) {
|
||||||
|
$locale = device.preferredLocale;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$locale = $settings.appearance.language;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: $settings.appearance.autoLanguage, updateLocale();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<SettingsToggle
|
||||||
|
settingContext="appearance"
|
||||||
|
settingId="autoLanguage"
|
||||||
|
{title}
|
||||||
|
{description}
|
||||||
|
/>
|
|
@ -27,7 +27,7 @@
|
||||||
</h4>
|
</h4>
|
||||||
<div class="right-side">
|
<div class="right-side">
|
||||||
<span class="selector-current" aria-hidden="true">
|
<span class="selector-current" aria-hidden="true">
|
||||||
{$t(`languages.${$locale}`)}
|
{$t(`languages.${currentSetting}`)}
|
||||||
</span>
|
</span>
|
||||||
<IconSelector />
|
<IconSelector />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
import SettingsToggle from "$components/buttons/SettingsToggle.svelte";
|
import SettingsToggle from "$components/buttons/SettingsToggle.svelte";
|
||||||
|
|
||||||
import LanguageDropdown from "$components/settings/LanguageDropdown.svelte";
|
import LanguageDropdown from "$components/settings/LanguageDropdown.svelte";
|
||||||
|
import LanguageAutoToggle from "$components/settings/LanguageAutoToggle.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<SettingsCategory
|
<SettingsCategory
|
||||||
|
@ -30,9 +31,7 @@
|
||||||
</SettingsCategory>
|
</SettingsCategory>
|
||||||
|
|
||||||
<SettingsCategory sectionId="language" title={$t("settings.language")}>
|
<SettingsCategory sectionId="language" title={$t("settings.language")}>
|
||||||
<SettingsToggle
|
<LanguageAutoToggle
|
||||||
settingContext="appearance"
|
|
||||||
settingId="autoLanguage"
|
|
||||||
title={$t("settings.language.auto.title")}
|
title={$t("settings.language.auto.title")}
|
||||||
description={$t("settings.language.auto.description")}
|
description={$t("settings.language.auto.description")}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue