diff --git a/.vscode/settings.json b/.vscode/settings.json index 23830fb4..11f6a2d0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,29 @@ { - "git.ignoreLimitWarning": true + "git.ignoreLimitWarning": true, + "i18n-ally.localesPaths": [ + "frontend/src/locales", + "backend/server/backend/lib/python3.12/site-packages/allauth/locale", + "backend/server/backend/lib/python3.12/site-packages/dj_rest_auth/locale", + "backend/server/backend/lib/python3.12/site-packages/rest_framework/locale", + "backend/server/backend/lib/python3.12/site-packages/rest_framework_simplejwt/locale", + "backend/server/backend/lib/python3.12/site-packages/django/conf/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/messages", + "backend/server/backend/lib/python3.12/site-packages/allauth/templates/account/messages", + "backend/server/backend/lib/python3.12/site-packages/allauth/templates/mfa/messages", + "backend/server/backend/lib/python3.12/site-packages/allauth/templates/socialaccount/messages", + "backend/server/backend/lib/python3.12/site-packages/allauth/templates/usersessions/messages", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/admindocs/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/auth/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/admin/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/contenttypes/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/flatpages/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/humanize/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/gis/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/redirects/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/postgres/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/sessions/locale", + "backend/server/backend/lib/python3.12/site-packages/django/contrib/sites/locale", + "backend/server/backend/lib/python3.12/site-packages/rest_framework/templates/rest_framework/docs/langs" + ], + "i18n-ally.keystyle": "nested" } diff --git a/frontend/src/hooks.server.ts b/frontend/src/hooks.server.ts index 6cc4f463..0c1f991d 100644 --- a/frontend/src/hooks.server.ts +++ b/frontend/src/hooks.server.ts @@ -109,17 +109,11 @@ export const themeHook: Handle = async ({ event, resolve }) => { // hook to get the langauge cookie and set the locale export const i18nHook: Handle = async ({ event, resolve }) => { - let lang = event.cookies.get('lang'); - if (!lang) { - lang = ''; // Set default locale - event.cookies.set('lang', lang, { - httpOnly: true, - sameSite: 'lax', - expires: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000), // 1 year - path: '/' - }); + let locale = event.cookies.get('locale'); + if (!locale) { + return await resolve(event); } - event.locals.locale = lang; // Store the locale in locals + event.locals.locale = locale; // Store the locale in locals return await resolve(event); }; diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index b30fb415..00a84511 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -11,15 +11,14 @@ import MapMarker from '~icons/mdi/map-marker'; import { addToast } from '$lib/toasts'; import Link from '~icons/mdi/link-variant'; - import CheckBold from '~icons/mdi/check-bold'; - import FormatListBulletedSquare from '~icons/mdi/format-list-bulleted-square'; import LinkVariantRemove from '~icons/mdi/link-variant-remove'; import Plus from '~icons/mdi/plus'; import CollectionLink from './CollectionLink.svelte'; import DotsHorizontal from '~icons/mdi/dots-horizontal'; import DeleteWarning from './DeleteWarning.svelte'; - import { isAdventureVisited, typeToString } from '$lib'; + import { isAdventureVisited } from '$lib'; import CardCarousel from './CardCarousel.svelte'; + import { t } from 'svelte-i18n'; export let type: string; export let user: User | null; @@ -67,34 +66,13 @@ body: JSON.stringify({ collection: null }) }); if (res.ok) { - console.log('Adventure removed from collection'); - addToast('info', 'Adventure removed from collection successfully!'); + addToast('info', `${$t('adventures.collection_remove_success')}`); dispatch('delete', adventure.id); } else { - console.log('Error removing adventure from collection'); + addToast('error', `${$t('adventures.collection_remove_error')}`); } } - function changeType(newType: string) { - return async () => { - let res = await fetch(`/api/adventures/${adventure.id}/`, { - method: 'PATCH', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ type: newType }) - }); - if (res.ok) { - console.log('Adventure type changed'); - dispatch('typeChange', adventure.id); - addToast('info', 'Adventure type changed successfully!'); - adventure.type = newType; - } else { - console.log('Error changing adventure type'); - } - }; - } - async function linkCollection(event: CustomEvent) { let collectionId = event.detail; let res = await fetch(`/api/adventures/${adventure.id}`, { @@ -106,11 +84,11 @@ }); if (res.ok) { console.log('Adventure linked to collection'); - addToast('info', 'Adventure linked to collection successfully!'); + addToast('info', `${$t('adventures.collection_link_success')}`); isCollectionModalOpen = false; dispatch('delete', adventure.id); } else { - console.log('Error linking adventure to collection'); + addToast('error', `${$t('adventures.collection_link_error')}`); } } @@ -131,7 +109,7 @@ (isWarningModalOpen = false)} on:confirm={deleteAdventure} @@ -153,7 +131,7 @@
-
{typeToString(adventure.type)}
+
{$t(`adventures.activities.${adventure.type}`)}
{isAdventureVisited(adventure) ? 'Visited' : 'Planned'}
{adventure.is_public ? 'Public' : 'Private'}
@@ -198,30 +176,24 @@ {$t('adventures.open_details')} - {#if adventure.type == 'visited' && user?.pk == adventure.user_id} - - {/if} - {#if adventure.type == 'planned' && user?.pk == adventure.user_id} - - {/if} + {#if adventure.collection && user?.pk == adventure.user_id} {$t( + 'adventures.remove_from_collection' + )} {/if} {#if !adventure.collection} {$t('adventures.add_to_collection')} {/if} {$t('adventures.delete')} diff --git a/frontend/src/lib/components/Avatar.svelte b/frontend/src/lib/components/Avatar.svelte index 5f9c1c8e..4f95b6d7 100644 --- a/frontend/src/lib/components/Avatar.svelte +++ b/frontend/src/lib/components/Avatar.svelte @@ -15,7 +15,7 @@
{#if user.profile_pic} - User Profile + {$t('navbar.profile')} {:else} {letter} {/if} diff --git a/frontend/src/lib/components/CardCarousel.svelte b/frontend/src/lib/components/CardCarousel.svelte index ca9e6520..07718bd4 100644 --- a/frontend/src/lib/components/CardCarousel.svelte +++ b/frontend/src/lib/components/CardCarousel.svelte @@ -1,6 +1,7 @@