Merge pull request #239 from Xyphyn/i18n

Add support for localization
This commit is contained in:
Xylight authored and GitHub committed 2024-06-06 13:28:50 -07:00
commit 8756670c37
84 files changed
+2068 -1083

No files matched your search

+24 -17
View File
@@ -2,21 +2,14 @@
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import StickyCard from '$lib/components/ui/StickyCard.svelte'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { publishedToDate } from '$lib/components/util/date.js'
import { getClient } from '$lib/lemmy.js'
import type { PersonView, SiteView, Tagline } from 'lemmy-js-client'
import { Button, Disclosure, Popover } from 'mono-svelte'
import { Button } from 'mono-svelte'
import {
BuildingOffice,
Calendar,
ChartBar,
ChatBubbleOvalLeftEllipsis,
Icon,
InformationCircle,
Newspaper,
PencilSquare,
ServerStack,
UserGroup,
} from 'svelte-hero-icons'
@@ -24,6 +17,7 @@
import LabelStat from '../ui/LabelStat.svelte'
import ItemList from './generic/ItemList.svelte'
import { userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations'
export let site: SiteView
export let taglines: Tagline[] | undefined = undefined
@@ -49,15 +43,25 @@
</div>
</div>
<div class="flex flex-row gap-1 !border-0">
<Button href="/modlog" title="Modlog" color="ghost" size="square-md">
<Button
href="/modlog"
title={$t('routes.modlog')}
color="ghost"
size="square-md"
>
<Icon src={Newspaper} size="16" mini />
</Button>
<Button href="/legal" title="Legal" color="ghost" size="square-md">
<Button
href="/legal"
title={$t('routes.legal.title')}
color="ghost"
size="square-md"
>
<Icon src={BuildingOffice} size="16" mini />
</Button>
<Button
href="/instances"
title="Instances"
title={$t('routes.instances')}
class="3xl:rounded-l-none"
color="ghost"
size="square-md"
@@ -78,7 +82,8 @@
<Expandable>
<svelte:fragment slot="title">
<Icon src={InformationCircle} size="15" mini /> About
<Icon src={InformationCircle} size="15" mini />
{$t('cards.site.about')}
</svelte:fragment>
<Markdown source={site.site.description} />
<div class="my-4" />
@@ -87,21 +92,22 @@
<Expandable>
<svelte:fragment slot="title">
<Icon src={ChartBar} size="15" mini /> Stats
<Icon src={ChartBar} size="15" mini />
{$t('cards.site.stats')}
</svelte:fragment>
<div class="flex flex-row gap-4 flex-wrap">
<LabelStat
label="Users"
label={$t('content.users')}
content={site.counts.users.toString()}
formatted
/>
<LabelStat
label="Posts"
label={$t('content.posts')}
content={site.counts.posts.toString()}
formatted
/>
<LabelStat
label="Communities"
label={$t('content.communities')}
content={site.counts.communities.toString()}
formatted
/>
@@ -111,7 +117,8 @@
{#if admins}
<Expandable>
<svelte:fragment slot="title">
<Icon src={UserGroup} size="15" mini /> Admins
<Icon src={UserGroup} size="15" mini />
{$t('cards.site.admins')}
</svelte:fragment>
<ItemList
items={admins.map((a) => ({
@@ -22,6 +22,7 @@
import ShieldIcon from '../moderation/ShieldIcon.svelte'
import { page } from '$app/stores'
import { onMount } from 'svelte'
import { t } from '$lib/translations'
export let node: CommentNodeI
export let postId: number
@@ -50,11 +51,6 @@
node.comment_view.comment.content = newComment
editing = false
toast({
content: 'Successfully edited comment.',
type: 'success',
})
} catch (err) {
toast({
// @ts-ignore i hate this
@@ -145,7 +141,7 @@
src={Trash}
solid
size="12"
title="Deleted"
title={$t('post.badges.deleted')}
class="text-red-600 dark:text-red-500"
/>
{/if}
@@ -154,7 +150,7 @@
src={Bookmark}
solid
size="12"
title="Saved"
title={$t('post.badges.saved')}
class="text-yellow-600 dark:text-yellow-500"
/>
{/if}
@@ -181,7 +177,7 @@
<div
class="max-w-full my-2 border-l border-slate-200 dark:border-zinc-800 pl-4"
>
<h1 class="font-bold text-sm mb-2">Reply</h1>
<h1 class="font-bold text-sm mb-2">{$t('comment.reply')}</h1>
<CommentForm
{postId}
parentId={node.comment_view.comment.id}
@@ -8,6 +8,7 @@
EllipsisHorizontal,
Flag,
Icon,
Language,
PencilSquare,
Square2Stack,
Trash,
@@ -23,6 +24,10 @@
import { profile } from '$lib/auth.js'
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
@@ -30,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}
@@ -47,7 +57,7 @@
disabled={comment.post.locked}
>
<Icon src={ArrowUturnLeft} width={14} height={14} mini />
<span class="text-xs">Reply</span>
<span class="text-xs">{$t('comment.reply')}</span>
</Button>
{#if $profile?.user && (amMod($profile?.user, comment.community) || isAdmin($profile.user))}
<CommentModerationMenu bind:item={comment} />
@@ -56,7 +66,7 @@
<Button
slot="target"
class="!p-1 text-slate-600 dark:text-zinc-400"
aria-label="Comment actions"
title={$t('comment.actions.label')}
color="tertiary"
>
<Icon
@@ -67,7 +77,7 @@
slot="prefix"
/>
</Button>
<MenuDivider>Actions</MenuDivider>
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
<MenuButton
on:click={() => {
navigator.share?.({
@@ -76,13 +86,25 @@
}}
>
<Icon src={Square2Stack} mini size="16" />
<divv>Copy Link</divv>
<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)}>
<Icon src={PencilSquare} mini size="16" />
<span>Edit</span>
<span>{$t('post.actions.more.edit')}</span>
</MenuButton>
{/if}
<MenuButton
@@ -92,7 +114,9 @@
}}
>
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
<span>{comment.saved ? 'Unsave' : 'Save'}</span>
<span>
{comment.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
</span>
</MenuButton>
{#if $profile?.user && $profile.jwt && $profile.user.local_user_view.person.id == comment.creator.id}
<MenuButton
@@ -107,13 +131,17 @@
}}
>
<Icon src={Trash} mini size="16" />
<span>{comment.comment.deleted ? 'Restore' : 'Delete'}</span>
<span>
{comment.comment.deleted
? $t('post.actions.more.restore')
: $t('post.actions.more.delete')}
</span>
</MenuButton>
{/if}
{#if $profile.jwt && $profile.user?.local_user_view.person.id != comment.creator.id}
<MenuButton on:click={() => report(comment)} color="danger-subtle">
<Icon src={Flag} mini size="16" />
<span>Report</span>
<span>{$t('moderation.report')}</span>
</MenuButton>
{/if}
{/if}
@@ -8,6 +8,7 @@
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { placeholders } from '$lib/util.js'
import { Button } from 'mono-svelte'
import { t } from '$lib/translations'
export let postId: number
export let parentId: number | undefined = undefined
@@ -40,10 +41,6 @@
dispatch('comment', response)
value = ''
toast({
content: 'Your comment was submitted.',
type: 'success',
})
} catch (err) {
console.error(err)
toast({
@@ -69,7 +66,7 @@
{...$$restProps}
{rows}
placeholder={locked
? 'This post is locked.'
? $t('comment.locked')
: placeholder ?? placeholders.get('comment')}
bind:value
disabled={locked || loading}
@@ -92,7 +89,7 @@
{loading}
disabled={locked || loading}
>
Submit
{$t('form.submit')}
</Button>
</div>
{/if}
@@ -17,6 +17,7 @@
import { shouldShowVoteColor } from '../post/PostVote.svelte'
import { fly } from 'svelte/transition'
import { backOut } from 'svelte/easing'
import { t } from '$lib/translations'
export let vote: number = 0
export let upvotes: number
@@ -25,7 +26,7 @@
const castVote = async (newVote: number) => {
if (!$profile?.jwt) {
toast({ content: 'You must be logged in to vote.', type: 'warning' })
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
return
}
@@ -18,6 +18,7 @@
import { Button } from 'mono-svelte'
import { afterNavigate } from '$app/navigation'
import { backOut } from 'svelte/easing'
import { t } from '$lib/translations'
export let nodes: CommentNodeI[]
export let isParent: boolean
@@ -62,7 +63,7 @@
if (newComments.comments.length == 0) {
loadingChildren = false
toast({
content: 'The API returned no comments.',
content: $t('toast.noComments'),
type: 'error',
})
return
@@ -81,7 +82,7 @@
parent.children = treeParent.children
if (treeParent.children.length == 0) {
toast({
content: 'The API returned no comments.',
content: $t('toast.noComments'),
type: 'warning',
})
}
@@ -90,7 +91,7 @@
parent.children = tree
if (tree.length == 0) {
toast({
content: 'The API returned no comments.',
content: $t('toast.noComments'),
type: 'warning',
})
}
@@ -99,7 +100,7 @@
} catch (error) {
console.error(error)
toast({
content: `Failed to fetch comments. ${error as any}`,
content: error as any,
type: 'error',
})
}
@@ -112,7 +113,7 @@
? 'divide-y dark:divide-zinc-800 divide-slate-100'
: 'pl-3.5 border-l border-slate-200 dark:border-zinc-800 my-1'}
>
{#each nodes as node (node.comment_view.comment.id)}
{#each nodes as node}
<Comment
postId={post.id}
bind:node
@@ -46,6 +46,7 @@
import ShieldIcon from '../moderation/ShieldIcon.svelte'
import ItemList from '../generic/ItemList.svelte'
import { communityLink, userLink } from '$lib/lemmy/generic'
import { t } from '$lib/translations'
export let community_view: CommunityView
export let moderators: CommunityModeratorView[] = []
@@ -83,7 +84,7 @@
try {
const loading = toast({
content: `${blocked ? 'Unblocking' : 'blocking'} community...`,
content: ``,
loading: true,
})
@@ -95,9 +96,9 @@
removeToast(loading)
toast({
content: `Successfully ${
blocked ? 'unblocked' : 'blocked'
} that community.`,
content: blocked
? $t('toast.unblockedCommunity')
: $t('toast.blockedCommunity'),
type: 'success',
})
} catch (error) {
@@ -119,14 +120,14 @@
async function purgeCommunity() {
purgingCommunity = false
const purgeToast = toast({ content: 'Purging community...', loading: true })
const purgeToast = toast({ content: '', loading: true })
try {
await client().purgeCommunity({
community_id: community_view.community.id,
})
removeToast(purgeToast)
toast({ content: 'Purged that community.', type: 'success' })
toast({ content: $t('toast.purgedCommunity'), type: 'success' })
} catch (e) {
toast({ content: e as any, type: 'error' })
}
@@ -136,7 +137,7 @@
if (!$profile?.jwt) return
try {
const loading = toast({
content: `Blocking instance...`,
content: ``,
loading: true,
})
@@ -159,14 +160,12 @@
{#if purgingCommunity}
<Modal bind:open={purgingCommunity}>
<svelte:fragment slot="title">Purging Community</svelte:fragment>
<svelte:fragment slot="title">
{$t('admin.purgeCommunity.title')}
</svelte:fragment>
<CommunityLink avatar community={community_view.community} />
<p>
Purging community <span class="font-bold">
{community_view.community.title}
</span>
</p>
<p>
Are you sure you want to do this? (The button will enable in 3 seconds.)
{$t('admin.purgeCommunity.warning')}
</p>
<div class="flex flex-row gap-2">
<Button
@@ -174,7 +173,7 @@
on:click={() => (purgingCommunity = false)}
class="flex-1"
>
Cancel
{$t('common.cancel')}
</Button>
<Button
size="lg"
@@ -183,7 +182,7 @@
disabled={!purgeEnabled}
class="flex-1"
>
Purge
{$t('admin.purge')}
</Button>
</div>
</Modal>
@@ -224,23 +223,25 @@
>
<Expandable class="!pt-0">
<svelte:fragment slot="title">
<Icon src={InformationCircle} size="15" mini /> About
<Icon src={InformationCircle} size="15" mini />
{$t('cards.site.about')}
</svelte:fragment>
<Markdown source={community_view.community.description} />
</Expandable>
<Expandable>
<svelte:fragment slot="title">
<Icon src={ChartBar} size="15" mini /> Stats
<Icon src={ChartBar} size="15" mini />
{$t('cards.site.stats')}
</svelte:fragment>
<div class="flex flex-row gap-4 flex-wrap">
<LabelStat
label="Members"
label={$t('cards.community.members')}
content={community_view.counts.subscribers.toString()}
formatted
/>
<LabelStat
label="Posts"
label={$t('content.posts')}
content={community_view.counts.posts.toString()}
formatted
/>
@@ -250,7 +251,8 @@
{#if moderators && moderators.length > 0}
<Expandable>
<svelte:fragment slot="title">
<ShieldIcon width={15} filled /> Moderators
<ShieldIcon width={15} filled />
{$t('cards.community.moderators')}
</svelte:fragment>
<ItemList
items={moderators.map((m) => ({
@@ -286,8 +288,8 @@
/>
{community_view.subscribed == 'Subscribed' ||
community_view.subscribed == 'Pending'
? 'Subscribed'
: 'Subscribe'}
? $t('cards.community.subscribed')
: $t('cards.community.subscribe')}
</Button>
{/if}
{#if $profile?.user && amMod($profile.user, community_view.community)}
@@ -307,17 +309,19 @@
</Button>
<MenuButton href="/modlog?community={community_view.community.id}">
<Icon src={Newspaper} size="16" mini />
Modlog
{$t('cards.community.modlog')}
</MenuButton>
{#if $profile?.jwt}
<MenuButton color="danger-subtle" size="lg" on:click={block}>
<Icon src={NoSymbol} size="16" mini slot="prefix" />
{community_view.blocked ? 'Unblock' : 'Block'}
{community_view.blocked
? $t('cards.community.unblock')
: $t('cards.community.block')}
</MenuButton>
{#if $profile?.user}
<MenuButton color="danger-subtle" size="lg" on:click={blockInstance}>
<Icon src={BuildingOffice2} size="16" mini slot="prefix" />
Block instance
{$t('cards.community.blockInstance')}
</MenuButton>
{/if}
{#if $profile?.user && isAdmin($profile.user)}
@@ -326,7 +330,7 @@
on:click={() => (purgingCommunity = !purgingCommunity)}
>
<Icon src={Fire} size="16" mini slot="prefix" />
Purge
{$t('admin.purge')}
</MenuButton>
{/if}
{/if}
@@ -7,6 +7,8 @@
import { addSubscription } from '$lib/lemmy/user.js'
import { Button, Checkbox, TextInput } from 'mono-svelte'
import { uploadImage } from '$lib/util.js'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
/**
* The community ID to edit.
@@ -68,7 +70,7 @@
})
toast({
content: `Your community was ${edit ? 'saved' : 'created'}.`,
content: $t('toast.updatedCommunity'),
type: 'success',
})
@@ -106,23 +108,31 @@
<form on:submit|preventDefault={submit} class="flex flex-col gap-4 h-full">
<slot name="formtitle">
<h1 class="text-2xl font-bold">Create Community</h1>
<Header>{$t('routes.createCommunity')}</Header>
</slot>
<TextInput
required
label="Name"
label={$t('form.name')}
bind:value={formData.name}
on:input={() => {
formData.name = formData.name.toLowerCase().replaceAll(' ', '_')
}}
disabled={edit != undefined}
/>
<TextInput required label="Display name" bind:value={formData.displayName} />
<ImageInput label="Icon" bind:files={formData.icon} />
<ImageInput label="Banner" bind:files={formData.banner} />
<MarkdownEditor previewButton label="Sidebar" bind:value={formData.sidebar} />
<TextInput
required
label={$t('form.profile.displayName')}
bind:value={formData.displayName}
/>
<ImageInput label={$t('form.profile.avatar')} bind:files={formData.icon} />
<ImageInput label={$t('form.profile.banner')} bind:files={formData.banner} />
<MarkdownEditor
previewButton
label={$t('routes.admin.config.banner')}
bind:value={formData.sidebar}
/>
<Checkbox bind:checked={formData.nsfw}>NSFW</Checkbox>
<Checkbox bind:checked={formData.nsfw}>{$t('post.badges.nsfw')}</Checkbox>
<Checkbox bind:checked={formData.postsLockedToModerators}>
Only moderators can post
</Checkbox>
@@ -134,6 +144,6 @@
loading={formData.submitting}
disabled={formData.submitting}
>
{edit ? 'Save' : 'Create'}
{edit ? $t('common.save') : $t('form.submit')}
</Button>
</form>
@@ -20,6 +20,7 @@
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
import LabelStat from '$lib/components/ui/LabelStat.svelte'
import PostBody from '../post/PostBody.svelte'
import { t } from '$lib/translations'
export let community: CommunityView
@@ -77,9 +78,9 @@
slot="prefix"
/>
{#if isSubscribed(community.subscribed)}
Subscribed
{$t('cards.community.subscribed')}
{:else}
Subscribe
{$t('cards.community.subscribe')}
{/if}
</Button>
</Subscribe>
@@ -6,6 +6,7 @@
import { Select } from 'mono-svelte'
import { GlobeAmericas, Icon } from 'svelte-hero-icons'
import { amModOfAny } from '../moderation/moderation'
import { t } from '$lib/translations'
export let selected: string
export let navigate: boolean = true
@@ -33,19 +34,19 @@
{#if showLabel}
<span class="flex items-center gap-1">
<Icon src={GlobeAmericas} size="16" mini />
Location
{$t('filter.location.label')}
</span>
{/if}
</svelte:fragment>
<option value="All">All</option>
<option value="Local">Local</option>
<option value="All">{$t('filter.location.all')}</option>
<option value="Local">{$t('filter.location.local')}</option>
<option value="Subscribed" disabled={$profile?.jwt == undefined}>
Subscribed
{$t('filter.location.subscribed')}
</option>
<option
value="ModeratorView"
disabled={!$profile?.jwt || !amModOfAny($profile?.user)}
>
Moderator
{$t('filter.location.moderator')}
</option>
</Select>
+30 -23
View File
@@ -2,6 +2,7 @@
import { page } from '$app/stores'
import { site } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings'
import { t } from '$lib/translations'
import { searchParam } from '$lib/util.js'
import { feature } from '$lib/version.js'
import type { SortType } from 'lemmy-js-client'
@@ -33,21 +34,19 @@
>
<span slot="label" class="flex items-center gap-1">
<Icon src={ChartBar} size="13" mini />
Sort
{$t('filter.sort.label')}
</span>
<option value="Active">Active</option>
<option value="Hot">Hot</option>
<option value="Active">{$t('filter.sort.active')}</option>
<option value="Hot">{$t('filter.sort.hot')}</option>
{#if feature('scaledSort', $site?.version)}
<option value="Scaled">Scaled</option>
<option value="Scaled">{$t('filter.sort.scaled')}</option>
{/if}
<option value="TopAll">Top</option>
<option value="New">New</option>
{#if feature('controversialSort', $site?.version)}
<option value="Controversial">Controversial</option>
{/if}
<option value="Old">Old</option>
<option value="MostComments">Comments</option>
<option value="NewComments">New Replies</option>
<option value="TopAll">{$t('filter.sort.top.label')}</option>
<option value="New">{$t('filter.sort.new')}</option>
<option value="Old">{$t('filter.sort.old')}</option>
<option value="Controversial">{$t('filter.sort.controversial')}</option>
<option value="MostComments">{$t('filter.sort.mostcomments')}</option>
<option value="NewComments">{$t('filter.sort.newcomments')}</option>
</Select>
{#if selected?.startsWith('Top')}
<div transition:fly={{ easing: backOut, x: 2 }}>
@@ -62,18 +61,26 @@
>
<span slot="label" class="flex items-center gap-1">
<Icon src={Clock} size="15" mini />
Time
{$t('filter.sort.top.time.label')}
</span>
<option value="TopAll">All</option>
<option value="TopNineMonths">9 Months</option>
<option value="TopSixMonths">6 Months</option>
<option value="TopThreeMonths">3 Months</option>
<option value="TopMonth">Month</option>
<option value="TopWeek">Week</option>
<option value="TopDay">Day</option>
<option value="TopTwelveHour">12 Hours</option>
<option value="TopSixHour">6 Hours</option>
<option value="TopHour">Hour</option>
<option value="TopAll">{$t('filter.sort.top.time.all')}</option>
<option value="TopNineMonths">
{$t('filter.sort.top.time.9months')}
</option>
<option value="TopSixMonths">
{$t('filter.sort.top.time.6months')}
</option>
<option value="TopThreeMonths">
{$t('filter.sort.top.time.3months')}
</option>
<option value="TopMonth">{$t('filter.sort.top.time.month')}</option>
<option value="TopWeek">{$t('filter.sort.top.time.week')}</option>
<option value="TopDay">{$t('filter.sort.top.time.day')}</option>
<option value="TopTwelveHour">
{$t('filter.sort.top.time.12hours')}
</option>
<option value="TopSixHour">{$t('filter.sort.top.time.6hours')}</option>
<option value="TopHour">{$t('filter.sort.top.time.hour')}</option>
</Select>
</div>
{/if}
@@ -1,5 +1,6 @@
<script lang="ts">
import { userSettings } from '$lib/settings.js'
import { t } from '$lib/translations'
import { Select } from 'mono-svelte'
import { Icon, ViewColumns } from 'svelte-hero-icons'
@@ -11,12 +12,12 @@
{#if showLabel}
<span class="flex items-center gap-1">
<Icon src={ViewColumns} size="14" mini />
View
{$t('filter.view.label')}
</span>
{/if}
</svelte:fragment>
<option value="cozy">Cozy</option>
<option value="list">List</option>
<option value="compact">Compact</option>
<option value="card">Legacy</option>
<option value="cozy">{$t('filter.view.cozy')}</option>
<option value="list">{$t('filter.view.list')}</option>
<option value="compact">{$t('filter.view.compact')}</option>
<option value="card">{$t('filter.view.legacy')}</option>
</Select>
@@ -1,38 +1,38 @@
<script lang="ts">
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import type { Person } from 'lemmy-js-client'
import { Button, Modal } from 'mono-svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { t } from '$lib/translations'
import type { Person } from 'lemmy-js-client'
import { Button, Modal } from 'mono-svelte'
export let open: boolean = false
export let user: Person
export let open: boolean = false
export let user: Person
export let denying: boolean
export let denying: boolean
export let denyReason: string = ''
export let denyReason: string = ''
let loading = false
let loading = false
function deny() {
denying = true
open = false
}
function deny() {
denying = true
open = false
}
</script>
<Modal bind:open>
<h1 class="text-2xl font-bold" slot="title">Deny Application</h1>
<form on:submit|preventDefault={() => deny()} class="flex flex-col gap-4">
<p class="inline-flex flex-row gap-2 items-center">
Denying <UserLink avatar {user} />'s Application
</p>
<MarkdownEditor
bind:value={denyReason}
label="Deny Reason (optional)"
placeholder="Application Reason breaks rule #3"
rows={4}
/>
<Button color="primary" size="lg" submit {loading} disabled={loading}>
Deny
</Button>
</form>
<h1 class="text-2xl font-bold" slot="title">
{$t('routes.admin.applications.modalTitle')}
</h1>
<form on:submit|preventDefault={() => deny()} class="flex flex-col gap-4">
<UserLink avatar {user} />
<MarkdownEditor
bind:value={denyReason}
label={$t('routes.admin.applications.reason')}
rows={4}
/>
<Button color="primary" size="lg" submit {loading} disabled={loading}>
{$t('routes.admin.applications.deny')}
</Button>
</form>
</Modal>
@@ -3,8 +3,10 @@
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { getClient } from '$lib/lemmy.js'
import { t } from '$lib/translations'
import type { Person } from 'lemmy-js-client'
import { Button, Modal, toast } from 'mono-svelte'
import { Icon, PaperAirplane } from 'svelte-hero-icons'
export let open: boolean = false
export let user: Person
@@ -25,7 +27,7 @@
})
toast({
content: 'Successfully sent that person a message.',
content: $t('toast.sentMessage'),
type: 'success',
})
@@ -45,16 +47,16 @@
<h1 class="text-2xl font-bold" slot="title">Message</h1>
<form on:submit|preventDefault={sendMessage} class="flex flex-col gap-4">
<p class="inline-flex flex-row gap-2 items-center">
Sending <UserLink avatar {user} /> a message
<Icon src={PaperAirplane} size="16" mini />
<UserLink avatar {user} />
</p>
<MarkdownEditor
bind:value={message}
label="Message"
placeholder="your hair looks nice today"
label={$t('content.message')}
rows={4}
/>
<Button color="primary" size="lg" submit {loading} disabled={loading}>
Send
{$t('common.send')}
</Button>
</form>
</Modal>
@@ -6,6 +6,8 @@
import { profile } from '$lib/auth.js'
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { t } from '$lib/translations'
import CommunityLink from '../community/CommunityLink.svelte'
export let open = false
let item: Person | undefined
@@ -40,7 +42,7 @@
date = Date.parse(expires)
if (Number.isNaN(date)) {
toast({
content: 'Invalid date. It must be an absolute date.',
content: $t('toast.invalidDateAbsolute'),
type: 'error',
})
@@ -51,7 +53,7 @@
if (date < Date.now()) {
toast({
content: 'Invalid date. It is before the current time.',
content: $t('toast.invalidDateBeforeCurrent'),
type: 'error',
})
@@ -82,9 +84,7 @@
open = false
toast({
content: `Successfully ${
banned ? 'unbanned' : 'banned'
} that user. You may need to refresh to see changes.`,
content: banned ? $t('toast.unbannedUser') : $t('toast.bannedUser'),
type: 'success',
})
@@ -101,42 +101,38 @@
</script>
<Modal bind:open class="max-w-xl w-full">
<h1 slot="title">{banned ? 'Unbanning' : 'Banning'} user</h1>
<h1 slot="title">
{banned ? $t('moderation.ban.unbanning') : $t('moderation.ban.banning')}
</h1>
{#if item}
<form class="flex flex-col gap-4" on:submit|preventDefault={submit}>
<div class="flex items-center gap-1">
<Avatar url={item.avatar} alt={item.name} width={24} />
<span class="font-bold">{item.name}</span>
</div>
<p>
{banned ? 'Unbanning' : 'Banning'} from
<span class="font-bold">{community ? community.name : 'site'}</span>
</p>
{#if community}
<CommunityLink {community} avatar />
{/if}
<MarkdownEditor
required
bind:value={reason}
label="Reason"
placeholder="Why are you {banned
? 'unbanning'
: 'banning'} {item.name}?"
label={$t('moderation.reason')}
/>
{#if !banned}
<Checkbox bind:checked={deleteData}>
Delete data
{$t('moderation.ban.deleteData')}
<svelte:fragment slot="description">
This will delete ALL of this user's posts and comments on this {community
? 'community'
: 'site'}.
{$t('moderation.ban.warning')}
</svelte:fragment>
</Checkbox>
<TextInput
bind:value={expires}
label="Expires (UTC)"
label={$t('moderation.ban.expires')}
placeholder="2024 August 5"
/>
{/if}
<Button submit color="primary" {loading} disabled={loading} size="lg">
Submit
{$t('form.submit')}
</Button>
</form>
{/if}
@@ -6,6 +6,7 @@
import { profile } from '$lib/auth.js'
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
import { t } from '$lib/translations'
export let item: PostView | CommentView
</script>
@@ -22,16 +23,20 @@
</Button>
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
<MenuDivider>
Moderation {#if !item.community.local && !amMod($profile.user, item.community)}
(Instance Only)
{#if !item.community.local && !amMod($profile.user, item.community)}
{$t('moderation.labelInstanceOnly')}
{:else}
{$t('moderation.label')}
{/if}
</MenuDivider>
<MenuButton color="success-subtle" on:click={() => remove(item)}>
<Icon src={Trash} size="16" mini />
{#if isCommentView(item)}
{item.comment.removed ? 'Restore' : 'Remove'}
{item.comment.removed
? $t('moderation.restore')
: $t('moderation.remove')}
{:else}
{item.post.removed ? 'Restore' : 'Remove'}
{item.post.removed ? $t('moderation.restore') : $t('moderation.remove')}
{/if}
</MenuButton>
{#if $profile?.user && $profile.user?.local_user_view.person.id != item.creator.id}
@@ -42,17 +47,17 @@
>
<Icon src={ShieldExclamation} size="16" mini />
{item.creator_banned_from_community
? 'Unban from community'
: 'Ban from community'}
? $t('moderation.ban.unbanFromCommunity')
: $t('moderation.ban.banFromCommunity')}
</MenuButton>
{/if}
{/if}
{#if $profile?.user && isAdmin($profile.user)}
<MenuDivider>Admin</MenuDivider>
<MenuDivider>{$t('admin.label')}</MenuDivider>
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
<Icon src={Fire} size="16" mini slot="prefix" />
Purge
{$t('admin.purge')}
</MenuButton>
{/if}
</Menu>
@@ -15,6 +15,8 @@
import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
import { profile } from '$lib/auth.js'
import { Button } from 'mono-svelte'
import { t } from '$lib/translations'
import ShieldIcon from './ShieldIcon.svelte'
export let item: PostView | CommentView
@@ -34,11 +36,6 @@
})
item.post.locked = lock
toast({
content: `Successfully ${lock ? 'locked' : 'unlocked'} that post.`,
type: 'success',
})
} catch (err) {
toast({
content: err as any,
@@ -62,11 +59,6 @@
})
item.post.featured_community = pinned
toast({
content: `Successfully ${pinned ? 'pinned' : 'unpinned'} that post.`,
type: 'success',
})
} catch (err) {
toast({
content: err as any,
@@ -87,26 +79,14 @@
loading={acting}
{...$$restProps}
>
<svg
width="16"
height="16"
viewBox="0 0 20 22"
fill="none"
xmlns="http://www.w3.org/2000/svg"
slot="prefix"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M10.516 1.17C10.3767 1.03791 10.192 0.964283 10 0.964283C9.80801 0.964283 9.62333 1.03791 9.484 1.17C7.36127 3.18588 4.53412 4.29133 1.607 4.25C1.44753 4.24793 1.29156 4.29674 1.16172 4.38935C1.03189 4.48196 0.934957 4.61355 0.885 4.765C0.462973 6.05116 0.248618 7.39637 0.25 8.75C0.25 14.692 4.314 19.683 9.813 21.098C9.93566 21.1296 10.0643 21.1296 10.187 21.098C15.686 19.683 19.75 14.692 19.75 8.75C19.75 7.36 19.527 6.02 19.115 4.765C19.0652 4.61336 18.9684 4.48156 18.8385 4.38875C18.7087 4.29595 18.5526 4.247 18.393 4.249L18.25 4.25C15.254 4.25 12.533 3.08 10.516 1.17Z"
fill="currentColor"
/>
</svg>
<ShieldIcon filled width={16} />
</Button>
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
<MenuDivider>
Moderation {#if !item.community.local && !amMod($profile.user, item.community)}
(Instance Only)
{#if !item.community.local && !amMod($profile.user, item.community)}
{$t('moderation.labelInstanceOnly')}
{:else}
{$t('moderation.label')}
{/if}
</MenuDivider>
<MenuButton
@@ -121,7 +101,7 @@
mini
slot="prefix"
/>
{item.post.locked ? 'Unlock' : 'Lock'}
{item.post.locked ? $t('moderation.unlock') : $t('moderation.lock')}
</MenuButton>
<MenuButton
@@ -135,18 +115,24 @@
<div
class="flex flex-row gap-2 text-left items-center justify-between w-full"
>
<span>{item.post.featured_community ? 'Unfeature' : 'Feature'}</span>
<span>
{item.post.featured_community
? $t('moderation.unfeature')
: $t('moderation.feature')}
</span>
{#if isAdmin($profile.user)}
<span class="text-xs opacity-80">Community</span>
<span class="text-xs opacity-80">{$t('form.post.community')}</span>
{/if}
</div>
</MenuButton>
<MenuButton color="danger-subtle" on:click={() => remove(item)}>
<Icon src={Trash} size="16" mini />
{#if isCommentView(item)}
{item.comment.removed ? 'Restore' : 'Remove'}
{item.comment.removed
? $t('moderation.restore')
: $t('moderation.remove')}
{:else}
{item.post.removed ? 'Restore' : 'Remove'}
{item.post.removed ? $t('moderation.restore') : $t('moderation.remove')}
{/if}
</MenuButton>
{#if $profile?.user && $profile.user.local_user_view.person.id != item.creator.id}
@@ -157,13 +143,13 @@
>
<Icon src={ShieldExclamation} size="16" mini />
{item.creator_banned_from_community
? 'Unban from community'
: 'Ban from community'}
? $t('moderation.ban.unbanFromCommunity')
: $t('moderation.ban.banFromCommunity')}
</MenuButton>
{/if}
{/if}
{#if $profile?.user && isAdmin($profile.user)}
<MenuDivider>Admin</MenuDivider>
<MenuDivider>{$t('admin.label')}</MenuDivider>
<MenuButton
color="success-subtle"
on:click={() =>
@@ -173,13 +159,17 @@
<div
class="flex flex-row gap-2 text-left items-center justify-between w-full"
>
<span>{item.post.featured_local ? 'Unfeature' : 'Feature'}</span>
<span class="text-xs opacity-80">Instance</span>
<span>
{item.post.featured_local
? $t('moderation.unfeature')
: $t('moderation.feature')}
</span>
<span class="text-xs opacity-80">{$t('admin.instance')}</span>
</div>
</MenuButton>
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
<Icon src={Fire} size="16" mini />
Purge
{$t('admin.purge')}
</MenuButton>
{/if}
</Menu>
@@ -14,6 +14,7 @@
import { fullCommunityName } from '$lib/util.js'
import { amMod, isAdmin } from './moderation'
import { Button, Checkbox, Modal } from 'mono-svelte'
import { t } from '$lib/translations'
export let open: boolean
export let item: PostView | CommentView | undefined = undefined
@@ -68,7 +69,7 @@
}
toast({
content: 'Successfully purged that submission.',
content: $t('moderation.removeSubmission.successPurge'),
type: 'success',
})
@@ -81,7 +82,7 @@
if (commentReason) {
if (replyReason == '') {
toast({
content: 'Your reply cannot be empty if "Reply reason" is enabled.',
content: $t('moderation.removeSubmission.failEmptyReply'),
})
return
}
@@ -96,7 +97,7 @@
})
.catch(() => {
toast({
content: 'Failed to message user. Removing anyway...',
content: $t('moderation.removeSubmission.failMessage'),
type: 'warning',
})
})
@@ -109,7 +110,7 @@
})
.catch(() => {
toast({
content: 'Failed to post reply. Removing anyway...',
content: $t('moderation.removeSubmission.failReply'),
type: 'warning',
})
})
@@ -134,13 +135,6 @@
}
open = false
toast({
content: `Successfully ${
removed ? 'restored' : 'removed'
} that submission.`,
type: 'success',
})
} catch (err) {
toast({
content: err as any,
@@ -166,7 +160,11 @@
<Modal bind:open>
<span slot="title">
{purge ? 'Purging' : removed ? 'Restoring' : 'Removing'} submission
{purge
? $t('moderation.removeSubmission.titlePurge')
: removed
? $t('moderation.removeSubmission.titleRestore')
: $t('moderation.removeSubmission.title')}
</span>
{#if item}
<form
@@ -195,12 +193,17 @@
/>
{#if !removed && $profile?.user && (amMod($profile.user, item.community) || (isAdmin($profile.user) && item.community.local))}
<Checkbox bind:checked={commentReason}>Reply with reason</Checkbox>
<Checkbox bind:checked={commentReason}>
{$t('moderation.removeSubmission.withReason')}
</Checkbox>
{#if commentReason}
<MultiSelect
options={[false, true]}
optionNames={['Comment', 'Message']}
optionNames={[
$t('moderation.removeSubmission.comment'),
$t('moderation.removeSubmission.message'),
]}
bind:selected={privateMessage}
/>
<MarkdownEditor
@@ -209,7 +212,7 @@
rows={3}
>
<div class="flex justify-between items-end mb-1" slot="label">
Reply
{$t('comment.reply')}
<Select bind:value={preset} placeholder="No preset">
{#each $userSettings.moderation.presets as preset}
<option value={preset.content}>
@@ -231,9 +234,9 @@
>
<Icon src={purge ? Fire : Trash} mini size="16" slot="prefix" />
{#if purge}
Purge
{$t('admin.purge')}
{:else}
{removed ? 'Restore' : 'Remove'}
{removed ? $t('moderation.restore') : $t('moderation.remove')}
{/if}
</Button>
</form>
@@ -8,6 +8,8 @@
import { Button, Modal } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { onMount } from 'svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations'
export let open: boolean
export let item: PostView | CommentView | undefined = undefined
@@ -39,7 +41,7 @@
}
open = false
toast({
content: 'That submission has been reported.',
content: $t('moderation.reportModal.success'),
type: 'success',
})
} catch (err) {
@@ -59,10 +61,9 @@
</script>
<Modal bind:open>
<h1 class="font-bold text-2xl" slot="title">Report</h1>
<Header slot="title">{$t('moderation.reportModal.title')}</Header>
<form class="flex flex-col gap-4" on:submit|preventDefault={report}>
{#if item}
<span>Reporting this submission</span>
<div class="pointer-events-none list-none">
{#if isComment(item)}
<Comment
@@ -83,12 +84,11 @@
<MarkdownEditor
required
rows={4}
label="Reason"
placeholder="he's being a meanie :("
label={$t('moderation.reason')}
bind:value={reason}
/>
<Button submit {loading} disabled={loading} color="primary" size="lg">
Submit
{$t('form.submit')}
</Button>
</form>
</Modal>
+1 -10
View File
@@ -107,16 +107,7 @@
<PostBody body={post.post.body} {view} style="grid-area: body" />
{/if}
{#if actions}
<PostActions
bind:post
on:edit={(e) => {
toast({
content: 'The post was edited successfully.',
type: 'success',
})
}}
style="grid-area: actions;"
/>
<PostActions bind:post style="grid-area: actions;" />
{:else if view == 'compact'}
<div class="flex flex-row items-center gap-2 text-sm">
<Badge>
@@ -14,6 +14,7 @@
EyeSlash,
Flag,
Icon,
Language,
Newspaper,
PencilSquare,
ServerStack,
@@ -49,6 +50,9 @@
} 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'
export let post: PostView
@@ -61,6 +65,8 @@
let fediseerOpen = false
let fediseerData: Data | null = null
let fediseerLoading = false
let translating = false
</script>
{#if fediseerData}
@@ -93,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 ?? ''}
@@ -110,7 +118,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 +131,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 +156,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 +172,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 +207,6 @@
const data = await fediseer.getInstanceInfo(
new URL(post.community.actor_id).hostname
)
console.log(data)
fediseerData = data
fediseerOpen = true
fediseerLoading = false
@@ -207,11 +224,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 +239,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,8 +252,20 @@
}}
>
<Icon src={Share} width={16} mini slot="prefix" />
Share
{$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={() => {
@@ -260,7 +291,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 +306,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}
+17 -16
View File
@@ -19,6 +19,7 @@
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
import { Button } from 'mono-svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import { t } from '$lib/translations'
export let edit = false
@@ -85,7 +86,7 @@
if (!data.community && !edit) {
toast({
type: 'warning',
content: 'You need to set a community.',
content: $t('toast.needCommunity'),
})
return
}
@@ -95,7 +96,7 @@
new URL(data.url)
} catch (err) {
toast({
content: 'Invalid URL',
content: $t('toast.invalidURL'),
type: 'warning',
})
return
@@ -170,14 +171,14 @@
.join('\n')
toast({
content: `Generated title and body from that website. Would you like to undo this action?`,
content: $t('toast.generatedTitle'),
type: 'info',
action: () => (data = oldData),
duration: 15 * 1000,
})
} catch (e) {
toast({
content: 'There was no usable title or description of that website.',
content: $t('toast.failGenerateTitle'),
})
}
generation.loading = false
@@ -217,7 +218,7 @@
<form on:submit|preventDefault={submit} class="flex flex-col gap-4 h-full">
<slot name="formtitle">
<h1 class="font-bold text-xl">
{edit ? 'Edit' : 'Create'} Post
{edit ? $t('form.post.edit') : $t('form.post.create')}
</h1>
</slot>
{#if !edit && data}
@@ -227,7 +228,7 @@
bind:items={communities}
jwt={$profile?.jwt}
listing_type="All"
label="Community"
label={$t('form.post.community')}
required
on:select={(e) => {
const c = e.detail
@@ -243,7 +244,7 @@
/>
{:else}
<div class="flex flex-col gap-1">
<span class="font-medium text-sm">Community</span>
<span class="font-medium text-sm">{$t('form.post.community')}</span>
<Button
class="w-full !bg-white dark:!bg-black h-[38px]"
on:click={() => (data.community = null)}
@@ -268,13 +269,13 @@
{/if}
<TextInput
required
label="Title"
label={$t('form.post.title')}
bind:value={data.title}
placeholder={placeholders.get('post')}
/>
<div class="flex gap-2 w-full items-end">
<TextInput
label="URL"
label={$t('form.post.url')}
bind:value={data.url}
placeholder={placeholders.get('url')}
class="w-full"
@@ -285,32 +286,32 @@
? 'width: 38px; padding: 0;'
: ''}"
class="flex-shrink-0"
title="Generate title/body"
title={$t('form.post.generateTitle')}
loading={generation.loading}
disabled={!generation.generatable || generation.loading}
>
<Icon src={Sparkles} size="18" mini slot="prefix" />
{#if generation.generatable}
Generate Title
{$t('form.post.generateTitle')}
{/if}
</Button>
<Button
on:click={() => (uploadingImage = !uploadingImage)}
style="width: 38px; height: 38px; padding: 0;"
class="flex-shrink-0"
title="Upload image"
title={$t('form.post.uploadImage')}
>
<Icon src={Photo} size="18" mini slot="prefix" />
</Button>
</div>
<MarkdownEditor
rows={8}
label="Body"
label={$t('form.post.body')}
bind:value={data.body}
placeholder={placeholders.get('post')}
previewButton
/>
<Switch bind:checked={data.nsfw}>NSFW</Switch>
<Switch bind:checked={data.nsfw}>{$t('form.post.nsfw')}</Switch>
<div class="mt-auto" />
<div class="flex flex-row items-center gap-2">
<Button
@@ -321,13 +322,13 @@
disabled={data.loading}
class="flex-1"
>
Submit
{$t('form.submit')}
</Button>
{#if !edit}
<Button
on:click={() => {
toast({ content: 'Restored from draft' })
toast({ content: $t('toast.restoredFromDraft') })
const draft = getSessionStorage('postDraft')
if (draft && !edit) {
// @ts-ignore
+24 -11
View File
@@ -20,6 +20,7 @@
import ShieldIcon from '../moderation/ShieldIcon.svelte'
import { userSettings } from '$lib/settings'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { t } from '$lib/translations'
export let community: Community | undefined = undefined
export let subscribed: SubscribedType | undefined = undefined
@@ -113,36 +114,48 @@
style="grid-area: badges;"
>
{#if badges.nsfw}
<Badge color="red-subtle">NSFW</Badge>
<Badge color="red-subtle">{$t('post.badges.nsfw')}</Badge>
{/if}
{#if badges.saved}
<Badge label="Saved" color="yellow-subtle" allowIconOnly>
<Badge
label={$t('post.badges.saved')}
color="yellow-subtle"
allowIconOnly
>
<Icon src={Bookmark} mini size="12" slot="icon" />
Saved
{$t('post.badges.saved')}
</Badge>
{/if}
{#if badges.locked}
<Badge label="Locked" color="yellow-subtle" allowIconOnly>
<Badge
label={$t('post.badges.locked')}
color="yellow-subtle"
allowIconOnly
>
<Icon src={LockClosed} mini size="14" slot="icon" />
<span class="max-md:hidden">Locked</span>
<span class="max-md:hidden">{$t('post.badges.locked')}</span>
</Badge>
{/if}
{#if badges.removed}
<Badge label="Removed" color="red-subtle" allowIconOnly>
<Badge label={$t('post.badges.removed')} color="red-subtle" allowIconOnly>
<Icon src={Trash} mini size="14" slot="icon" />
<span class="max-md:hidden">Removed</span>
<span class="max-md:hidden">{$t('post.badges.removed')}</span>
</Badge>
{/if}
{#if badges.deleted}
<Badge label="Deleted" color="red-subtle" allowIconOnly>
<Badge label={$t('post.badges.deleted')} color="red-subtle" allowIconOnly>
<Icon src={Trash} mini size="14" slot="icon" />
<span class="max-md:hidden">Deleted</span>
<span class="max-md:hidden">{$t('post.badges.deleted')}</span>
</Badge>
{/if}
{#if badges.featured}
<Badge label="Featured" color="green-subtle" allowIconOnly>
<Badge
label={$t('post.badges.featured')}
color="green-subtle"
allowIconOnly
>
<Icon src={Megaphone} mini size="14" slot="icon" />
<span class="max-md:hidden">Featured</span>
<span class="max-md:hidden">{$t('post.badges.featured')}</span>
</Badge>
{/if}
<slot name="badges" />
@@ -29,6 +29,7 @@
import { site } from '$lib/lemmy.js'
import { fly } from 'svelte/transition'
import { backOut } from 'svelte/easing'
import { t } from '$lib/translations'
export let post: Post
export let vote: number = 0
@@ -42,7 +43,7 @@
const castVote = async (newVote: number) => {
if (!$profile?.jwt) {
toast({ content: 'You must be logged in to vote.', type: 'warning' })
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
return
}
loading = true
@@ -1,5 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { t } from '$lib/translations'
import { TextInput } from 'mono-svelte'
let query: string = ''
@@ -15,7 +16,7 @@
<TextInput
bind:value={query}
class="w-full h-full {$$props.class}"
placeholder="Search"
placeholder={$t('nav.search')}
autofocus
/>
</form>
@@ -2,6 +2,7 @@
import { profile } from '$lib/auth.js'
import MultiSelect from '$lib/components/input/Switch.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { t } from '$lib/translations'
import { uploadImage } from '$lib/util.js'
import { ImageInput, toast } from 'mono-svelte'
import { Button, Label, Modal, TextArea } from 'mono-svelte'
@@ -63,12 +64,11 @@
let uploadingImage = false
let loading = false
let image: any
$: previewURL =
image instanceof FileList
? URL.createObjectURL(image[0])
: image
? URL.createObjectURL(image)
: ''
$: previewURL = image?.length
? URL.createObjectURL(image[0])
: image
? URL.createObjectURL(image)
: ''
async function upload() {
if (!$profile?.jwt || !image) return
@@ -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}
<div
class="px-3 py-2.5 h-32 overflow-auto text-sm resize-y bg-white dark:bg-zinc-950"
class="px-3 py-2.5 overflow-auto text-sm resize-y bg-white dark:bg-zinc-950"
style="height: {rows * 2}em"
>
<Markdown source={beforePreview(value)} />
</div>
@@ -317,7 +318,7 @@ overflow-hidden transition-colors"
<MultiSelect
bind:selected={previewing}
options={[false, true]}
optionNames={['Edit', 'Preview']}
optionNames={[$t('form.edit'), $t('form.preview')]}
/>
{/if}
<slot />
@@ -0,0 +1,116 @@
<script lang="ts">
import { Button, Modal, Select, Spinner, TextArea } from 'mono-svelte'
import { text } from './translation'
import { locale, t } from '$lib/translations'
import { userSettings } from '$lib/settings'
import { ArrowRight, Icon } from 'svelte-hero-icons'
import MarkdownEditor from '../markdown/MarkdownEditor.svelte'
interface TranslateResponse {
translatedText: string
}
export let open: boolean = false
let error = false
const opened = () => translate($text)
$: if (open) opened()
let result: Promise<TranslateResponse> | undefined = undefined
let from = 'auto'
let to = $locale
async function translate(text: string) {
const url = $userSettings.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)
requestURL.searchParams.set('alternatives', '')
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}>
<Button on:click={() => translate($text)} slot="suffix" color="primary">
{$t('post.actions.more.translate')}
</Button>
</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}
{#if !error}
<MarkdownEditor
previewButton={false}
previewing
tools={false}
rows={8}
value={result.translatedText || 'Failed to translate'}
disabled
></MarkdownEditor>
{/if}
{:catch err}
<MarkdownEditor
previewButton={false}
previewing
tools={false}
disabled
rows={8}
value={err || 'Failed to translate'}
class="!border-red-500 !ring-red-500 !text-red-500"
></MarkdownEditor>
{/await}
{:else}
<TextArea disabled />
{/if}
</Modal>
@@ -0,0 +1,3 @@
import { writable } from 'svelte/store'
export let text = writable<string>(undefined)
+3 -2
View File
@@ -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,3 +1,3 @@
<h1 class="text-3xl font-bold flex items-center">
<h1 class="text-3xl font-bold flex items-center gap-2 {$$props.class ?? ''}">
<slot />
</h1>
+19 -10
View File
@@ -37,6 +37,7 @@
import Logo from '../Logo.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/translations'
let searching = false
</script>
@@ -48,7 +49,7 @@
"
style={$$props.style}
>
<NavButton href="/" label="Home" class="ml-2 logo">
<NavButton href="/" label={$t('nav.home')} class="ml-2 logo">
<svelte:fragment slot="icon">
{#if LINKED_INSTANCE_URL}
{#if $site}
@@ -171,7 +172,7 @@
{#if $profile?.user && isAdmin($profile.user)}
<NavButton
href="/admin"
label="Admin"
label={$t('nav.admin')}
icon={ServerStack}
class="relative"
isSelectedFilter={(path) => path.startsWith('/admin')}
@@ -184,7 +185,11 @@
</NavButton>
{/if}
{#if amModOfAny($profile?.user)}
<NavButton href="/moderation" label="Moderation" class="relative">
<NavButton
href="/moderation"
label={$t('nav.moderation')}
class="relative"
>
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
@@ -193,10 +198,14 @@
<ShieldIcon let:isSelected slot="icon" filled={isSelected} width={18} />
</NavButton>
{/if}
<NavButton href="/communities" label="Explore" icon={GlobeAlt} />
<NavButton
href="/communities"
label={$t('nav.communities')}
icon={GlobeAlt}
/>
<NavButton
on:click={() => (searching = true)}
label="Search"
label={$t('nav.search')}
icon={MagnifyingGlass}
/>
<Menu placement="top">
@@ -204,13 +213,13 @@
class="relative"
color="primary"
slot="target"
label="Create"
label={$t('nav.create.label')}
icon={Plus}
/>
<MenuDivider>Create</MenuDivider>
<MenuDivider>{$t('nav.create.label')}</MenuDivider>
<MenuButton link href="/create/post" disabled={!$profile?.jwt}>
<Icon src={PencilSquare} mini width={16} slot="prefix" />
Post
{$t('nav.create.post')}
</MenuButton>
<MenuButton
link
@@ -221,11 +230,11 @@
!isAdmin($profile.user))}
>
<Icon src={Newspaper} mini width={16} slot="prefix" />
Community
{$t('nav.create.community')}
</MenuButton>
{#if !$profile?.jwt}
<span class="text-sm mx-4 my-1 py-1">
<Link highlight href="/login">Log in</Link> to create content.
{$t('nav.create.logingate')}
</span>
{/if}
</Menu>
+20 -20
View File
@@ -35,6 +35,7 @@
import { userSettings } from '$lib/settings'
import { site } from '$lib/lemmy'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/translations'
let showInstance = false
</script>
@@ -59,7 +60,7 @@
class="w-10 h-10 rounded-full ring-1 ring-slate-200 dark:ring-zinc-700
transition-all bg-slate-50 dark:bg-zinc-900 relative
hover:dark:brightness-125 hover:brightness {$$props.buttonClass}"
aria-label="Profile"
title={$t('profile.profile')}
slot="target"
>
{#if $profile?.user}
@@ -93,15 +94,16 @@
{$profile?.user?.local_user_view?.person.name}
</div>
{:else}
<MenuDivider>Profile</MenuDivider>
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
{/if}
{#if $profile?.user}
<MenuButton link href="/profile">
<Icon src={UserCircle} mini width={16} slot="prefix" /> Profile
<Icon src={UserCircle} mini width={16} slot="prefix" />
{$t('profile.profile')}
</MenuButton>
<MenuButton link href="/inbox">
<Icon src={Inbox} mini width={16} slot="prefix" />
Inbox
{$t('profile.inbox')}
{#if $profile.user.notifications.inbox > 0}
<Badge color="red-subtle" class="text-xs ml-auto font-bold !py-0.5">
{$profile.user.notifications.inbox}
@@ -109,18 +111,19 @@
{/if}
</MenuButton>
<MenuButton link href="/saved">
<Icon src={Bookmark} mini width={16} slot="prefix" /> Saved
<Icon src={Bookmark} mini width={16} slot="prefix" />
{$t('profile.saved')}
</MenuButton>
{/if}
<MenuButton link href="/accounts">
<Icon src={UserGroup} mini width={16} slot="prefix" />
Accounts
{$t('account.accounts')}
</MenuButton>
<hr class="dark:opacity-10 w-[90%] my-2 mx-auto" />
<MenuDivider>App</MenuDivider>
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
<MenuButton link href="/settings">
<Icon src={Cog6Tooth} mini width={16} slot="prefix" />
Settings
{$t('nav.menu.settings')}
</MenuButton>
<MenuButton class="!py-0">
<Icon
@@ -135,20 +138,20 @@
size="16"
slot="prefix"
/>
<span>Color Scheme</span>
<span>{$t('nav.menu.colorscheme.label')}</span>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="contents" on:click|stopPropagation={() => {}}>
<Select bind:value={$legacyTheme} class="ml-auto my-auto w-24" size="sm">
<option value="system">System</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
<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>
</Select>
</div>
</MenuButton>
<MenuButton href="/theme">
<Icon src={Swatch} size="16" mini slot="prefix" />
Theme
{$t('nav.menu.theme')}
</MenuButton>
{#if $userSettings.debugInfo}
<MenuButton link href="/util">
@@ -165,7 +168,7 @@
class="hover:brightness-110 transition-all"
on:click={() => {
navigator?.clipboard?.writeText(__VERSION__)
toast({ content: 'Copied version to clipboard.' })
toast({ content: $t('toast.copied') })
}}
>
<Badge color="blue-subtle">{__VERSION__}</Badge>
@@ -174,7 +177,7 @@
<Button
on:click={() => (showInstance = !showInstance)}
color="tertiary"
title="Instance"
title={$t('nav.menu.instance')}
size="square-md"
>
<Icon src={ServerStack} size="16" mini />
@@ -182,7 +185,7 @@
<Button
color="tertiary"
href="https://buymeacoffee.com/xylight"
title="Donate"
title={$t('nav.menu.donate')}
size="square-md"
>
<Icon src={Heart} size="16" mini />
@@ -190,14 +193,11 @@
<Button
color="tertiary"
href="https://github.com/Xyphyn/Photon"
title="GitHub"
title={$t('nav.menu.source')}
size="square-md"
>
<Icon src={CodeBracketSquare} size="16" mini />
</Button>
<Button color="tertiary" href="/about" title="About" size="square-md">
<Icon src={InformationCircle} size="16" mini />
</Button>
</div>
</li>
</Menu>
+22 -11
View File
@@ -26,6 +26,7 @@
import Expandable from '$lib/components/ui/Expandable.svelte'
import EndPlaceholder from '../EndPlaceholder.svelte'
import Application from '../../../../routes/admin/applications/Application.svelte'
import { t } from '$lib/translations'
</script>
<nav
@@ -35,11 +36,13 @@
>
{#if $profile?.jwt}
<SidebarButton icon={UserCircle} href="/profile/user">
<span slot="label">Profile</span>
<span slot="label">
{$t('profile.profile')}
</span>
</SidebarButton>
<SidebarButton icon={Inbox} href="/inbox">
<span slot="label" class="flex items-center gap-2">
Inbox
{$t('profile.inbox')}
{#if $profile?.user?.notifications.inbox}
<Badge
class="w-5 h-5 !p-0 grid place-items-center ml-auto"
@@ -51,22 +54,30 @@
</span>
</SidebarButton>
<SidebarButton icon={Bookmark} href="/saved">
<span slot="label">Saved</span>
<span slot="label">{$t('profile.saved')}</span>
</SidebarButton>
{:else}
<SidebarButton href="/login" title="Log In" icon={ArrowLeftOnRectangle}>
<span slot="label">Log In</span>
<SidebarButton
href="/login"
title={$t('account.login')}
icon={ArrowLeftOnRectangle}
>
<span slot="label">{$t('account.login')}</span>
</SidebarButton>
<SidebarButton href="/signup" title="Sign Up" icon={Identification}>
<span slot="label">Sign Up</span>
<SidebarButton
href="/signup"
title={$t('account.signup')}
icon={Identification}
>
<span slot="label">{$t('account.signup')}</span>
</SidebarButton>
{#if LINKED_INSTANCE_URL === undefined}
<SidebarButton
href="/accounts"
title="Change Instance"
title={$t('account.changeinstance')}
icon={ServerStack}
>
<span slot="label">Change Instance</span>
<span slot="label">{$t('account.changeinstance')}</span>
</SidebarButton>
{/if}
{/if}
@@ -78,7 +89,7 @@
</div>
{/each}
<SidebarButton href="/accounts" icon={UserGroup}>
<span slot="label">Accounts</span>
<span slot="label">{$t('account.accounts')}</span>
</SidebarButton>
{/if}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
@@ -99,7 +110,7 @@
: '//max-lg:hidden'}"
>
<EndPlaceholder>
Subscribed
{$t('profile.subscribed')}
<span slot="action" class="dark:text-white text-black">
{$profile.user.follows.length}
</span>
@@ -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>
+3 -4
View File
@@ -1,4 +1,6 @@
<script lang="ts">
import { locale } from '$lib/translations'
export let date: Date
export let relativeTo: Date | undefined = undefined
export let options: Intl.RelativeTimeFormatOptions = {
@@ -36,10 +38,7 @@
if (diffInMillis >= thresholds[i].threshold) {
const value = Math.round(diffInMillis / thresholds[i].threshold)
let language = 'en'
if (typeof navigator != 'undefined') {
language = navigator.language
}
let language = $locale
const rtf = new Intl.RelativeTimeFormat(language, options)
+673
View File
@@ -0,0 +1,673 @@
{
"profile": {
"profile": "Profile",
"inbox": "Inbox",
"saved": "Saved",
"subscribed": "Subscribed"
},
"nav": {
"home": "Home",
"admin": "Admin",
"moderation": "Moderation",
"communities": "Explore",
"search": "Search",
"create": {
"label": "Create",
"post": "Post",
"community": "Community",
"logingate": "You must log in to create content."
},
"menu": {
"label": "Profile",
"app": "App",
"settings": "Settings",
"colorscheme": {
"label": "Color Scheme",
"system": "System",
"dark": "Dark",
"light": "Light"
},
"theme": "Theme",
"about": "About",
"source": "Source",
"donate": "Donate",
"instance": "Instance"
}
},
"account": {
"login": "Log In",
"logout": "Log Out",
"signup": "Sign Up",
"accounts": "Accounts",
"changeinstance": "Change Instance",
"resetColor": "Reset Color",
"addGuest": "Add Guest",
"moveUp": "Move Up",
"moveDown": "Move Down",
"guest": "Guest",
"versionGate": "This version of Photon supports instances running {{version}} or higher."
},
"filter": {
"location": {
"label": "Location",
"all": "All",
"local": "Local",
"subscribed": "Subscribed",
"moderator": "Moderator"
},
"sort": {
"label": "Sort",
"active": "Active",
"hot": "Hot",
"top": {
"label": "Top",
"time": {
"label": "Time",
"all": "All",
"9months": "9 Months",
"6months": "6 Months",
"3months": "3 Months",
"month": "Month",
"week": "Week",
"day": "Day",
"12hours": "12 Hours",
"6hours": "6 Hours",
"hour": "Hour"
}
},
"new": "New",
"old": "Old",
"controversial": "Controversial",
"scaled": "Scaled",
"mostcomments": "Comments",
"newcomments": "New Replies"
},
"view": {
"label": "View",
"cozy": "Cozy",
"list": "List",
"compact": "Compact",
"legacy": "Legacy"
},
"type": "Type",
"filter": "Filter",
"unread": "Unread",
"inbox": {
"messages": "Messages",
"replies": "Replies",
"mentions": "Mentions"
}
},
"form": {
"username": "Username",
"name": "Name",
"instance": "Instance URL",
"password": "Password",
"confirmPassword": "Confirm Password",
"2fa": "2FA Code",
"forgotpassword": "Forgot Password",
"submit": "Submit",
"edit": "Edit",
"preview": "Preview",
"post": {
"create": "Create Post",
"edit": "Edit Post",
"community": "Community",
"title": "Title",
"url": "URL",
"body": "Body",
"nsfw": "NSFW",
"generateTitle": "Generate Title",
"uploadImage": "Upload Image"
},
"profile": {
"displayName": "Display name",
"bio": "Bio",
"avatar": "Avatar",
"banner": "Banner",
"email": "Email",
"matrix": "Matrix User",
"showNSFW": "Show NSFW content",
"scores": "Show Scores",
"bot": "Bot Account",
"showBots": "Show Bots",
"showRead": "Show Read Posts",
"currentPassword": "Current Password",
"newPassword": "New Password",
"verifyNewPassword": "Verify New Password",
"2fa": {
"totp": "TOTP",
"2fa": "2FA",
"paste": "Paste this in your authenticator app."
},
"deleteAccount": {
"label": "Delete account",
"deleteContent": "Delete content",
"warning": "This will delete ALL of your submissions."
}
},
"email": "Email",
"setup": "Setup",
"signup": {
"title": "Sign Up",
"description": "Choose an instance that interests you, or type the URL manually.",
"info": "An instance is the server that your account will be hosted on, but you can still access and interact with content from other instances.",
"chooseInstance": "Choose an instance",
"application": {
"label": "Application",
"info": "To join this instance, you must fill out this application, and wait to be accepted. You will receive an email if your application is accepted."
},
"closed": {
"title": "Registrations closed",
"description": "This instance has registrations closed. Find another instance.",
"anotherInstance": "Find another instance"
}
},
"description": "Description"
},
"routes": {
"frontpage": {
"title": "Frontpage",
"footer": "{{users:number}} active {{users; 1:user; default:users;}}"
},
"modlog": "Modlog",
"instances": "Instances",
"legal": {
"title": "Legal",
"noLegal": "This instance does not have any legal information."
},
"profile": {
"user": "User",
"settings": "Settings",
"blocks": "Blocks",
"credentials": "Credentials",
"moderates": "Moderates"
},
"translators": "Translators",
"accounts": "Accounts",
"communities": "Communities",
"search": {
"title": "Search",
"federating": "Federating",
"query": "Query",
"noResults": {
"title": "No Results",
"description": "There are no results that match that filter. Try refining your search.",
"alt": "Search across the fediverse"
}
},
"saved": "Saved",
"createPost": "Create Post",
"createCommunity": "Create Community",
"post": {
"crosspostCount": "crossposts",
"commentCount": "comments",
"addComment": "Add a comment",
"scrollToTop": "Scroll to top",
"instanceWarning": "This post was requested from a different server than your account's. Many actions won't work.",
"remoteView": "Remote View",
"localView": "Local View",
"thread": {
"single": "You're viewing a single thread.",
"allComments": "All Comments",
"part": "You're viewing part of a thread.",
"context": "Show Context"
}
},
"inbox": {
"title": "Inbox",
"markAsRead": "Mark All Read",
"empty": {
"title": "No new notifications",
"description": "Messages, replies, and mentions will appear here."
}
},
"moderation": {
"title": "Moderation",
"empty": {
"title": "No new reports",
"description": "When submissions are reported, you can act on them here."
},
"reason": "Reason",
"resolve": "Resolve",
"unresolve": "Unresolve"
},
"admin": {
"title": "Administration",
"config": {
"title": "Configuration",
"sidebar": "Sidebar",
"icon": "Icon",
"banner": "Banner",
"downvotesEnabled": "Enable Downvotes",
"nsfwEnabled": "Enable NSFW",
"registration": {
"label": "Registration Mode",
"open": "Open",
"application": "Require Application",
"closed": "Closed"
},
"applicationQuestion": "Application Question",
"adminCommunityOnly": "Only admins can create communities",
"requireVerifyEmail": "Require email verification",
"emailAdminsOnApplication": "Email admins on receiving new applications",
"emailAdminsOnReport": "Email admins on receiving new reports",
"listingType": {
"label": "Listing Type",
"all": "All",
"local": "Local"
},
"private": "Private instance",
"hideModlogModNames": "Hide modlog mod names",
"slurFilter": "Slur filter regex",
"federation": "Federation enabled",
"federationDebug": "Federation debug mode",
"captcha": {
"enabled": "Enabled"
}
},
"applications": {
"title": "Applications",
"empty": {
"title": "No new applications",
"description": "Applications to join your instance will appear here."
},
"application": "Application",
"approved": "Approved",
"denied": "Denied",
"user": "User",
"deny": "Deny",
"approve": "Approve",
"reason": "Reason",
"modalTitle": "Deny Application"
},
"taglines": {
"title": "Taglines",
"add": "Add a tagline",
"empty": {
"title": "No taglines",
"description": "A random tagline will appear on the site card when users visit your instance."
}
},
"team": {
"title": "Admins",
"empty": {
"title": "No admins",
"description": "Somehow there's no admins of this site. How??"
}
},
"federation": {
"title": "Federation",
"csv": "Upload CSV",
"blocked": "Blocked Instances",
"block": "Block",
"blockplaceholder": "Block an instance...",
"allowed": "Whitelisted Instances",
"allow": "Whitelist",
"allowplaceholder": "Whitelist an instance",
"emptyBlock": {
"title": "No blocked instances",
"description": "Blocking an instance will hide new submissions from that instance."
},
"emptyAllow": {
"title": "No whitelisted instances",
"description": "Whitelisting an instance will block every other instance."
}
}
},
"verifyEmail": {
"message": "Your email was verified. You can now close this window.",
"error": "Failed to verify your email."
},
"passwordChange": {
"title": "Change Password",
"description": "Choose your new password.",
"instance": "Which instance is your account hosted on?"
},
"resetLogin": {
"title": "Reset Password",
"description": "Enter your account's email, and a password reset link will be sent. If your account does not have an email, contact your instance admins."
},
"theme": {
"title": "Theme",
"import": "Import",
"export": "Export",
"reset": "Reset",
"accent": "Accent",
"resetWarning": {
"title": "Reset Theme",
"description": "This will reset all of your colors to the default. It is recommended to export your theme before this."
}
}
},
"cards": {
"site": {
"about": "About",
"stats": "Stats",
"admins": "Admins"
},
"community": {
"members": "Members",
"moderators": "Moderators",
"subscribe": "Subscribe",
"subscribed": "Subscribed",
"modlog": "Modlog",
"block": "Block",
"unblock": "Unblock",
"blockInstance": "Block instance"
}
},
"admin": {
"purge": "Purge",
"instance": "Instance",
"label": "Administration",
"purgeCommunity": {
"title": "Purging Community",
"warning": "This will delete all posts. Are you sure? (The button will enable in 3 seconds.)"
}
},
"content": {
"all": "All",
"users": "Users",
"posts": "Posts",
"comments": "Comments",
"communities": "Communities",
"instances": "Instances",
"message": "Message"
},
"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",
"translate": "Translate",
"share": "Share",
"crosspost": "Crosspost",
"delete": "Delete",
"restore": "Restore"
}
},
"badges": {
"nsfw": "NSFW",
"locked": "Locked",
"featured": "Featured",
"removed": "Removed",
"deleted": "Deleted",
"saved": "Saved"
}
},
"comment": {
"reply": "Reply",
"actions": {
"label": "Actions",
"link": "Copy Link"
},
"locked": "This post is locked."
},
"moderation": {
"report": "Report",
"ban": {
"banning": "Banning User",
"unbanning": "Unbanning User",
"deleteData": "Delete data",
"warning": "This will delete ALL of this user's submissions here.",
"expires": "Expires (UTC)",
"banFromCommunity": "Ban from community",
"unbanFromCommunity": "Unban from community"
},
"removeSubmission": {
"title": "Removing Submission",
"titleRestore": "Restoring Submission",
"titlePurge": "Purging Submission",
"withReason": "Reply with reason",
"comment": "Comment",
"message": "Message",
"failReply": "Failed to post reply. Removing anyway...",
"failMessage": "Failed to message user. Removing anyway...",
"failEmptyReply": "Your reply cannot be empty if 'Reply with reason' is enabled.",
"successPurge": "Successfully purged that submission."
},
"reportModal": {
"title": "Report",
"success": "Reported that submission."
},
"reason": "Reason",
"lock": "Lock",
"unlock": "Unlock",
"remove": "Remove",
"restore": "Restore",
"label": "Moderation",
"labelInstanceOnly": "Moderation (Instance Only)",
"feature": "Feature",
"unfeature": "Unfeature"
},
"common": {
"back": "Back",
"next": "Next",
"debug": "Debug",
"refresh": "Refresh",
"jump": "Jump",
"save": "Save",
"enabled": "Enabled",
"disabled": "Disabled",
"enable": "Enable",
"disable": "Disable",
"add": "Add",
"cancel": "Cancel",
"send": "Send"
},
"message": {
"success": "Success",
"error": "Error"
},
"toast": {
"noComments": "The API returned no comments.",
"loginVoteGate": "You must be logged in to vote.",
"blockedCommunity": "Blocked that community.",
"unblockedCommunity": "Unblocked that community.",
"purgedCommunity": "Purged that community.",
"blockedInstance": "Blocked that instance.",
"updatedCommunity": "Your community was updated.",
"sentMessage": "Sent that message.",
"invalidDateAbsolute": "Invalid date. It must be an absolute date.",
"invalidDateBeforeCurrent": "Invalid date. It is before the current time.",
"bannedUser": "Banned that user.",
"unbannedUser": "Unbanned that user.",
"needCommunity": "You must set a community.",
"invalidURL": "Invalid URL",
"generatedTitle": "Generated title and body from the URL. Do you want to undo this?",
"failGenerateTitle": "There was no usable title or description of that website.",
"restoredFromDraft": "Restored your post from the draft.",
"copied": "Copied to clipboard.",
"approvedApplication": "Approved that application.",
"deniedApplication": "Denied that application.",
"updatedSite": "Updated your site.",
"failCSV": "Failed to read CSV",
"removeAdminWarning": "Are you sure you want to remove that admin?",
"removeAdmin": "Removed that admin.",
"failFindUser": "Could not find that user.",
"addMod": "Added that moderator.",
"updateMods": "Updated community moderators.",
"logIn": "Successfully logged in.",
"failInstanceURL": "Failed to contact that instance URL. Is it down?",
"addAccount": "Added that account.",
"resetLink": "A password reset link was sent to your email.",
"resolveReport": "Resolved that report.",
"unresolveReport": "Unresolved that report.",
"passwordReset": "Your password was reset.",
"fetchPostOnHome": "Attempting to fetch this post on your home instance...",
"loginRefresh": "Your login was refreshed.",
"invalidLogin": "Invalid credentials",
"saveSettings": "Saved your user settings. If you changed your email, a verification link was sent.",
"confirmDelete1": "Are you sure you want to delete your account?",
"confirmDelete2": "Are you really sure?",
"confirmDelete3": "Final warning. Are you really sure?",
"needPassword": "You must provide your password.",
"deleting": "Deleting your account...",
"deleted": "Your account was deleted.",
"resetSettings": "Do you want to reset your settings to the default?",
"failFetchInstances": "Failed to fetch available instances.",
"verifyEmail": "A verification link was sent to your email. Verify your email, then log in.",
"failSignup": "Failed to sign up.",
"successSignup": "Signed up.",
"waitApplication": "Wait for your registration application to be accepted before logging in.",
"blockUser": "Blocked that user.",
"unblockUser": "Unblocked that user.",
"purgeUser": "Purged that user."
},
"settings": {
"title": "Settings",
"navigation": {
"title": "Navigation",
"dockPos": {
"title": "Dock position",
"description": "Where the dock should be positioned on the screen.",
"top": "Top",
"bottom": "Bottom",
"adaptive": "Adaptive"
},
"panel": {
"title": "Panel mode",
"description": "Extend the dock to the screen edges, similar to a panel.",
"on": "On",
"off": "Off",
"adaptive": "Adaptive"
}
},
"app": {
"title": "Photon",
"theming": {
"title": "Theming",
"description": "Customize Photon's colors.",
"link": "Go to themes"
},
"lang": {
"title": "Language",
"description": "The language used for Photon's UI.",
"note": "Languages other than English and Hebrew are community translated, and may be incomplete.",
"en": "English",
"en-US": "English",
"he": "Hebrew",
"ee": "Estonian",
"fr": "French",
"auto": "Auto",
"credits": "Credits"
},
"view": {
"title": "Post style",
"list": "Show posts in a list, with post bodies and compact media.",
"cozy": "Show posts with large images, rich embeds, and longer post bodies.",
"compact": "Show posts in a list, without post bodies and with tighter spacing.",
"legacy": "The old look of Photon."
},
"sort": {
"title": "Default sort",
"description": "The default sorting to use in feeds."
},
"postsInNewTab": {
"title": "Open posts in new tab",
"description": "Open posts in a separate tab instead of the current."
},
"displayName": {
"title": "Use display name",
"description": "Show users' display names instead of their actual usernames."
},
"limitLayoutWidth": {
"title": "Limit layout width",
"description": "Improve readability by limiting the main content width."
},
"placeholders": {
"title": "Random placeholders",
"description": "Show random placeholders for certain text inputs."
},
"expandImages": {
"title": "Expand images",
"description": "Clicking on a post's image brings you to an expanded view rather than the post page."
},
"duplicateTitles": {
"title": "Hide duplicate titles/bodies",
"description": "Hides the post title and body if they are identical to the embed."
},
"thumbnailSide": {
"title": "Thumbnail alignment",
"description": "Where thumbnails should be on the post in list/compact mode",
"left": "Left",
"right": "Right"
},
"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": {
"title": "Embeds",
"clickToView": {
"title": "Click to view",
"description": "Only load embeds once you click on them."
},
"youtube": {
"description": "The website to embed YouTube content in."
}
},
"lemmy": {
"title": "Lemmy",
"compactFeatured": {
"title": "Compact featured posts",
"description": "Make featured posts more compact"
},
"markReadPosts": {
"title": "Mark read posts",
"description": "Mark a post as read when you click on it"
},
"fadeReadPosts": {
"title": "Fade read posts",
"description": "Fade the title of posts you've already read"
},
"crosspostMarker": {
"title": "Mark crossposts",
"description": "Show 'crossposted from' when crossposting."
},
"hideSubmissions": {
"title": "Hide submissions",
"description": "Hide certain types of submissions.",
"deleted": "Deleted by user",
"removed": "Removed by moderator"
},
"nsfwBlur": {
"title": "NSFW blur",
"description": "Blur images and remove post bodies of NSFW posts."
},
"instances": {
"title": "Show instances",
"description": "Show the instances where certain content is from."
}
},
"moderation": {
"title": "Moderation",
"replyPresets": {
"title": "Removal reply presets",
"description": "Presets to use for 'reply reason' in the submission removal dialog.",
"syntax": "Syntax"
}
},
"other": {
"title": "Other",
"debug": {
"title": "Debug info",
"description": "Display debug information"
}
}
}
}
+3
View File
@@ -1,3 +1,4 @@
import { browser } from '$app/environment'
import type { Community } from 'lemmy-js-client'
import { writable } from 'svelte/store'
@@ -20,6 +21,7 @@ export const setSessionStorage = (
key: keyof SessionStorage,
value: SessionStorage[typeof key]
) => {
if (!browser) return
if (value == undefined) {
sessionStorage.removeItem(key)
} else {
@@ -30,6 +32,7 @@ export const setSessionStorage = (
export const getSessionStorage = (
key: keyof SessionStorage
): SessionStorage[typeof key] => {
if (!browser) return
return JSON.parse(sessionStorage.getItem(key)!)
}
+14 -3
View File
@@ -1,6 +1,8 @@
import type { CommentSortType, SortType } from 'lemmy-js-client'
import { writable } from 'svelte/store'
import { env } from '$env/dynamic/public'
import { locale } from './translations'
import { browser } from '$app/environment'
console.log('Using the following default settings from the environment:')
console.log(env)
@@ -77,6 +79,8 @@ interface Settings {
deduplicateEmbed: boolean
compactFeatured: boolean
}
language: string | null
translator: string | undefined
}
export const defaultSettings: Settings = {
@@ -128,12 +132,14 @@ 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,
translator: undefined,
}
export const userSettings = writable(defaultSettings)
@@ -166,4 +172,9 @@ userSettings.subscribe((settings) => {
if (typeof window != 'undefined') {
localStorage.setItem('settings', JSON.stringify(settings))
}
if (settings.language) {
locale.set(settings.language)
} else {
if (browser) locale.set(navigator?.language)
}
})
+16
View File
@@ -0,0 +1,16 @@
import i18n, { type Config } from 'sveltekit-i18n'
const config: Config = {
loaders: [
{
locale: 'en',
key: '',
loader: async () => (await import('./i18n/en.json')).default,
},
],
fallbackLocale: 'en',
}
export const { t, locale, locales, loading, loadTranslations } = new i18n(
config
)