1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 14:59:36 +02:00

Add language selection and share localization for multiple languages

This commit is contained in:
Sean Morley 2024-11-04 19:41:25 -05:00
parent 9ac4a8f4e9
commit 9c6e11b16d
10 changed files with 266 additions and 29 deletions

View file

@ -252,15 +252,20 @@
<button formaction="/?/setTheme&theme=aqua"
>{$t('navbar.themes.aqua')}<Water class="w-6 h-6" /></button
>
<form method="POST" use:enhance>
<select class="select" on:change={submitLocaleChange} bind:value={$locale}>
{#each $locales as loc}
<option value={loc}>{loc}</option>
{/each}
</select>
<input type="hidden" name="locale" value={$locale} />
</form>
</li>
<p class="font-bold m-4 text-lg text-center">{$t('navbar.language_selection')}</p>
<form method="POST" use:enhance>
<select
class="select select-bordered w-full max-w-xs bg-base-100 text-base-content"
on:change={submitLocaleChange}
bind:value={$locale}
>
{#each $locales as loc}
<option value={loc} class="text-base-content">{$t(`languages.${loc}`)}</option>
{/each}
</select>
<input type="hidden" name="locale" value={$locale} />
</form>
</form>
</ul>
</div>

View file

@ -6,6 +6,7 @@
import UserCard from './UserCard.svelte';
import { addToast } from '$lib/toasts';
let modal: HTMLDialogElement;
import { t } from 'svelte-i18n';
export let collection: Collection;
@ -25,7 +26,10 @@
sharedWithUsers = sharedWithUsers.concat(user);
collection.shared_with.push(user.uuid);
notSharedWithUsers = notSharedWithUsers.filter((u) => u.uuid !== user.uuid);
addToast('success', `Shared ${collection.name} with ${user.first_name} ${user.last_name}`);
addToast(
'success',
`${$t('share.shared')} ${collection.name} ${$t('share.with')} ${user.first_name} ${user.last_name}`
);
}
}
@ -40,7 +44,10 @@
notSharedWithUsers = notSharedWithUsers.concat(user);
collection.shared_with = collection.shared_with.filter((u) => u !== user.uuid);
sharedWithUsers = sharedWithUsers.filter((u) => u.uuid !== user.uuid);
addToast('success', `Unshared ${collection.name} with ${user.first_name} ${user.last_name}`);
addToast(
'success',
`${$t('share.unshared')} ${collection.name} ${$t('share.with')} ${user.first_name} ${user.last_name}`
);
}
}
@ -75,10 +82,10 @@
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0">
<h3 class="font-bold text-lg">Share {collection.name}</h3>
<p class="py-1">Share this collection with other users.</p>
<h3 class="font-bold text-lg">{$t('adventures.share')} {collection.name}</h3>
<p class="py-1">{$t('share.share_desc')}</p>
<div class="divider"></div>
<h3 class="font-bold text-md">Shared With</h3>
<h3 class="font-bold text-md">{$t('share.shared_with')}</h3>
<ul>
{#each sharedWithUsers as user}
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
@ -92,11 +99,11 @@
</div>
{/each}
{#if sharedWithUsers.length === 0}
<p class="text-neutral-content">No users shared with</p>
<p class="text-neutral-content">{$t('share.no_users_shared')}</p>
{/if}
</ul>
<div class="divider"></div>
<h3 class="font-bold text-md">Not Shared With</h3>
<h3 class="font-bold text-md">{$t('share.not_shared_with')}</h3>
<ul>
{#each notSharedWithUsers as user}
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
@ -110,9 +117,9 @@
</div>
{/each}
{#if notSharedWithUsers.length === 0}
<p class="text-neutral-content">No users not shared with</p>
<p class="text-neutral-content">{$t('share.no_users_shared')}</p>
{/if}
</ul>
<button class="btn btn-primary mt-4" on:click={close}>Close</button>
<button class="btn btn-primary mt-4" on:click={close}>{$t('about.close')}</button>
</div>
</dialog>