Skip to content
Permalink
6775eba989
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
31 lines (25 sloc) 847 Bytes
import { derived } from 'svelte/store';
import languages from '$i18n/languages.json';
import settings from '$lib/state/settings';
import { device } from '$lib/device';
import { INTERNAL_locale, defaultLocale } from '$lib/i18n/translations';
const isValid = (lang: string) => (
Object.keys(languages).includes(lang)
);
export default derived(
settings,
($settings) => {
let currentLocale = defaultLocale;
if ($settings.appearance.autoLanguage) {
if (isValid(device.prefers.language)) {
currentLocale = device.prefers.language;
}
} else {
if (isValid($settings.appearance.language)) {
currentLocale = $settings.appearance.language;
}
}
INTERNAL_locale.set(currentLocale);
return currentLocale;
}
);