High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
<script lang="ts">
import Combobox from '#lib/components/shared-components/Combobox.svelte';
import { defaultLang } from '#lib/constants.ts';
import { lang } from '#lib/stores/preferences.store.ts';
import { convertBCP47, getClosestAvailableLocale, langCodes, langs } from '#lib/utils/i18n.ts';
import { refreshAll } from '$app/navigation';
import { Label, Text } from '@immich/ui';
import { locale as i18nLocale, t } from 'svelte-i18n';
interface Props {
showSettingDescription?: boolean;
}
let { showSettingDescription = false }: Props = $props();
const langOptions = langs.map((lang) => ({ label: lang.name, value: convertBCP47(lang.code) }));
const defaultLangOption = { label: defaultLang.name, value: defaultLang.code };
const handleLanguageChange = async (newLang: string | undefined) => {
if (!newLang) {
return;
}
$lang = newLang;
await i18nLocale.set(convertBCP47(newLang));
await refreshAll();
};
let closestLanguage = $derived(getClosestAvailableLocale([$lang], langCodes));
</script>
<div class="max-w-75">
{#if showSettingDescription}
<div>
<div class="flex h-6.5 place-items-center gap-1">
<Label size="small">{$t('language')}</Label>
</div>
<Text size="small" color="muted">{$t('language_setting_description')}</Text>
</div>
{/if}
<Combobox
label={$t('language')}
hideLabel={true}
selectedOption={langOptions.find(({ value }) => value === closestLanguage) || defaultLangOption}
placeholder={$t('language')}
onSelect={(event) => handleLanguageChange(event?.value)}
options={langOptions}
/>
</div>