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

more localization

This commit is contained in:
Sean Morley 2024-10-28 19:59:44 -04:00
parent 5011829e6e
commit fcd2d27221
12 changed files with 302 additions and 36 deletions

View file

@ -49,8 +49,7 @@
}
});
if (res.ok) {
console.log('Adventure deleted');
addToast('info', 'Adventure deleted successfully!');
addToast('info', $t('adventures.adventure_delete_success'));
dispatch('delete', adventure.id);
} else {
console.log('Error deleting adventure');
@ -107,7 +106,7 @@
{#if isWarningModalOpen}
<DeleteWarning
title="Delete Adventure"
title={$t('adventures.delete_adventure')}
button_text="Delete"
description={$t('adventures.adventure_delete_confirm')}
is_warning={false}
@ -132,8 +131,12 @@
</div>
<div>
<div class="badge badge-primary">{$t(`adventures.activities.${adventure.type}`)}</div>
<div class="badge badge-success">{isAdventureVisited(adventure) ? 'Visited' : 'Planned'}</div>
<div class="badge badge-secondary">{adventure.is_public ? 'Public' : 'Private'}</div>
<div class="badge badge-success">
{isAdventureVisited(adventure) ? $t('adventures.visited') : $t('adventures.planned')}
</div>
<div class="badge badge-secondary">
{adventure.is_public ? $t('adventures.public') : $t('adventures.private')}
</div>
</div>
{#if adventure.location && adventure.location !== ''}
<div class="inline-flex items-center">
@ -147,7 +150,7 @@
<Calendar class="w-5 h-5 mr-1" />
<p class="ml-.5">
{adventure.visits.length}
{adventure.visits.length > 1 ? 'visits' : 'visit'}
{adventure.visits.length > 1 ? $t('adventures.visits') : $t('adventures.visit')}
</p>
</div>
{/if}

View file

@ -5,6 +5,7 @@
import { enhance } from '$app/forms';
import { addToast } from '$lib/toasts';
import { deserialize } from '$app/forms';
import { t } from 'svelte-i18n';
export let longitude: number | null = null;
export let latitude: number | null = null;
@ -111,9 +112,9 @@
images = images.filter((image) => image.id !== id);
adventure.images = images;
console.log(images);
addToast('success', 'Image removed');
addToast('success', $t('adventures.image_removed_success'));
} else {
addToast('error', 'Failed to remove image');
addToast('error', $t('adventures.image_removed_error'));
}
}
@ -139,7 +140,7 @@
let res = await fetch(url);
let data = await res.blob();
if (!data) {
imageError = 'No image found at that URL.';
imageError = $t('adventures.no_image_url');
return;
}
let file = new File([data], 'image.jpg', { type: 'image/jpeg' });
@ -155,9 +156,9 @@
if (data2.type === 'success') {
images = [...images, data2];
adventure.images = images;
addToast('success', 'Image uploaded');
addToast('success', $t('adventures.image_upload_success'));
} else {
addToast('error', 'Failed to upload image');
addToast('error', $t('adventures.image_upload_error'));
}
}
@ -187,10 +188,10 @@
console.log(newImage);
images = [...images, newImage];
adventure.images = images;
addToast('success', 'Image uploaded');
addToast('success', $t('adventures.image_upload_success'));
} else {
addToast('error', 'Failed to upload image');
wikiImageError = 'Failed to upload image';
addToast('error', $t('adventures.image_upload_error'));
wikiImageError = $t('adventures.wiki_image_error');
}
}
}
@ -225,7 +226,7 @@
new_end_date = new_start_date;
}
if (new_start_date > new_end_date) {
addToast('error', 'Start date must be before end date');
addToast('error', $t('adventures.start_before_end_error'));
return;
}
if (new_start_date === '' || new_end_date === '') {

View file

@ -109,12 +109,14 @@
<p>{collection.adventures.length} {$t('navbar.adventures')}</p>
{#if collection.start_date && collection.end_date}
<p>
Dates: {new Date(collection.start_date).toLocaleDateString(undefined, { timeZone: 'UTC' })} -
{$t('adventures.dates')}: {new Date(collection.start_date).toLocaleDateString(undefined, {
timeZone: 'UTC'
})} -
{new Date(collection.end_date).toLocaleDateString(undefined, { timeZone: 'UTC' })}
</p>
<!-- display the duration in days -->
<p>
Duration: {Math.floor(
{$t('adventures.duration')}: {Math.floor(
(new Date(collection.end_date).getTime() - new Date(collection.start_date).getTime()) /
(1000 * 60 * 60 * 24)
) + 1}{' '}