i18n: localize toasts

This commit is contained in:
Xylight committed 2024-06-04 13:02:05 -07:00
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',
})
+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>
@@ -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
+1 -1
View File
@@ -168,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>
+65 -3
View File
@@ -347,7 +347,11 @@
"admin": {
"purge": "Purge",
"instance": "Instance",
"label": "Administration"
"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",
@@ -355,7 +359,8 @@
"posts": "Posts",
"comments": "Comments",
"communities": "Communities",
"instances": "Instances"
"instances": "Instances",
"message": "Message"
},
"post": {
"actions": {
@@ -440,10 +445,67 @@
"disabled": "Disabled",
"enable": "Enable",
"disable": "Disable",
"add": "Add"
"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."
}
}