cleanup: remove translation
This commit is contained in:
1 parent
87fba8af04
commit
acf92a7647
6 files changed
-180
No files matched your search
@@ -26,8 +26,6 @@
|
|||||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import Translation from '$lib/components/translate/Translation.svelte'
|
|
||||||
import { text } from '$lib/components/translate/translation'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -101,20 +99,6 @@
|
|||||||
<Icon src={Square2Stack} mini size="16" />
|
<Icon src={Square2Stack} mini size="16" />
|
||||||
<div>{$t('comment.actions.link')}</div>
|
<div>{$t('comment.actions.link')}</div>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if settings.translator}
|
|
||||||
<MenuButton
|
|
||||||
onclick={() => {
|
|
||||||
// @ts-ignore
|
|
||||||
text.set(comment.comment.content)
|
|
||||||
translating = !translating
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Language} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.translate')}
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
{#if $profile?.jwt}
|
{#if $profile?.jwt}
|
||||||
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
||||||
<MenuButton onclick={() => dispatcher('edit', comment)}>
|
<MenuButton onclick={() => dispatcher('edit', comment)}>
|
||||||
|
|||||||
@@ -55,7 +55,6 @@
|
|||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import { fediseer, type Data } from '$lib/fediseer/fediseer'
|
import { fediseer, type Data } from '$lib/fediseer/fediseer'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { text } from '$lib/components/translate/translation'
|
|
||||||
import { hidePost, postLink } from './helpers'
|
import { hidePost, postLink } from './helpers'
|
||||||
import { feature } from '$lib/version'
|
import { feature } from '$lib/version'
|
||||||
import Switch from '$lib/components/input/Switch.svelte'
|
import Switch from '$lib/components/input/Switch.svelte'
|
||||||
@@ -121,12 +120,6 @@
|
|||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if translating}
|
|
||||||
{#await import('$lib/components/translate/Translation.svelte') then { default: Translation }}
|
|
||||||
<Translation bind:open={translating} />
|
|
||||||
{/await}
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<footer
|
<footer
|
||||||
class="flex flex-row gap-2 items-center flex-shrink-0 {buttonHeight}"
|
class="flex flex-row gap-2 items-center flex-shrink-0 {buttonHeight}"
|
||||||
class:flex-row-reverse={settings.posts.reverseActions}
|
class:flex-row-reverse={settings.posts.reverseActions}
|
||||||
@@ -378,20 +371,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if post.post.body && settings.translator}
|
|
||||||
<MenuButton
|
|
||||||
onclick={() => {
|
|
||||||
// @ts-ignore
|
|
||||||
text.set(post.post.body)
|
|
||||||
translating = !translating
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Language} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.translate')}
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
{#if $profile?.jwt}
|
{#if $profile?.jwt}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { run } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { Button, Modal, Select, Spinner, TextArea } from 'mono-svelte'
|
|
||||||
import { text } from './translation'
|
|
||||||
import { locale, t } from '$lib/translations'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import { ArrowRight, Icon } from 'svelte-hero-icons'
|
|
||||||
import MarkdownEditor from '../markdown/MarkdownEditor.svelte'
|
|
||||||
|
|
||||||
interface TranslateResponse {
|
|
||||||
translatedText: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
open?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
let { open = $bindable(false) }: Props = $props()
|
|
||||||
let error = false
|
|
||||||
|
|
||||||
const opened = () => translate($text)
|
|
||||||
|
|
||||||
run(() => {
|
|
||||||
if (open) opened()
|
|
||||||
})
|
|
||||||
|
|
||||||
let result: Promise<TranslateResponse> | undefined = $state(undefined)
|
|
||||||
let from = $state('auto')
|
|
||||||
let to = $state($locale)
|
|
||||||
|
|
||||||
async function translate(text: string) {
|
|
||||||
const url = settings.translator
|
|
||||||
|
|
||||||
if (!url) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
error = false
|
|
||||||
|
|
||||||
const requestURL = new URL(`https://${url}/translate`)
|
|
||||||
requestURL.searchParams.set('q', text)
|
|
||||||
requestURL.searchParams.set('source', from)
|
|
||||||
requestURL.searchParams.set('target', to)
|
|
||||||
|
|
||||||
result = fetch(requestURL.toString(), {
|
|
||||||
method: 'POST',
|
|
||||||
}).then(async (res) => {
|
|
||||||
if (!res.ok) {
|
|
||||||
error = true
|
|
||||||
throw new Error(`${res.status} ${res.statusText}`)
|
|
||||||
return {
|
|
||||||
translatedText: `${res.status} ${res.statusText}`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return await res.json()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal title={$t('post.actions.more.translate')} bind:open>
|
|
||||||
<TextArea bind:value={$text} rows={2}>
|
|
||||||
{#snippet suffix()}
|
|
||||||
<Button onclick={() => translate($text)} color="primary">
|
|
||||||
{$t('post.actions.more.translate')}
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
|
||||||
</TextArea>
|
|
||||||
<div class="flex items-center gap-2 w-full">
|
|
||||||
<Select bind:value={from} class="flex-1">
|
|
||||||
<option value="auto">Auto</option>
|
|
||||||
</Select>
|
|
||||||
<Icon src={ArrowRight} mini size="20" />
|
|
||||||
<Select on:change={() => translate($text)} bind:value={to} class="flex-1">
|
|
||||||
<option value="en">English</option>
|
|
||||||
<option value="ar">Arabic</option>
|
|
||||||
<option value="zh">Chinese</option>
|
|
||||||
<option value="cs">Czech</option>
|
|
||||||
<option value="nl">Dutch</option>
|
|
||||||
<option value="fi">Finnish</option>
|
|
||||||
<option value="fr">French</option>
|
|
||||||
<option value="de">German</option>
|
|
||||||
<option value="el">Greek</option>
|
|
||||||
<option value="it">Italian</option>
|
|
||||||
<option value="ja">Japanese</option>
|
|
||||||
<option value="pl">Polish</option>
|
|
||||||
<option value="es">Spanish</option>
|
|
||||||
<option value="sv">Swedish</option>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
{#if result}
|
|
||||||
{#await result}
|
|
||||||
<div
|
|
||||||
style="height: 226px; width:100%;"
|
|
||||||
class="flex items-center justify-center"
|
|
||||||
>
|
|
||||||
<Spinner width={32} />
|
|
||||||
</div>
|
|
||||||
{:then result}
|
|
||||||
<MarkdownEditor
|
|
||||||
previewButton={false}
|
|
||||||
previewing
|
|
||||||
tools={false}
|
|
||||||
rows={8}
|
|
||||||
value={result.translatedText || 'Failed to translate'}
|
|
||||||
disabled
|
|
||||||
></MarkdownEditor>
|
|
||||||
{:catch err}
|
|
||||||
<MarkdownEditor
|
|
||||||
previewButton={false}
|
|
||||||
previewing
|
|
||||||
tools={false}
|
|
||||||
disabled
|
|
||||||
rows={8}
|
|
||||||
value="Failed to translate: {err}"
|
|
||||||
class="!border-red-500 !ring-red-500 !text-red-500"
|
|
||||||
></MarkdownEditor>
|
|
||||||
{/await}
|
|
||||||
{:else}
|
|
||||||
<TextArea disabled />
|
|
||||||
{/if}
|
|
||||||
</Modal>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { writable } from 'svelte/store'
|
|
||||||
|
|
||||||
export let text = writable<string>(undefined)
|
|
||||||
@@ -99,7 +99,6 @@ interface Settings {
|
|||||||
infiniteScroll: boolean
|
infiniteScroll: boolean
|
||||||
language: string | null
|
language: string | null
|
||||||
useRtl: boolean
|
useRtl: boolean
|
||||||
translator: string | undefined
|
|
||||||
parseTags: boolean
|
parseTags: boolean
|
||||||
tagRules: {
|
tagRules: {
|
||||||
[key: string]: 'hide' | 'blur'
|
[key: string]: 'hide' | 'blur'
|
||||||
@@ -181,7 +180,6 @@ export const defaultSettings: Settings = {
|
|||||||
infiniteScroll: true,
|
infiniteScroll: true,
|
||||||
language: env.PUBLIC_LANGUAGE ?? null,
|
language: env.PUBLIC_LANGUAGE ?? null,
|
||||||
useRtl: false,
|
useRtl: false,
|
||||||
translator: env.PUBLIC_TRANSLATOR ?? undefined,
|
|
||||||
parseTags: true,
|
parseTags: true,
|
||||||
tagRules: {
|
tagRules: {
|
||||||
cw: 'blur',
|
cw: 'blur',
|
||||||
|
|||||||
@@ -404,21 +404,6 @@
|
|||||||
title={$t('settings.app.duplicateTitles.title')}
|
title={$t('settings.app.duplicateTitles.title')}
|
||||||
description={$t('settings.app.duplicateTitles.description')}
|
description={$t('settings.app.duplicateTitles.description')}
|
||||||
/>
|
/>
|
||||||
<Setting>
|
|
||||||
{#snippet title()}
|
|
||||||
<span>{$t('settings.app.translation.title')}</span>
|
|
||||||
{/snippet}
|
|
||||||
{#snippet description()}
|
|
||||||
<span>
|
|
||||||
{$t('settings.app.translation.description')}
|
|
||||||
</span>
|
|
||||||
{/snippet}
|
|
||||||
<!-- <TextInput
|
|
||||||
bind:value={settings.translator}
|
|
||||||
label={$t('settings.app.translation.instance')}
|
|
||||||
pattern={DOMAIN_REGEX_FORMS}
|
|
||||||
/> -->
|
|
||||||
</Setting>
|
|
||||||
<div>
|
<div>
|
||||||
<ToggleSetting
|
<ToggleSetting
|
||||||
title={$t('settings.app.titleTags.title')}
|
title={$t('settings.app.titleTags.title')}
|
||||||
|
|||||||
Reference in new issue
Block a user