Refactor localization strings and add missing translations

This commit is contained in:
Sean Morley
2024-10-29 10:29:03 -04:00
parent fcd2d27221
commit 05076a6732
15 changed files with 1245 additions and 441 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation';
import type { PageData } from './$types';
import { t } from 'svelte-i18n';
export let data: PageData;
@@ -11,8 +12,8 @@
<table class="table table-compact">
<thead>
<tr>
<th>Activity</th>
<th>Actions</th>
<th>{$t('adventures.activity')}</th>
<th>{$t('adventures.actions')}</th>
</tr>
</thead>
<tbody>
@@ -23,7 +24,7 @@
<button
class="btn btn-sm btn-primary"
on:click={() => goto(`/search?query=${activity}&property=activity_types`)}
>See Adventures</button
>{$t('adventures.see_adventures')}</button
>
</td>
</tr>

View File

@@ -1,12 +1,11 @@
<script lang="ts">
import { enhance } from '$app/forms';
import { goto, invalidateAll } from '$app/navigation';
import { page } from '$app/stores';
import { addToast } from '$lib/toasts';
import type { Adventure, Collection, User } from '$lib/types.js';
import type { User } from '$lib/types.js';
import { onMount } from 'svelte';
import { browser } from '$app/environment';
import { exportData } from '$lib';
import { t } from 'svelte-i18n';
export let data;
let user: User;
@@ -20,7 +19,7 @@
const pageParam = queryParams.get('page');
if (pageParam === 'success') {
addToast('success', 'Settings updated successfully!');
addToast('success', $t('settings.update_success'));
console.log('Settings updated successfully!');
}
}
@@ -31,39 +30,39 @@
window.location.href = '/settings?page=success';
}
if (browser && $page.form?.error) {
addToast('error', 'Error updating settings');
addToast('error', $t('settings.update_error'));
}
}
async function exportAdventures() {
const url = await exportData();
// async function exportAdventures() {
// const url = await exportData();
const a = document.createElement('a');
a.href = url;
a.download = 'adventure-log-export.json';
a.click();
URL.revokeObjectURL(url);
}
// const a = document.createElement('a');
// a.href = url;
// a.download = 'adventure-log-export.json';
// a.click();
// URL.revokeObjectURL(url);
// }
async function checkVisitedRegions() {
let res = await fetch('/api/countries/region_check_all_adventures/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});
let data = await res.json();
if (res.ok) {
addToast('success', `${data.regions_visited} regions updated`);
} else {
addToast('error', 'Error updating visited regions');
}
}
// async function checkVisitedRegions() {
// let res = await fetch('/api/countries/region_check_all_adventures/', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// }
// });
// let data = await res.json();
// if (res.ok) {
// addToast('success', `${data.regions_visited} regions updated`);
// } else {
// addToast('error', 'Error updating visited regions');
// }
// }
</script>
<h1 class="text-center font-extrabold text-4xl mb-6">Settings Page</h1>
<h1 class="text-center font-extrabold text-4xl mb-6">{$t('settings.settings_page')}</h1>
<h1 class="text-center font-extrabold text-xl">User Account Settings</h1>
<h1 class="text-center font-extrabold text-xl">{$t('settings.account_settings')}</h1>
<div class="flex justify-center">
<form
method="post"
@@ -72,14 +71,14 @@
class="w-full max-w-xs"
enctype="multipart/form-data"
>
<label for="username">Username</label>
<label for="username">{$t('auth.username')}</label>
<input
bind:value={user.username}
name="username"
id="username"
class="block mb-2 input input-bordered w-full max-w-xs"
/><br />
<label for="first_name">First Name</label>
<label for="first_name">{$t('auth.first_name')}</label>
<input
type="text"
bind:value={user.first_name}
@@ -88,7 +87,7 @@
class="block mb-2 input input-bordered w-full max-w-xs"
/><br />
<label for="last_name">Last Name</label>
<label for="last_name">{$t('auth.last_name')}</label>
<input
type="text"
bind:value={user.last_name}
@@ -104,7 +103,7 @@
id="email"
class="block mb-2 input input-bordered w-full max-w-xs"
/><br /> -->
<label for="profilePicture">Profile Picture</label>
<label for="profilePicture">{$t('auth.profile_picture')}</label>
<input
type="file"
name="profile_pic"
@@ -112,12 +111,9 @@
class="file-input file-input-bordered w-full max-w-xs mb-2"
/><br />
<div class="form-control">
<div
class="tooltip tooltip-info"
data-tip="With a public profile, users can share collections with you and view your profile on the users page."
>
<div class="tooltip tooltip-info" data-tip={$t('auth.public_tooltip')}>
<label class="label cursor-pointer">
<span class="label-text">Public Profile</span>
<span class="label-text">{$t('auth.public_profile')}</span>
<input
id="public_profile"
@@ -129,7 +125,7 @@
</label>
</div>
</div>
<button class="py-2 mt-2 px-4 btn btn-primary">Update</button>
<button class="py-2 mt-2 px-4 btn btn-primary">{$t('settings.update')}</button>
</form>
</div>
@@ -139,13 +135,13 @@
</div>
{/if}
<h1 class="text-center font-extrabold text-xl mt-4 mb-2">Password Change</h1>
<h1 class="text-center font-extrabold text-xl mt-4 mb-2">{$t('settings.password_change')}</h1>
<div class="flex justify-center">
<form action="?/changePassword" method="post" class="w-full max-w-xs">
<input
type="password"
name="password1"
placeholder="New Password"
placeholder={$t('settings.new_password')}
id="password1"
class="block mb-2 input input-bordered w-full max-w-xs"
/>
@@ -154,22 +150,22 @@
type="password"
name="password2"
id="password2"
placeholder="Confirm New Password"
placeholder={$t('settings.confirm_new_password')}
class="block mb-2 input input-bordered w-full max-w-xs"
/>
<button class="py-2 px-4 btn btn-primary mt-2">Change Password</button>
<button class="py-2 px-4 btn btn-primary mt-2">{$t('settings.password_change')}</button>
<br />
</form>
</div>
<h1 class="text-center font-extrabold text-xl mt-4 mb-2">Email Change</h1>
<h1 class="text-center font-extrabold text-xl mt-4 mb-2">{$t('settings.email_change')}</h1>
<div class="flex justify-center">
<form action="?/changeEmail" method="post" class="w-full max-w-xs">
<label for="current_email">Current Email</label>
<label for="current_email">{$t('settings.current_email')}</label>
<input
type="email"
name="current_email"
placeholder={user.email || 'No Email Set'}
placeholder={user.email || $t('settings.no_email_set')}
id="current_email"
readonly
class="block mb-2 input input-bordered w-full max-w-xs"
@@ -178,11 +174,11 @@
<input
type="email"
name="new_email"
placeholder="New Email"
placeholder={$t('settings.new_email')}
id="new_email"
class="block mb-2 input input-bordered w-full max-w-xs"
/>
<button class="py-2 px-4 btn btn-primary mt-2">Change Email</button>
<button class="py-2 px-4 btn btn-primary mt-2">{$t('settings.email_change')}</button>
</form>
</div>

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { enhance } from '$app/forms';
import { t } from 'svelte-i18n';
export let data;
console.log(data);
@@ -34,46 +35,46 @@
{#if !is_disabled}
<h3 class="text-center">AdventureLog</h3>
<article class="text-center text-4xl mb-4 font-extrabold">
<h1>Signup</h1>
<h1>{$t('auth.signup')}</h1>
</article>
<div class="flex justify-center">
<form method="post" use:enhance class="w-full max-w-xs">
<label for="username">Username</label>
<label for="username">{$t('auth.username')}</label>
<input
name="username"
id="username"
class="block input input-bordered w-full max-w-xs"
/><br />
<label for="email">Email</label>
<label for="email">{$t('auth.email')}</label>
<input
name="email"
id="email"
type="email"
class="block input input-bordered w-full max-w-xs"
/><br />
<label for="first_name">First Name</label>
<label for="first_name">{$t('auth.first_name')}</label>
<input
name="first_name"
id="first_name"
type="text"
class="block input input-bordered w-full max-w-xs"
/><br />
<label for="last_name">Last Name</label>
<label for="last_name">{$t('auth.last_name')}</label>
<input
name="last_name"
id="last_name"
type="text"
class="block input input-bordered w-full max-w-xs"
/><br />
<label for="password">Password</label>
<label for="password">{$t('auth.password')}</label>
<input
type="password"
name="password1"
id="password"
class="block input input-bordered w-full max-w-xs"
/><br />
<label for="password">Confirm Password</label>
<label for="password">{$t('auth.confirm_password')}</label>
<input
type="password"
name="password2"
@@ -81,11 +82,15 @@
class="block input input-bordered w-full max-w-xs"
/><br />
<button class="py-2 px-4 btn btn-primary mr-2">Signup</button>
<button class="py-2 px-4 btn btn-primary mr-2">{$t('auth.signup')}</button>
<div class="flex justify-between mt-4">
<p><a href="/login" class="underline">Login</a></p>
<p><a href="/settings/forgot-password" class="underline">Forgot Password</a></p>
<p><a href="/login" class="underline">{$t('auth.login')}</a></p>
<p>
<a href="/settings/forgot-password" class="underline"
>{$t('auth.forgot_password')}</a
>
</p>
</div>
</form>
</div>
@@ -96,7 +101,7 @@
{:else}
<div class="flex justify-center">
<div class="text-center mb-4">
<h1 class="text-4xl font-extrabold">Registration is Disabled</h1>
<h1 class="text-4xl font-extrabold">{$t('auth.registration_disabled')}</h1>
<p class="text-lg mt-4">{is_disabled_message}</p>
</div>
</div>

View File

@@ -2,13 +2,14 @@
import UserCard from '$lib/components/UserCard.svelte';
import type { User } from '$lib/types';
import type { PageData } from './$types';
import { t } from 'svelte-i18n';
export let data: PageData;
let users: User[] = data.props.users;
console.log(users);
</script>
<h1 class="text-center font-bold text-4xl mb-4">AdventureLog Users</h1>
<h1 class="text-center font-bold text-4xl mb-4">AdventureLog {$t('navbar.users')}</h1>
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each users as user (user.uuid)}
<UserCard {user} />
@@ -16,7 +17,7 @@
</div>
{#if users.length === 0}
<p class="text-center">No users found with public profiles.</p>
<p class="text-center">{$t('users.no_users_found')}</p>
{/if}
<svelte:head>