[+] Multi-language switch

This commit is contained in:
2025-11-23 00:54:55 +08:00
parent 5f83008ec0
commit caad381877
2 changed files with 9 additions and 9 deletions
+3 -2
View File
@@ -8,12 +8,13 @@
onclick: () => void onclick: () => void
} }
let { title, sub, account, right, children }: { let { title, sub, account, right, children, moreIcon }: {
title?: string title?: string
sub?: string sub?: string
account?: () => void account?: () => void
right?: Icon[] right?: Icon[]
children?: any children?: any
moreIcon?: string
} = $props() } = $props()
let showMenu = $state(false) let showMenu = $state(false)
@@ -37,7 +38,7 @@
{/each} {/each}
{#if children} {#if children}
<IconButton icon="i-material-symbols:more-vert" onclick={() => showMenu = !showMenu} /> <IconButton icon={moreIcon ?? 'i-material-symbols:more-vert'} onclick={() => showMenu = !showMenu} />
{/if} {/if}
</div> </div>
+6 -7
View File
@@ -7,6 +7,7 @@
import { Layer } from "m3-svelte" import { Layer } from "m3-svelte"
import { goto } from "$app/navigation" import { goto } from "$app/navigation"
import { getI18n, setLanguage } from "$lib/i18n" import { getI18n, setLanguage } from "$lib/i18n"
import MenuItem from "$lib/ui/material3/MenuItem.svelte";
let { data }: PageProps = $props() let { data }: PageProps = $props()
@@ -19,13 +20,11 @@
</script> </script>
<AppBar account={() => goto('/user')} right={[ <AppBar account={() => goto('/user')} moreIcon="i-material-symbols:translate-rounded">
// {icon: "i-material-symbols:settings-rounded", onclick: () => alert('Settings clicked')} <MenuItem onclick={() => setLanguage('en')}>English</MenuItem>
// Language switching button <MenuItem onclick={() => setLanguage('zh')}>中文</MenuItem>
{icon: "i-material-symbols:translate-rounded", onclick: () => { <MenuItem onclick={() => setLanguage('ja')}>日本語</MenuItem>
setLanguage(data.lang === 'en' ? 'zh' : 'en') </AppBar>
}}
]} />
<div class="vbox gap-16px overflow-y-auto flex-1"> <div class="vbox gap-16px overflow-y-auto flex-1">
{#if data.last} {#if data.last}