diff --git a/bun.lockb b/bun.lockb
index 45e1b00d..537d7449 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/src/lib/components/lemmy/comment/CommentActions.svelte b/src/lib/components/lemmy/comment/CommentActions.svelte
index 697d71fd..01b54968 100644
--- a/src/lib/components/lemmy/comment/CommentActions.svelte
+++ b/src/lib/components/lemmy/comment/CommentActions.svelte
@@ -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
+{#if translating}
+
+{/if}
+
{$t('comment.actions.link')}
+ {#if $userSettings.translator}
+
{
+ // @ts-ignore
+ text.set(comment.comment.content)
+ translating = !translating
+ }}
+ >
+
+ {$t('post.actions.more.translate')}
+
+ {/if}
{#if $profile?.jwt}
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
dispatcher('edit', comment)}>
diff --git a/src/lib/components/lemmy/post/PostActions.svelte b/src/lib/components/lemmy/post/PostActions.svelte
index a8ae48a5..af956f09 100644
--- a/src/lib/components/lemmy/post/PostActions.svelte
+++ b/src/lib/components/lemmy/post/PostActions.svelte
@@ -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
{#if fediseerData}
@@ -94,6 +99,8 @@
{/if}
+
+
{$t('post.actions.more.share')}
+ {#if post.post.body && $userSettings.translator}
+
{
+ // @ts-ignore
+ text.set(post.post.body)
+ translating = !translating
+ }}
+ >
+
+ {$t('post.actions.more.translate')}
+
+ {/if}
{#if $profile?.jwt}
{
diff --git a/src/lib/components/markdown/MarkdownEditor.svelte b/src/lib/components/markdown/MarkdownEditor.svelte
index 5df9b5b0..298e5a4e 100644
--- a/src/lib/components/markdown/MarkdownEditor.svelte
+++ b/src/lib/components/markdown/MarkdownEditor.svelte
@@ -97,7 +97,7 @@
loading = false
}
- let previewing = false
+ export let previewing = false
const shortcuts = {
KeyB: () => wrapSelection('**', '**'),
@@ -174,7 +174,8 @@ overflow-hidden transition-colors"
>
{#if previewing}
diff --git a/src/lib/components/translate/Translation.svelte b/src/lib/components/translate/Translation.svelte
new file mode 100644
index 00000000..c3c7c971
--- /dev/null
+++ b/src/lib/components/translate/Translation.svelte
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+ {#if result}
+ {#await result}
+
+
+
+ {:then result}
+
+ {:catch err}
+
+ {/await}
+ {:else}
+
+ {/if}
+
+
diff --git a/src/lib/components/translate/translation.ts b/src/lib/components/translate/translation.ts
new file mode 100644
index 00000000..68de6e56
--- /dev/null
+++ b/src/lib/components/translate/translation.ts
@@ -0,0 +1,3 @@
+import { writable } from 'svelte/store'
+
+export let text = writable(undefined)
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 5a1501f9..eb5ffd20 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -375,6 +375,7 @@
"actions": "Actions",
"markRead": "Mark as Read",
"markUnread": "Mark as Unread",
+ "translate": "Translate",
"share": "Share",
"crosspost": "Crosspost",
"delete": "Delete",
@@ -589,6 +590,11 @@
"font": {
"title": "Font",
"description": "What font Photon uses in the UI."
+ },
+ "translation": {
+ "title": "Translation",
+ "description": "The LibreTranslate instance to use for translation.",
+ "instance": "Domain"
}
},
"embeds": {
diff --git a/src/lib/settings.ts b/src/lib/settings.ts
index ab9c9425..616ccb0f 100644
--- a/src/lib/settings.ts
+++ b/src/lib/settings.ts
@@ -80,6 +80,7 @@ interface Settings {
compactFeatured: boolean
}
language: string | null
+ translator: string | undefined
}
export const defaultSettings: Settings = {
@@ -138,6 +139,7 @@ export const defaultSettings: Settings = {
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
},
language: null,
+ translator: undefined,
}
export const userSettings = writable(defaultSettings)
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte
index 6c1f8762..7dafdae5 100644
--- a/src/routes/settings/+page.svelte
+++ b/src/routes/settings/+page.svelte
@@ -29,7 +29,7 @@
import { Button, Checkbox, Select } from 'mono-svelte'
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
- import { removeItem } from '$lib/util.js'
+ import { DOMAIN_REGEX_FORMS, removeItem } from '$lib/util.js'
import Section from './Section.svelte'
import ToggleSetting from './ToggleSetting.svelte'
import { locales, t } from '$lib/translations'
@@ -224,6 +224,17 @@
bind:selected={$userSettings.font}
/>
+
+ {$t('settings.app.translation.title')}
+
+ {$t('settings.app.translation.description')}
+
+
+