mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-16 21:39:11 +00:00
feat: add support for translations (#349)
Co-authored-by: Kyle Mendell <kmendell@outlook.com> Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
39
frontend/src/routes/settings/account/locale-picker.svelte
Normal file
39
frontend/src/routes/settings/account/locale-picker.svelte
Normal file
@@ -0,0 +1,39 @@
|
||||
<script lang="ts">
|
||||
import * as Select from '$lib/components/ui/select';
|
||||
import { getLocale, setLocale, type Locale } from '$lib/paraglide/runtime';
|
||||
import UserService from '$lib/services/user-service';
|
||||
import userStore from '$lib/stores/user-store';
|
||||
|
||||
const userService = new UserService();
|
||||
const currentLocale = getLocale();
|
||||
|
||||
const locales = {
|
||||
en: 'English',
|
||||
nl: 'Nederlands'
|
||||
};
|
||||
|
||||
function updateLocale(locale: Locale) {
|
||||
setLocale(locale);
|
||||
userService.updateCurrent({
|
||||
...$userStore!,
|
||||
locale
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<Select.Root
|
||||
selected={{
|
||||
label: locales[currentLocale],
|
||||
value: currentLocale
|
||||
}}
|
||||
onSelectedChange={(v) => updateLocale(v!.value)}
|
||||
>
|
||||
<Select.Trigger class="h-9 max-w-[200px]" aria-label="Select locale">
|
||||
<Select.Value>{locales[currentLocale]}</Select.Value>
|
||||
</Select.Trigger>
|
||||
<Select.Content>
|
||||
{#each Object.entries(locales) as [value, label]}
|
||||
<Select.Item {value}>{label}</Select.Item>
|
||||
{/each}
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
Reference in New Issue
Block a user