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

-50
View File
@@ -44,37 +44,6 @@
let newInstance: string = $profileData.defaultInstance ?? DEFAULT_INSTANCE_URL
let loading = false
async function changeGuestInstance() {
loading = true
try {
const valid = await validateInstance(newInstance.trim())
if (!valid) {
throw new Error('invalid instance')
}
toast({
content: 'Changed guest instance.',
type: 'success',
})
} catch (err) {
toast({
content: 'Failed to contact that instance URL. Is it down?',
type: 'error',
})
loading = false
return
}
$profileData.defaultInstance = newInstance
if ($currentProfile && $currentProfile.id == -1) {
$instance = newInstance
}
loading = false
}
let debugging = false
let debugProfile: Profile | undefined = undefined
@@ -161,25 +130,6 @@
Sign up
</Button>
</div>
{#if LINKED_INSTANCE_URL === undefined}
<div class="flex flex-row font-normal gap-2">
<TextInput
label="Guest instance"
on:change={changeGuestInstance}
placeholder="Instance URL"
bind:value={newInstance}
/>
<Button
color="primary"
class="h-max self-end"
size="lg"
{loading}
disabled={loading}
>
Change
</Button>
</div>
{/if}
</div>
</div>
{:else}
@@ -51,9 +51,9 @@
registrationApplicationAnswer
)
toast({
content: `Successfully ${
approve ? 'approved' : 'denied'
} that application.`,
content: approve
? $t('toast.approvedApplication')
: $t('toast.deniedApplication'),
type: 'success',
})
application.creator_local_user.accepted_application = approve
+1 -1
View File
@@ -31,7 +31,7 @@
...formData,
})
toast({
content: 'Updated your site.',
content: $t('toast.updatedSite'),
type: 'success',
})
} catch (err) {
+4 -5
View File
@@ -109,7 +109,7 @@
if (res) {
toast({
content: 'Edited your site.',
content: $t('toast.updatedSite'),
type: 'success',
})
}
@@ -127,8 +127,7 @@
if (!data.federated_instances?.federated_instances?.blocked)
throw new Error('Missing instance')
const content = e.target?.result
if (!content)
toast({ content: 'No content in that file', type: 'warning' })
if (!content) toast({ content: $t('toast.failCSV'), type: 'warning' })
try {
const instances: Instance[] = []
@@ -152,12 +151,12 @@
data.federated_instances.federated_instances.blocked = instances
} catch (err) {
toast({ content: err as 'Failed to parse CSV', type: 'error' })
toast({ content: $t('toast.failCSV'), type: 'error' })
}
}
reader.onerror = (e) =>
toast({ content: 'Failed to read file.', type: 'error' })
toast({ content: $t('toast.failCSV'), type: 'error' })
reader.readAsText(files[0])
}
+1 -1
View File
@@ -29,7 +29,7 @@
taglines: taglines,
})
toast({
content: 'Successfully saved taglines.',
content: $t('toast.updatedSite'),
type: 'success',
})
} catch (err) {
+2 -2
View File
@@ -21,7 +21,7 @@
async function removeAdmin(id: number, confirm: boolean): Promise<any> {
if (!confirm)
return toast({
content: 'Are you sure you want to remove that admin?',
content: $t('toast.removeAdminWarning'),
action: () => removeAdmin(id, true),
})
@@ -37,7 +37,7 @@
if (result) {
data.site!.admins = result.admins
toast({
content: 'Removed that admin.',
content: $t('toast.removeAdmin'),
type: 'success',
})
}
+2 -1
View File
@@ -22,6 +22,7 @@
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { profile } from '$lib/auth'
import { addResumable } from '$lib/lemmy/item.js'
import { t } from '$lib/translations.js'
export let data
@@ -94,7 +95,7 @@
}`
)
toast({ content: 'Copied to clipboard.' })
toast({ content: $t('toast.copied') })
}}
class="dark:text-zinc-400 text-slate-600 text-sm text-left"
>
@@ -9,6 +9,8 @@
import { getClient } from '$lib/lemmy.js'
import { flip } from 'svelte/animate'
import { Button, TextInput } from 'mono-svelte'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data: PageData
@@ -37,14 +39,14 @@
data.community.moderators = addModRes.moderators
toast({
content: 'Added that user as a moderator.',
content: $t('toast.addMod'),
type: 'success',
})
formData.newModerator = ''
} else {
toast({
content: 'Could not find that user.',
content: $t('toast.failFindUser'),
type: 'warning',
})
}
@@ -71,7 +73,7 @@
data.community.moderators = res.moderators
toast({
content: 'Successfully updated community moderators.',
content: $t('toast.updateMods'),
type: 'success',
})
} catch (err) {
@@ -83,11 +85,7 @@
}
</script>
<svelte:head>
<title>Moderator Team</title>
</svelte:head>
<h1 class="text-2xl font-bold">Moderators</h1>
<Header>Moderators</Header>
<EditableList
let:action
on:action={(e) => {
+1 -1
View File
@@ -26,7 +26,7 @@
subscribing = false
return res
} catch (error) {
toast({ content: 'Failed to subscribe to community', type: 'error' })
toast({ content: error as any, type: 'error' })
}
subscribing = false
+1 -1
View File
@@ -48,7 +48,7 @@
const result = await setUser(response.jwt, data.instance, data.username)
if (result) {
toast({ content: 'Successfully logged in.', type: 'success' })
toast({ content: $t('toast.logIn'), type: 'success' })
goto('/')
}
} else {
+2 -2
View File
@@ -19,7 +19,7 @@
async function addGuest() {
form.loading = true
if (!(await validateInstance(form.instance))) {
toast({ content: 'Failed to contact that instance URL.', type: 'error' })
toast({ content: $t('toast.failInstanceURL'), type: 'error' })
form.loading = false
return
}
@@ -44,7 +44,7 @@
}
})
toast({ content: 'Added that account.', type: 'success' })
toast({ content: $t('toast.addAccount'), type: 'success' })
goto('/')
+2 -2
View File
@@ -16,14 +16,14 @@
loading = true
try {
if (!(await validateInstance(instance)))
throw new Error('Failed to contact instance url')
throw new Error($t('toast.failInstanceURL'))
await getClient(instance).passwordReset({
email: email,
})
toast({
content: 'A password reset link was sent to your email.',
content: $t('toast.resetLink'),
type: 'success',
})
} catch (err) {
+9 -9
View File
@@ -34,9 +34,9 @@
item.resolved = res.comment_report_view.comment_report.resolved
toast({
content: `${
item.resolved ? 'Resolved' : 'Unresolved'
} that report.`,
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
@@ -50,9 +50,9 @@
item.resolved = res.post_report_view.post_report.resolved
toast({
content: `${
item.resolved ? 'Resolved' : 'Unresolved'
} that report.`,
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
@@ -67,9 +67,9 @@
item.resolved =
res.private_message_report_view.private_message_report.resolved
toast({
content: `${
item.resolved ? 'Resolved' : 'Unresolved'
} that report.`,
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
@@ -22,7 +22,7 @@
loading = true
try {
if (!(await validateInstance(instance)))
throw new Error('Failed to contact instance url')
throw new Error($t('toast.failInstanceURL'))
await getClient(instance).passwordChangeAfterReset({
password: password,
@@ -31,7 +31,7 @@
})
toast({
content: 'Your password was reset.',
content: $t('toast.passwordReset'),
type: 'success',
})
@@ -82,7 +82,7 @@
const fetchOnHome = async (jwt: string) => {
const id = toast({
content: 'Attempting to fetch this post on your home instance...',
content: $t('toast.fetchPostOnHome'),
loading: true,
})
@@ -41,12 +41,12 @@
await setUser(res.jwt, instance, username!)
$currentInstance = instance
toast({ content: 'Your login was refreshed.', type: 'success' })
toast({ content: $t('toast.loginRefresh'), type: 'success' })
} else {
throw new Error('Invalid credentials')
throw new Error($t('toast.invalidLogin'))
}
toast({ content: 'Successfully changed your password. ' })
toast({ content: $t('toast.passwordReset') })
} catch (e) {
toast({
content: e as any,
@@ -139,7 +139,7 @@
on:click={() => {
if (!totpLink) return
navigator.clipboard?.writeText(totpLink)
toast({ content: 'Copied to clipboard.' })
toast({ content: $t('toast.copied') })
}}
>
<Icon src={ClipboardDocument} size="20" mini />
@@ -41,8 +41,7 @@
})
toast({
content:
'Saved your user settings. If you changed your email, a verification email will have been sent.',
content: $t('toast.saveSettings'),
type: 'success',
})
} catch (err) {
@@ -65,21 +64,21 @@
switch (level) {
case 0: {
toast({
content: 'Are you sure you want to delete your account?',
content: $t('toast.confirmDelete1'),
action: () => deleteAccount(1),
})
return
}
case 1: {
toast({
content: 'Are you really sure?',
content: $t('toast.confirmDelete2'),
action: () => deleteAccount(2),
})
return
}
case 2: {
toast({
content: 'Final warning. Are you reeeeeeally sure?',
content: $t('toast.confirmDelete3'),
action: () => deleteAccount(3),
})
return
@@ -93,13 +92,13 @@
if (!(deletion.password || null)) {
toast({
content: 'You must provide your password.',
content: $t('toast.needPassword'),
type: 'warning',
})
}
const id = toast({
content: 'You did this. Deleting account...',
content: $t('toast.deleting'),
loading: true,
})
@@ -121,7 +120,7 @@
setUserID(-1)
toast({
content: 'Your account was deleted.',
content: $t('toast.deleted'),
})
goto('/')
} catch (err) {
+2 -2
View File
@@ -32,7 +32,7 @@
import { removeItem } from '$lib/util.js'
import Section from './Section.svelte'
import ToggleSetting from './ToggleSetting.svelte'
import { locales } from '$lib/translations'
import { locales, t } from '$lib/translations'
</script>
<svelte:head>
@@ -43,7 +43,7 @@
Settings <Button
on:click={() => {
toast({
content: 'Are you sure you want to reset your settings to the default?',
content: $t('toast.resetSettings'),
action: () => ($userSettings = defaultSettings),
})
}}
+2 -2
View File
@@ -65,7 +65,7 @@
// ]
} catch (e) {
toast({
content: 'Failed to fetch available instances.',
content: $t('toast.failFetchInstances'),
type: 'error',
})
}
@@ -129,7 +129,7 @@
goto(`/signup/${selectedInstance}`)
} else {
toast({
content: 'Could not contact that instance URL',
content: $t('toast.failInstanceURL'),
type: 'error',
})
}
+5 -7
View File
@@ -69,7 +69,7 @@
if (res?.jwt) {
await setUser(res.jwt, $page.params.instance, username)
toast({ content: 'Successfully logged in.', type: 'success' })
toast({ content: $t('toast.logIn'), type: 'success' })
goto('/')
} else if (
res.verify_email_sent ||
@@ -78,8 +78,7 @@
currentInstance.set(instance)
if (res.verify_email_sent) {
toast({
content:
'A verification link was sent to your email. Verify your email, and then you can log in.',
content: $t('toast.verifyEmail'),
type: 'info',
})
}
@@ -87,18 +86,17 @@
data.site_view.local_site.registration_mode == 'RequireApplication'
) {
toast({
content:
'Please wait for your registration application to be approved before you can log in.',
content: $t('toast.waitApplication'),
type: 'info',
})
}
goto('/')
} else {
throw new Error('Failed to sign up.')
throw new Error($t('toast.failSignup'))
}
toast({
content: 'Signed up.',
content: $t('toast.successSignup'),
type: 'success',
})
} catch (err) {
+2 -1
View File
@@ -17,6 +17,7 @@
Icon,
} from 'svelte-hero-icons'
import ColorSwatch from './ColorSwatch.svelte'
import { t } from '$lib/translations'
const c = defaultColors
@@ -36,7 +37,7 @@
throw new Error('Import is empty')
}
$colors = JSON.parse(importText)
toast({ content: 'Import successful', type: 'success' })
toast({ content: $t('message.success'), type: 'success' })
importing = false
} catch (err) {
// @ts-ignore
+3 -3
View File
@@ -70,7 +70,7 @@
}
toast({
content: `Successfully ${blocked ? 'unblocked' : 'blocked'} that user.`,
content: blocked ? $t('toast.unblockUser') : $t('toast.blockUser'),
type: 'success',
})
@@ -99,14 +99,14 @@
async function purgeUser() {
purgingUser = false
const purgeToast = toast({ content: 'Purging user...', loading: true })
const purgeToast = toast({ content: '', loading: true })
try {
await client().purgePerson({
person_id: data.person_view.person.id,
})
removeToast(purgeToast)
toast({ content: 'Purged that user.', type: 'success' })
toast({ content: $t('toast.purgeUser'), type: 'success' })
} catch (e) {
toast({ content: e as any, type: 'error' })
}