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(
|
||||
|
||||
Reference in new issue
Block a user