i18n: localize posts
This commit is contained in:
1 parent
64107e51a0
commit
c4236fa124
9 files changed
+110
-31
No files matched your search
@@ -49,6 +49,7 @@
|
||||
} from 'mono-svelte'
|
||||
import { fediseer, type Data } from '$lib/fediseer/fediseer'
|
||||
import Fediseer from '$lib/fediseer/Fediseer.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
|
||||
export let post: PostView
|
||||
|
||||
@@ -110,7 +111,7 @@
|
||||
href="/post/{getInstance()}/{post.post.id}"
|
||||
class="!text-inherit h-8 px-3"
|
||||
target={$userSettings.openLinksInNewTab ? '_blank' : ''}
|
||||
title="Comments"
|
||||
title={$t('post.actions.comments')}
|
||||
>
|
||||
<Icon slot="prefix" src={ChatBubbleOvalLeft} mini size="14" />
|
||||
<FormattedNumber number={post.counts.comments} />
|
||||
@@ -123,7 +124,12 @@
|
||||
<DebugObject object={post} bind:open={debug} />
|
||||
{/await}
|
||||
{/if}
|
||||
<Button on:click={() => (debug = true)} size="square-md" color="ghost">
|
||||
<Button
|
||||
on:click={() => (debug = true)}
|
||||
title="Debug"
|
||||
size="square-md"
|
||||
color="ghost"
|
||||
>
|
||||
<Icon src={BugAnt} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
{/if}
|
||||
@@ -143,7 +149,7 @@
|
||||
color="ghost"
|
||||
loading={saving}
|
||||
disabled={saving}
|
||||
title={post.saved ? 'Unsave' : 'Save'}
|
||||
title={post.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
||||
>
|
||||
<Icon
|
||||
src={post.saved ? BookmarkSlash : Bookmark}
|
||||
@@ -159,12 +165,17 @@
|
||||
containerClass="overflow-auto max-h-[400px]"
|
||||
class="h-8"
|
||||
targetClass="h-full"
|
||||
title="Post actions"
|
||||
title={$t('post.actions.more.label')}
|
||||
>
|
||||
<Button slot="target" title="Post actions" color="ghost" size="square-md">
|
||||
<Button
|
||||
slot="target"
|
||||
title={$t('post.actions.more.label')}
|
||||
color="ghost"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon slot="prefix" src={EllipsisHorizontal} width={16} mini />
|
||||
</Button>
|
||||
<MenuDivider>Creator</MenuDivider>
|
||||
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
||||
<MenuButton
|
||||
link
|
||||
href="/u/{post.creator.name}@{new URL(post.creator.actor_id).hostname}"
|
||||
@@ -189,7 +200,6 @@
|
||||
const data = await fediseer.getInstanceInfo(
|
||||
new URL(post.community.actor_id).hostname
|
||||
)
|
||||
console.log(data)
|
||||
fediseerData = data
|
||||
fediseerOpen = true
|
||||
fediseerLoading = false
|
||||
@@ -207,11 +217,11 @@
|
||||
<span>{new URL(post.community.actor_id).hostname}</span>
|
||||
</MenuButton>
|
||||
<hr class="w-[90%] mx-auto opacity-100 dark:opacity-10 my-2" />
|
||||
<MenuDivider>Actions</MenuDivider>
|
||||
<MenuDivider>{$t('post.actions.more.actions')}</MenuDivider>
|
||||
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
||||
<MenuButton on:click={() => (editing = true)}>
|
||||
<Icon src={PencilSquare} width={16} mini slot="prefix" />
|
||||
Edit
|
||||
{$t('post.actions.more.edit')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile?.jwt}
|
||||
@@ -222,7 +232,9 @@
|
||||
}}
|
||||
>
|
||||
<Icon slot="prefix" src={post.read ? EyeSlash : Eye} width={16} mini />
|
||||
Mark as {post.read ? 'Unread' : 'Read'}
|
||||
{post.read
|
||||
? $t('post.actions.more.markUnread')
|
||||
: $t('post.actions.more.markRead')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<MenuButton
|
||||
@@ -233,7 +245,7 @@
|
||||
}}
|
||||
>
|
||||
<Icon src={Share} width={16} mini slot="prefix" />
|
||||
Share
|
||||
{$t('post.actions.more.share')}
|
||||
</MenuButton>
|
||||
{#if $profile?.jwt}
|
||||
<MenuButton
|
||||
@@ -260,7 +272,7 @@
|
||||
}}
|
||||
>
|
||||
<Icon src={ArrowTopRightOnSquare} width={16} mini slot="prefix" />
|
||||
Crosspost
|
||||
{$t('post.actions.more.crosspost')}
|
||||
</MenuButton>
|
||||
{#if $profile.user && post.creator.id == $profile.user.local_user_view.person.id}
|
||||
<MenuButton
|
||||
@@ -275,13 +287,15 @@
|
||||
color="danger-subtle"
|
||||
>
|
||||
<Icon src={Trash} width={16} mini slot="prefix" />
|
||||
{post.post.deleted ? 'Restore' : 'Delete'}
|
||||
{post.post.deleted
|
||||
? $t('post.actions.more.restore')
|
||||
: $t('post.actions.more.delete')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile.user?.local_user_view.person.id != post.creator.id}
|
||||
<MenuButton on:click={() => report(post)} color="danger-subtle">
|
||||
<Icon src={Flag} width={16} mini slot="prefix" />
|
||||
Report
|
||||
{$t('moderation.report')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@@ -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,11 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { locale } from '$lib/translations'
|
||||
|
||||
export let number: number
|
||||
export let locale: string = 'en'
|
||||
let localeToUse: string = $locale
|
||||
export let options: Intl.NumberFormatOptions = {
|
||||
notation: 'compact',
|
||||
}
|
||||
|
||||
export { localeToUse as locale }
|
||||
</script>
|
||||
|
||||
<span class={$$props.class ?? ''}>
|
||||
{Intl.NumberFormat(locale, options).format(number)}
|
||||
{Intl.NumberFormat(localeToUse, options).format(number)}
|
||||
</span>
|
||||
+30
-1
@@ -93,7 +93,10 @@
|
||||
"submit": "Submit"
|
||||
},
|
||||
"routes": {
|
||||
"frontpage": "Frontpage",
|
||||
"frontpage": {
|
||||
"title": "Frontpage",
|
||||
"footer": "{{users:number}} active {{users; 1:user; default:users;}}"
|
||||
},
|
||||
"modlog": "Modlog",
|
||||
"instances": "Instances",
|
||||
"legal": "Legal"
|
||||
@@ -109,5 +112,31 @@
|
||||
"users": "Users",
|
||||
"posts": "Posts",
|
||||
"communities": "Communities"
|
||||
},
|
||||
"post": {
|
||||
"actions": {
|
||||
"comments": "Comments",
|
||||
"save": "Save",
|
||||
"unsave": "Unsave",
|
||||
"more": {
|
||||
"label": "More Actions",
|
||||
"edit": "Edit",
|
||||
"creator": "Creator",
|
||||
"actions": "Actions",
|
||||
"markRead": "Mark as Read",
|
||||
"markUnread": "Mark as Unread",
|
||||
"share": "Share",
|
||||
"crosspost": "Crosspost",
|
||||
"delete": "Delete",
|
||||
"restore": "Restore"
|
||||
}
|
||||
}
|
||||
},
|
||||
"moderation": {
|
||||
"report": "Report"
|
||||
},
|
||||
"common": {
|
||||
"back": "Back",
|
||||
"next": "Next"
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -77,6 +77,7 @@ interface Settings {
|
||||
deduplicateEmbed: boolean
|
||||
compactFeatured: boolean
|
||||
}
|
||||
language: string | null
|
||||
}
|
||||
|
||||
export const defaultSettings: Settings = {
|
||||
@@ -128,12 +129,13 @@ export const defaultSettings: Settings = {
|
||||
},
|
||||
dock: {
|
||||
noGap: toBool(env.PUBLIC_DOCK_PANEL) ?? null,
|
||||
top: toBool(env.PUBLIC_DOCK_TOP) ?? null
|
||||
top: toBool(env.PUBLIC_DOCK_TOP) ?? null,
|
||||
},
|
||||
posts: {
|
||||
deduplicateEmbed: toBool(env.PUBLIC_DEDUPLICATE_EMBED) ?? true,
|
||||
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true
|
||||
}
|
||||
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
|
||||
},
|
||||
language: null,
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
@@ -8,6 +8,7 @@ const config: Config = {
|
||||
loader: async () => (await import('./i18n/en.json')).default,
|
||||
},
|
||||
],
|
||||
fallbackLocale: 'en',
|
||||
}
|
||||
|
||||
export const { t, locale, locales, loading, loadTranslations } = new i18n(
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { env } from '$env/dynamic/public'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { loadTranslations } from '$lib/translations.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
|
||||
|
||||
export const load = async ({ url }) => {
|
||||
await loadTranslations('en')
|
||||
export const load = async ({}) => {
|
||||
const initLocale = get(userSettings)?.language ?? navigator?.language ?? 'en'
|
||||
|
||||
console.log(`Loading locale ${initLocale}`)
|
||||
|
||||
await loadTranslations(initLocale)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
||||
<header>
|
||||
<Header>{$t('routes.frontpage')}</Header>
|
||||
<Header>{$t('routes.frontpage.title')}</Header>
|
||||
</header>
|
||||
<div class="flex items-center gap-2">
|
||||
<Location changeDefault selected={data.listingType} />
|
||||
@@ -45,11 +45,9 @@
|
||||
>
|
||||
<span class="flex flex-row items-center gap-1">
|
||||
<Icon src={ChartBar} size="16" mini />
|
||||
<FormattedNumber
|
||||
number={$site?.site_view.counts.users_active_day ?? 0}
|
||||
class="text-black dark:text-white font-medium"
|
||||
/>
|
||||
<span class="font-normal">active users</span>
|
||||
{$t('routes.frontpage.footer', {
|
||||
users: $site?.site_view.counts.users_active_day ?? '??',
|
||||
})}
|
||||
</span>
|
||||
</Pageination>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,14 @@
|
||||
import Setting from './Setting.svelte'
|
||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import { Disclosure, Material, Switch, TextInput, toast } from 'mono-svelte'
|
||||
import {
|
||||
Disclosure,
|
||||
Material,
|
||||
Note,
|
||||
Switch,
|
||||
TextInput,
|
||||
toast,
|
||||
} from 'mono-svelte'
|
||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import {
|
||||
@@ -25,6 +32,7 @@
|
||||
import { removeItem } from '$lib/util.js'
|
||||
import Section from './Section.svelte'
|
||||
import ToggleSetting from './ToggleSetting.svelte'
|
||||
import { locales } from '$lib/translations'
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -90,6 +98,22 @@
|
||||
Go to themes <Icon src={ArrowRight} size="16" mini slot="suffix" />
|
||||
</Button>
|
||||
</Setting>
|
||||
<Setting>
|
||||
<span slot="title">Language</span>
|
||||
<p slot="description">
|
||||
The language used for Photon's UI.
|
||||
<Note>
|
||||
All languages other than US English are community translated, and may
|
||||
be incomplete!
|
||||
</Note>
|
||||
</p>
|
||||
<Select bind:value={$userSettings.language}>
|
||||
<option value={null}>Auto-Detect</option>
|
||||
{#each $locales as locale}
|
||||
<option value={locale}>{locale}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
</Setting>
|
||||
<Setting>
|
||||
<span slot="title">Post style</span>
|
||||
<ViewSelect showLabel={false} />
|
||||
|
||||
Reference in new issue
Block a user