-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Language(Chinese) #137
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
da74192
feat: add language support
Buffett111 f911793
feat: add language support
Buffett111 6748bc2
feat: complete language support
Buffett111 790a492
fix: fix my git,Idk what's going on
Buffett111 f8ffcf7
deleted: ParticipantView.svelte
Buffett111 3fb58b5
fix: add ParticipantView component back
Buffett111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
<script> | ||
<script lang="ts"> | ||
import { Navbar, NavBrand, Avatar, Dropdown, DropdownItem, Button } from 'flowbite-svelte'; | ||
import { LogOut, User, LayoutDashboard } from 'lucide-svelte'; | ||
import { signOut, user } from '$lib/stores/auth'; | ||
import { profile } from '$lib/stores/profile'; | ||
import { onMount } from 'svelte'; | ||
import { page } from '$app/state'; | ||
import { language } from '$lib/stores/language'; // Import the global language store | ||
|
||
let hinagiku = $state('Hinagiku'); | ||
let highlight = $state(0); | ||
|
||
const translations = { | ||
en: { | ||
welcome: 'Welcome to Hinagiku!', | ||
profile: 'Profile', | ||
dashboard: 'Dashboard', | ||
signOut: 'Sign out', | ||
login: 'Login' | ||
}, | ||
zh: { | ||
welcome: '歡迎來到Hinagiku!', | ||
profile: '個人资料', | ||
dashboard: '儀表板', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 個人資料 |
||
signOut: '登出', | ||
login: '登入' | ||
} | ||
}; | ||
|
||
onMount(() => { | ||
const interval = setInterval(() => { | ||
let newHighlight; | ||
|
@@ -20,11 +38,15 @@ | |
|
||
return () => clearInterval(interval); | ||
}); | ||
|
||
function setLanguage(lang: 'en' | 'zh') { | ||
language.set(lang); | ||
} | ||
</script> | ||
|
||
<Navbar class="fixed left-0 top-0 z-50 w-full shadow-sm"> | ||
<NavBrand href="/"> | ||
<img src="/Icon.png" class="mr-3 h-8" alt="Welcome to Hinagiku!" /> | ||
<img src="/Icon.png" class="mr-3 h-8" alt={translations[$language].welcome} /> | ||
<span class="self-center whitespace-nowrap text-2xl font-bold"> | ||
{#each hinagiku as c, i}<span | ||
class="transition-colors duration-500" | ||
|
@@ -40,18 +62,36 @@ | |
<p class="text-sm text-gray-900">{$profile?.displayName}</p> | ||
<p class="truncate text-sm font-medium text-gray-500">{$user.email}</p> | ||
</div> | ||
<DropdownItem href="/profile" class="flex items-center" | ||
><User class="mr-2 h-4 w-4" />Profile</DropdownItem | ||
> | ||
<DropdownItem href="/dashboard" class="flex items-center" | ||
><LayoutDashboard class="mr-2 h-4 w-4" />Dashbaord</DropdownItem | ||
> | ||
<DropdownItem on:click={() => signOut()} class="flex items-center" | ||
><LogOut class="mr-2 h-4 w-4" />Sign out</DropdownItem | ||
> | ||
<DropdownItem href="/profile" class="flex items-center"> | ||
<User class="mr-2 h-4 w-4" />{translations[$language].profile} | ||
</DropdownItem> | ||
<DropdownItem href="/dashboard" class="flex items-center"> | ||
<LayoutDashboard class="mr-2 h-4 w-4" />{translations[$language].dashboard} | ||
</DropdownItem> | ||
<DropdownItem on:click={() => signOut()} class="flex items-center"> | ||
<LogOut class="mr-2 h-4 w-4" />{translations[$language].signOut} | ||
</DropdownItem> | ||
</Dropdown> | ||
{:else if !page.url.pathname.startsWith('/login')} | ||
<Button href="/login" class="">Login</Button> | ||
<Button href="/login" class="">{translations[$language].login}</Button> | ||
{/if} | ||
|
||
<!-- Remove the old toggle button and add a dropdown for language selection(PM requested) --> | ||
<Avatar | ||
id="language-menu" | ||
src={$language === 'en' ? '/icons/flag-us.png' : '/icons/flag-zh.jpg'} | ||
alt="Lang" | ||
class="ml-2 cursor-pointer" | ||
/> | ||
<Dropdown triggeredBy="#language-menu" class="w-36"> | ||
<DropdownItem class="flex items-center" on:click={() => setLanguage('en')}> | ||
<img src="/icons/flag-us.png" alt="English" class="mr-2 h-4 w-4" /> | ||
English | ||
</DropdownItem> | ||
<DropdownItem class="flex items-center" on:click={() => setLanguage('zh')}> | ||
<img src="/icons/flag-zh.jpg" alt="中文" class="mr-2 h-4 w-4" /> | ||
繁體中文 | ||
</DropdownItem> | ||
</Dropdown> | ||
</div> | ||
</Navbar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
歡迎來到 Hinagiku!