feat: add localizable error messages

This commit is contained in:
Xylight committed 2024-07-31 20:27:47 -07:00
1 parent cee02cbc99
commit f386ba94a6
5 files changed
+51 -3

No files matched your search

+7 -1
View File
@@ -16,7 +16,13 @@
themeVars,
} from '$lib/ui/colors.js'
import { userSettings } from '$lib/settings.js'
import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte'
import {
Button,
ModalContainer,
Spinner,
toast,
ToastContainer,
} from 'mono-svelte'
import { onMount } from 'svelte'
import { browser } from '$app/environment'
import { Forward, Icon } from 'svelte-hero-icons'
+14 -2
View File
@@ -20,6 +20,7 @@
import { MINIMUM_VERSION } from '$lib/version.js'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { errorMessage } from '$lib/lemmy/error'
let data = {
instance: DEFAULT_INSTANCE_URL,
@@ -27,6 +28,7 @@
password: '',
totp: '',
loading: false,
attempts: 0,
}
async function logIn() {
@@ -56,16 +58,26 @@
}
} catch (error) {
toast({
content: error as any,
content:
JSON.parse((error as any)?.body?.message ?? '{}')?.error ==
'incorrect_login'
? errorMessage(
'incorrect_login' +
(data.attempts == 0 || data.attempts >= 12
? ''
: `_${data.attempts + 1}`)
)
: errorMessage(error),
type: 'error',
})
data.attempts++
}
data.loading = false
}
</script>
<svelte:head>
<title>Login</title>
<title>{$t('account.login')}</title>
</svelte:head>
<div class="max-w-xl w-full mx-auto h-max my-auto">