mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-13 05:37:44 +02:00
web: refactor and deduplicate locale preference logic
This commit is contained in:
@ -1,27 +0,0 @@
|
||||
<script lang="ts">
|
||||
import settings from "$lib/state/settings";
|
||||
import { device } from "$lib/device";
|
||||
import { locale } 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) {
|
||||
$locale = device.prefers.language;
|
||||
} else {
|
||||
$locale = $settings.appearance.language;
|
||||
}
|
||||
}
|
||||
|
||||
$: $settings.appearance.autoLanguage, updateLocale();
|
||||
</script>
|
||||
|
||||
<SettingsToggle
|
||||
settingContext="appearance"
|
||||
settingId="autoLanguage"
|
||||
{title}
|
||||
{description}
|
||||
/>
|
@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import settings, { updateSetting } from "$lib/state/settings";
|
||||
import { t, locale, locales } from "$lib/i18n/translations";
|
||||
import { t, locales } from "$lib/i18n/translations";
|
||||
import locale from "$lib/i18n/locale";
|
||||
|
||||
import languages from "$i18n/languages.json";
|
||||
|
||||
|
Reference in New Issue
Block a user