i18n: localize login page

This commit is contained in:
Xylight committed 2024-06-03 16:21:28 -07:00
1 parent 8278cff51e
commit 3d76bb7330
3 files changed
+29 -25

No files matched your search

+3 -1
View File
@@ -44,7 +44,8 @@
"addGuest": "Add Guest", "addGuest": "Add Guest",
"moveUp": "Move Up", "moveUp": "Move Up",
"moveDown": "Move Down", "moveDown": "Move Down",
"guest": "Guest" "guest": "Guest",
"versionGate": "This version of Photon supports instances running {{version}} or higher."
}, },
"filter": { "filter": {
"location": { "location": {
@@ -92,6 +93,7 @@
}, },
"form": { "form": {
"username": "Username", "username": "Username",
"name": "Name",
"instance": "Instance URL", "instance": "Instance URL",
"password": "Password", "password": "Password",
"2fa": "2FA Code", "2fa": "2FA Code",
+15 -14
View File
@@ -18,6 +18,8 @@
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { DOMAIN_REGEX_FORMS } from '$lib/util.js' import { DOMAIN_REGEX_FORMS } from '$lib/util.js'
import { MINIMUM_VERSION } from '$lib/version.js' import { MINIMUM_VERSION } from '$lib/version.js'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let data = { let data = {
instance: DEFAULT_INSTANCE_URL, instance: DEFAULT_INSTANCE_URL,
@@ -69,14 +71,13 @@
<div class="max-w-xl w-full mx-auto h-max my-auto"> <div class="max-w-xl w-full mx-auto h-max my-auto">
<form on:submit|preventDefault={logIn} class="flex flex-col gap-5"> <form on:submit|preventDefault={logIn} class="flex flex-col gap-5">
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<h1 class="font-bold text-3xl">Log In</h1> <Header>{$t('account.login')}</Header>
{#if $site && mayBeIncompatible(MINIMUM_VERSION, $site.version.replace('v', ''))} {#if $site && mayBeIncompatible(MINIMUM_VERSION, $site.version.replace('v', ''))}
<Note> <Note>
This version of Photon supports instances running {$t('account.versionGate', {
<span style="font-family: monospace;"> //@ts-ignore
v{MINIMUM_VERSION} version: `v${MINIMUM_VERSION}`,
</span> })}
or higher.
</Note> </Note>
{/if} {/if}
</div> </div>
@@ -84,14 +85,14 @@
<TextInput <TextInput
id="username" id="username"
bind:value={data.username} bind:value={data.username}
label="Username" label={$t('form.username')}
class="flex-1" class="flex-1"
required required
/> />
{#if !LINKED_INSTANCE_URL} {#if !LINKED_INSTANCE_URL}
<TextInput <TextInput
id="instance_url" id="instance_url"
label="Instance URL" label={$t('form.instance')}
placeholder={DEFAULT_INSTANCE_URL} placeholder={DEFAULT_INSTANCE_URL}
disabled={LINKED_INSTANCE_URL != undefined} disabled={LINKED_INSTANCE_URL != undefined}
bind:value={data.instance} bind:value={data.instance}
@@ -105,7 +106,7 @@
<TextInput <TextInput
id="password" id="password"
bind:value={data.password} bind:value={data.password}
label="Password" label={$t('form.password')}
type="password" type="password"
minlength={10} minlength={10}
maxlength={60} maxlength={60}
@@ -115,7 +116,7 @@
<TextInput <TextInput
id="totp" id="totp"
bind:value={data.totp} bind:value={data.totp}
label="2FA Code" label={$t('form.2fa')}
placeholder="123456" placeholder="123456"
pattern={'\\d{6}'} pattern={'\\d{6}'}
minlength={6} minlength={6}
@@ -130,21 +131,21 @@
size="lg" size="lg"
submit submit
> >
Log In {$t('account.login')}
</Button> </Button>
<hr class="dark:border-zinc-700" /> <hr class="dark:border-zinc-700" />
<div class="flex flex-row items-center gap-2"> <div class="flex flex-row items-center gap-2">
<Button color="tertiary" href="/signup"> <Button color="tertiary" href="/signup">
<Icon src={Identification} mini size="16" /> <Icon src={Identification} mini size="16" />
Sign Up {$t('account.signup')}
</Button> </Button>
<Button color="tertiary" href="/login_reset"> <Button color="tertiary" href="/login_reset">
<Icon src={QuestionMarkCircle} mini size="16" /> <Icon src={QuestionMarkCircle} mini size="16" />
Forgot Password {$t('form.forgotpassword')}
</Button> </Button>
<Button color="tertiary" href="/login/guest"> <Button color="tertiary" href="/login/guest">
<Icon src={UserCircle} mini size="16" /> <Icon src={UserCircle} mini size="16" />
Guest {$t('account.guest')}
</Button> </Button>
</div> </div>
</form> </form>
+11 -10
View File
@@ -7,10 +7,12 @@
import { profile, profileData, type Profile } from '$lib/auth' import { profile, profileData, type Profile } from '$lib/auth'
import { LINKED_INSTANCE_URL } from '$lib/instance' import { LINKED_INSTANCE_URL } from '$lib/instance'
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let form = { let form = {
instance: '', instance: '',
username: `Guest ${$profileData.profiles.filter((p) => p.jwt == undefined).length + 1}`, username: `${$t('account.guest')} ${$profileData.profiles.filter((p) => p.jwt == undefined).length + 1}`,
loading: false, loading: false,
} }
@@ -53,21 +55,20 @@
<div class="max-w-xl w-full mx-auto h-max my-auto"> <div class="max-w-xl w-full mx-auto h-max my-auto">
<form on:submit|preventDefault={addGuest} class="flex flex-col gap-5"> <form on:submit|preventDefault={addGuest} class="flex flex-col gap-5">
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<h1 class="font-bold text-3xl">Add Guest</h1> <Header>{$t('account.addGuest')}</Header>
{#if $site && mayBeIncompatible(MINIMUM_VERSION, $site.version.replace('v', ''))} {#if $site && mayBeIncompatible(MINIMUM_VERSION, $site.version.replace('v', ''))}
<Note> <Note>
This version of Photon supports instances running {$t('account.versionGate', {
<span style="font-family: monospace;"> //@ts-ignore
v{MINIMUM_VERSION} version: `v${MINIMUM_VERSION}`,
</span> })}
or higher.
</Note> </Note>
{/if} {/if}
</div> </div>
<div class="inline-flex items-center gap-2"> <div class="inline-flex items-center gap-2">
<TextInput <TextInput
required required
label="Name" label={$t('form.name')}
bind:value={form.username} bind:value={form.username}
placeholder="Guest 2" placeholder="Guest 2"
minlength={1} minlength={1}
@@ -76,7 +77,7 @@
{#if !LINKED_INSTANCE_URL} {#if !LINKED_INSTANCE_URL}
<TextInput <TextInput
required required
label="Instance URL" label={$t('form.instance')}
bind:value={form.instance} bind:value={form.instance}
pattern={DOMAIN_REGEX_FORMS} pattern={DOMAIN_REGEX_FORMS}
placeholder="example.com" placeholder="example.com"
@@ -92,7 +93,7 @@
loading={form.loading} loading={form.loading}
disabled={form.loading} disabled={form.loading}
> >
Submit {$t('form.submit')}
</Button> </Button>
</form> </form>
</div> </div>