feat: add post and comment translation
This commit is contained in:
1 parent
e7d12916c3
commit
990f073715
9 files changed
+156
-3
No files matched your search
@@ -8,6 +8,7 @@
|
||||
EllipsisHorizontal,
|
||||
Flag,
|
||||
Icon,
|
||||
Language,
|
||||
PencilSquare,
|
||||
Square2Stack,
|
||||
Trash,
|
||||
@@ -24,6 +25,9 @@
|
||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import Translation from '$lib/components/translate/Translation.svelte'
|
||||
import { text } from '$lib/components/translate/translation'
|
||||
import { userSettings } from '$lib/settings'
|
||||
|
||||
export let comment: CommentView
|
||||
export let replying: boolean = false
|
||||
@@ -31,8 +35,13 @@
|
||||
const dispatcher = createEventDispatcher<{ edit: CommentView }>()
|
||||
|
||||
let reply = ''
|
||||
let translating = false
|
||||
</script>
|
||||
|
||||
{#if translating}
|
||||
<Translation bind:open={translating} />
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-row items-center gap-0.5 h-7 relative">
|
||||
<CommentVote
|
||||
bind:upvotes={comment.counts.upvotes}
|
||||
@@ -79,6 +88,18 @@
|
||||
<Icon src={Square2Stack} mini size="16" />
|
||||
<div>{$t('comment.actions.link')}</div>
|
||||
</MenuButton>
|
||||
{#if $userSettings.translator}
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
// @ts-ignore
|
||||
text.set(comment.comment.content)
|
||||
translating = !translating
|
||||
}}
|
||||
>
|
||||
<Icon src={Language} size="16" mini slot="prefix" />
|
||||
{$t('post.actions.more.translate')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile?.jwt}
|
||||
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
||||
<MenuButton on:click={() => dispatcher('edit', comment)}>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
EyeSlash,
|
||||
Flag,
|
||||
Icon,
|
||||
Language,
|
||||
Newspaper,
|
||||
PencilSquare,
|
||||
ServerStack,
|
||||
@@ -50,6 +51,8 @@
|
||||
import { fediseer, type Data } from '$lib/fediseer/fediseer'
|
||||
import Fediseer from '$lib/fediseer/Fediseer.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { text } from '$lib/components/translate/translation'
|
||||
import Translation from '$lib/components/translate/Translation.svelte'
|
||||
|
||||
export let post: PostView
|
||||
|
||||
@@ -62,6 +65,8 @@
|
||||
let fediseerOpen = false
|
||||
let fediseerData: Data | null = null
|
||||
let fediseerLoading = false
|
||||
|
||||
let translating = false
|
||||
</script>
|
||||
|
||||
{#if fediseerData}
|
||||
@@ -94,6 +99,8 @@
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
<Translation bind:open={translating} />
|
||||
|
||||
<div
|
||||
class="flex flex-row gap-2 items-center !h-8 flex-shrink-0"
|
||||
style={$$props.style ?? ''}
|
||||
@@ -247,6 +254,18 @@
|
||||
<Icon src={Share} width={16} mini slot="prefix" />
|
||||
{$t('post.actions.more.share')}
|
||||
</MenuButton>
|
||||
{#if post.post.body && $userSettings.translator}
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
// @ts-ignore
|
||||
text.set(post.post.body)
|
||||
translating = !translating
|
||||
}}
|
||||
>
|
||||
<Icon src={Language} size="16" mini slot="prefix" />
|
||||
{$t('post.actions.more.translate')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile?.jwt}
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
|
||||
Reference in new issue
Block a user