i18n: localize toasts
This commit is contained in:
1 parent
b57baa3769
commit
e89d2aaddb
35 files changed
+169
-177
No files matched your search
@@ -51,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
|
||||
|
||||
@@ -41,10 +41,6 @@
|
||||
dispatch('comment', response)
|
||||
|
||||
value = ''
|
||||
toast({
|
||||
content: 'Your comment was submitted.',
|
||||
type: 'success',
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
toast({
|
||||
|
||||
@@ -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',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
try {
|
||||
const loading = toast({
|
||||
content: `${blocked ? 'Unblocking' : 'blocking'} community...`,
|
||||
content: ``,
|
||||
loading: true,
|
||||
})
|
||||
|
||||
@@ -96,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) {
|
||||
@@ -120,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' })
|
||||
}
|
||||
@@ -137,7 +137,7 @@
|
||||
if (!$profile?.jwt) return
|
||||
try {
|
||||
const loading = toast({
|
||||
content: `Blocking instance...`,
|
||||
content: ``,
|
||||
loading: true,
|
||||
})
|
||||
|
||||
@@ -160,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
|
||||
@@ -175,7 +173,7 @@
|
||||
on:click={() => (purgingCommunity = false)}
|
||||
class="flex-1"
|
||||
>
|
||||
Cancel
|
||||
{$t('common.cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
size="lg"
|
||||
@@ -184,7 +182,7 @@
|
||||
disabled={!purgeEnabled}
|
||||
class="flex-1"
|
||||
>
|
||||
Purge
|
||||
{$t('admin.purge')}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
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'
|
||||
|
||||
/**
|
||||
* The community ID to edit.
|
||||
@@ -68,7 +69,7 @@
|
||||
})
|
||||
|
||||
toast({
|
||||
content: `Your community was ${edit ? 'saved' : 'created'}.`,
|
||||
content: $t('toast.updatedCommunity'),
|
||||
type: 'success',
|
||||
})
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -42,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',
|
||||
})
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
if (date < Date.now()) {
|
||||
toast({
|
||||
content: 'Invalid date. It is before the current time.',
|
||||
content: $t('toast.invalidDateBeforeCurrent'),
|
||||
type: 'error',
|
||||
})
|
||||
|
||||
@@ -84,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',
|
||||
})
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
if (!data.community && !edit) {
|
||||
toast({
|
||||
type: 'warning',
|
||||
content: 'You need to set a community.',
|
||||
content: $t('toast.needCommunity'),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -96,7 +96,7 @@
|
||||
new URL(data.url)
|
||||
} catch (err) {
|
||||
toast({
|
||||
content: 'Invalid URL',
|
||||
content: $t('toast.invalidURL'),
|
||||
type: 'warning',
|
||||
})
|
||||
return
|
||||
@@ -171,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
|
||||
@@ -328,7 +328,7 @@
|
||||
{#if !edit}
|
||||
<Button
|
||||
on:click={() => {
|
||||
toast({ content: 'Restored from draft' })
|
||||
toast({ content: $t('toast.restoredFromDraft') })
|
||||
const draft = getSessionStorage('postDraft')
|
||||
if (draft && !edit) {
|
||||
// @ts-ignore
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user