Skip to content

Commit

Permalink
fix: make translate feature mostly work
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyphyn committed Aug 1, 2024
1 parent 4b42e40 commit 19fa06b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
Binary file modified bun.lockb
Binary file not shown.
19 changes: 5 additions & 14 deletions src/lib/components/lemmy/post/PostActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@
BookmarkSlash,
BugAnt,
ChatBubbleOvalLeft,
ChatBubbleOvalLeftEllipsis,
CheckBadge,
EllipsisHorizontal,
Eye,
EyeSlash,
Flag,
GlobeAlt,
Home,
Icon,
Language,
Newspaper,
PencilSquare,
Scale,
ServerStack,
Share,
Trash,
Expand All @@ -36,12 +32,7 @@
} from '$lib/components/lemmy/moderation/moderation.js'
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
import { profile } from '$lib/auth.js'
import {
contentView,
deleteItem,
markAsRead,
save,
} from '$lib/lemmy/contentview.js'
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
import { setSessionStorage } from '$lib/session.js'
import { goto } from '$app/navigation'
import { userSettings, type View } from '$lib/settings.js'
Expand All @@ -55,11 +46,9 @@
toast,
} from 'mono-svelte'
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'
import { hidePost, postLink, type MediaType } from './helpers'
import { hidePost, type MediaType } from './helpers'
import { feature } from '$lib/version'
import Switch from '$lib/components/input/Switch.svelte'
import { instanceToURL } from '$lib/util'
Expand Down Expand Up @@ -92,7 +81,9 @@
</script>

{#if fediseerData}
<Fediseer bind:open={fediseerOpen} data={fediseerData} />
{#await import('$lib/fediseer/Fediseer.svelte') then { default: Fediseer }}
<Fediseer bind:open={fediseerOpen} data={fediseerData} />
{/await}
{/if}

{#if editing}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/markdown/MarkdownEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
class="flex flex-col border border-slate-200 border-b-slate-300 dark:border-t-zinc-700 dark:border-zinc-800
focus-within:border-primary-900 focus-within:dark:border-primary-100 focus-within:ring ring-slate-300
dark:ring-zinc-700 rounded-xl
overflow-hidden transition-colors"
overflow-hidden transition-colors {$$props.class}"
class:mt-1={label}
>
{#if previewing}
Expand Down
21 changes: 9 additions & 12 deletions src/lib/components/translate/Translation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
requestURL.searchParams.set('q', text)
requestURL.searchParams.set('source', from)
requestURL.searchParams.set('target', to)
requestURL.searchParams.set('alternatives', '')
result = fetch(requestURL.toString(), {
method: 'POST',
Expand Down Expand Up @@ -89,24 +88,22 @@
<Spinner width={32} />
</div>
{:then result}
{#if !error}
<MarkdownEditor
previewButton={false}
previewing
tools={false}
rows={8}
value={result.translatedText || 'Failed to translate'}
disabled
></MarkdownEditor>
{/if}
<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={err || 'Failed to translate'}
value="Failed to translate: {err}"
class="!border-red-500 !ring-red-500 !text-red-500"
></MarkdownEditor>
{/await}
Expand Down
15 changes: 12 additions & 3 deletions src/lib/components/ui/navbar/Profile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,18 @@
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="contents" on:click|stopPropagation={() => {}}>
<Select bind:value={$colorScheme} class="ml-auto my-auto w-24" size="sm">
<option value="system">{$t('nav.menu.colorscheme.system')}</option>
<option value="light">{$t('nav.menu.colorscheme.light')}</option>
<option value="dark">{$t('nav.menu.colorscheme.dark')}</option>
<option value="system">
<Icon src={ComputerDesktop} size="16" mini />
{$t('nav.menu.colorscheme.system')}
</option>
<option value="light">
<Icon src={Sun} size="16" mini />
{$t('nav.menu.colorscheme.light')}
</option>
<option value="dark">
<Icon src={Moon} size="16" mini />
{$t('nav.menu.colorscheme.dark')}
</option>
</Select>
</div>
</MenuButton>
Expand Down

0 comments on commit 19fa06b

Please sign in to comment.