Merge pull request #239 from Xyphyn/i18n

Add support for localization
This commit is contained in:
Xylight authored and GitHub committed 2024-06-06 13:28:50 -07:00
commit 8756670c37
84 files changed
+2068 -1083

No files matched your search

+3 -2
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { t } from '$lib/translations'
import { Button } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
import {
@@ -32,7 +33,7 @@
class={$$slots.default ? '' : 'flex-1'}
>
<Icon src={ChevronLeft} size="18" mini slot="prefix" />
Back
{$t('common.back')}
</Button>
{/if}
@@ -43,7 +44,7 @@
}}
class={$$slots.default ? '' : 'flex-1'}
>
Next
{$t('common.next')}
<Icon src={ChevronRight} size="18" mini slot="suffix" />
</Button>
</div>
@@ -1,3 +1,3 @@
<h1 class="text-3xl font-bold flex items-center">
<h1 class="text-3xl font-bold flex items-center gap-2 {$$props.class ?? ''}">
<slot />
</h1>
+19 -10
View File
@@ -37,6 +37,7 @@
import Logo from '../Logo.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/translations'
let searching = false
</script>
@@ -48,7 +49,7 @@
"
style={$$props.style}
>
<NavButton href="/" label="Home" class="ml-2 logo">
<NavButton href="/" label={$t('nav.home')} class="ml-2 logo">
<svelte:fragment slot="icon">
{#if LINKED_INSTANCE_URL}
{#if $site}
@@ -171,7 +172,7 @@
{#if $profile?.user && isAdmin($profile.user)}
<NavButton
href="/admin"
label="Admin"
label={$t('nav.admin')}
icon={ServerStack}
class="relative"
isSelectedFilter={(path) => path.startsWith('/admin')}
@@ -184,7 +185,11 @@
</NavButton>
{/if}
{#if amModOfAny($profile?.user)}
<NavButton href="/moderation" label="Moderation" class="relative">
<NavButton
href="/moderation"
label={$t('nav.moderation')}
class="relative"
>
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
@@ -193,10 +198,14 @@
<ShieldIcon let:isSelected slot="icon" filled={isSelected} width={18} />
</NavButton>
{/if}
<NavButton href="/communities" label="Explore" icon={GlobeAlt} />
<NavButton
href="/communities"
label={$t('nav.communities')}
icon={GlobeAlt}
/>
<NavButton
on:click={() => (searching = true)}
label="Search"
label={$t('nav.search')}
icon={MagnifyingGlass}
/>
<Menu placement="top">
@@ -204,13 +213,13 @@
class="relative"
color="primary"
slot="target"
label="Create"
label={$t('nav.create.label')}
icon={Plus}
/>
<MenuDivider>Create</MenuDivider>
<MenuDivider>{$t('nav.create.label')}</MenuDivider>
<MenuButton link href="/create/post" disabled={!$profile?.jwt}>
<Icon src={PencilSquare} mini width={16} slot="prefix" />
Post
{$t('nav.create.post')}
</MenuButton>
<MenuButton
link
@@ -221,11 +230,11 @@
!isAdmin($profile.user))}
>
<Icon src={Newspaper} mini width={16} slot="prefix" />
Community
{$t('nav.create.community')}
</MenuButton>
{#if !$profile?.jwt}
<span class="text-sm mx-4 my-1 py-1">
<Link highlight href="/login">Log in</Link> to create content.
{$t('nav.create.logingate')}
</span>
{/if}
</Menu>
+20 -20
View File
@@ -35,6 +35,7 @@
import { userSettings } from '$lib/settings'
import { site } from '$lib/lemmy'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/translations'
let showInstance = false
</script>
@@ -59,7 +60,7 @@
class="w-10 h-10 rounded-full ring-1 ring-slate-200 dark:ring-zinc-700
transition-all bg-slate-50 dark:bg-zinc-900 relative
hover:dark:brightness-125 hover:brightness {$$props.buttonClass}"
aria-label="Profile"
title={$t('profile.profile')}
slot="target"
>
{#if $profile?.user}
@@ -93,15 +94,16 @@
{$profile?.user?.local_user_view?.person.name}
</div>
{:else}
<MenuDivider>Profile</MenuDivider>
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
{/if}
{#if $profile?.user}
<MenuButton link href="/profile">
<Icon src={UserCircle} mini width={16} slot="prefix" /> Profile
<Icon src={UserCircle} mini width={16} slot="prefix" />
{$t('profile.profile')}
</MenuButton>
<MenuButton link href="/inbox">
<Icon src={Inbox} mini width={16} slot="prefix" />
Inbox
{$t('profile.inbox')}
{#if $profile.user.notifications.inbox > 0}
<Badge color="red-subtle" class="text-xs ml-auto font-bold !py-0.5">
{$profile.user.notifications.inbox}
@@ -109,18 +111,19 @@
{/if}
</MenuButton>
<MenuButton link href="/saved">
<Icon src={Bookmark} mini width={16} slot="prefix" /> Saved
<Icon src={Bookmark} mini width={16} slot="prefix" />
{$t('profile.saved')}
</MenuButton>
{/if}
<MenuButton link href="/accounts">
<Icon src={UserGroup} mini width={16} slot="prefix" />
Accounts
{$t('account.accounts')}
</MenuButton>
<hr class="dark:opacity-10 w-[90%] my-2 mx-auto" />
<MenuDivider>App</MenuDivider>
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
<MenuButton link href="/settings">
<Icon src={Cog6Tooth} mini width={16} slot="prefix" />
Settings
{$t('nav.menu.settings')}
</MenuButton>
<MenuButton class="!py-0">
<Icon
@@ -135,20 +138,20 @@
size="16"
slot="prefix"
/>
<span>Color Scheme</span>
<span>{$t('nav.menu.colorscheme.label')}</span>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="contents" on:click|stopPropagation={() => {}}>
<Select bind:value={$legacyTheme} class="ml-auto my-auto w-24" size="sm">
<option value="system">System</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
<option value="system">{$t('nav.menu.colorscheme.system')}</option>
<option value="light">{$t('nav.menu.colorscheme.light')}</option>
<option value="dark">{$t('nav.menu.colorscheme.dark')}</option>
</Select>
</div>
</MenuButton>
<MenuButton href="/theme">
<Icon src={Swatch} size="16" mini slot="prefix" />
Theme
{$t('nav.menu.theme')}
</MenuButton>
{#if $userSettings.debugInfo}
<MenuButton link href="/util">
@@ -165,7 +168,7 @@
class="hover:brightness-110 transition-all"
on:click={() => {
navigator?.clipboard?.writeText(__VERSION__)
toast({ content: 'Copied version to clipboard.' })
toast({ content: $t('toast.copied') })
}}
>
<Badge color="blue-subtle">{__VERSION__}</Badge>
@@ -174,7 +177,7 @@
<Button
on:click={() => (showInstance = !showInstance)}
color="tertiary"
title="Instance"
title={$t('nav.menu.instance')}
size="square-md"
>
<Icon src={ServerStack} size="16" mini />
@@ -182,7 +185,7 @@
<Button
color="tertiary"
href="https://buymeacoffee.com/xylight"
title="Donate"
title={$t('nav.menu.donate')}
size="square-md"
>
<Icon src={Heart} size="16" mini />
@@ -190,14 +193,11 @@
<Button
color="tertiary"
href="https://github.com/Xyphyn/Photon"
title="GitHub"
title={$t('nav.menu.source')}
size="square-md"
>
<Icon src={CodeBracketSquare} size="16" mini />
</Button>
<Button color="tertiary" href="/about" title="About" size="square-md">
<Icon src={InformationCircle} size="16" mini />
</Button>
</div>
</li>
</Menu>
+22 -11
View File
@@ -26,6 +26,7 @@
import Expandable from '$lib/components/ui/Expandable.svelte'
import EndPlaceholder from '../EndPlaceholder.svelte'
import Application from '../../../../routes/admin/applications/Application.svelte'
import { t } from '$lib/translations'
</script>
<nav
@@ -35,11 +36,13 @@
>
{#if $profile?.jwt}
<SidebarButton icon={UserCircle} href="/profile/user">
<span slot="label">Profile</span>
<span slot="label">
{$t('profile.profile')}
</span>
</SidebarButton>
<SidebarButton icon={Inbox} href="/inbox">
<span slot="label" class="flex items-center gap-2">
Inbox
{$t('profile.inbox')}
{#if $profile?.user?.notifications.inbox}
<Badge
class="w-5 h-5 !p-0 grid place-items-center ml-auto"
@@ -51,22 +54,30 @@
</span>
</SidebarButton>
<SidebarButton icon={Bookmark} href="/saved">
<span slot="label">Saved</span>
<span slot="label">{$t('profile.saved')}</span>
</SidebarButton>
{:else}
<SidebarButton href="/login" title="Log In" icon={ArrowLeftOnRectangle}>
<span slot="label">Log In</span>
<SidebarButton
href="/login"
title={$t('account.login')}
icon={ArrowLeftOnRectangle}
>
<span slot="label">{$t('account.login')}</span>
</SidebarButton>
<SidebarButton href="/signup" title="Sign Up" icon={Identification}>
<span slot="label">Sign Up</span>
<SidebarButton
href="/signup"
title={$t('account.signup')}
icon={Identification}
>
<span slot="label">{$t('account.signup')}</span>
</SidebarButton>
{#if LINKED_INSTANCE_URL === undefined}
<SidebarButton
href="/accounts"
title="Change Instance"
title={$t('account.changeinstance')}
icon={ServerStack}
>
<span slot="label">Change Instance</span>
<span slot="label">{$t('account.changeinstance')}</span>
</SidebarButton>
{/if}
{/if}
@@ -78,7 +89,7 @@
</div>
{/each}
<SidebarButton href="/accounts" icon={UserGroup}>
<span slot="label">Accounts</span>
<span slot="label">{$t('account.accounts')}</span>
</SidebarButton>
{/if}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
@@ -99,7 +110,7 @@
: '//max-lg:hidden'}"
>
<EndPlaceholder>
Subscribed
{$t('profile.subscribed')}
<span slot="action" class="dark:text-white text-black">
{$profile.user.follows.length}
</span>