From 1dc8e1075805355280be3c8990155c4ab8862bab Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Tue, 18 Mar 2025 17:40:32 -0400 Subject: [PATCH] feat: Add "all day" localization strings for multiple languages and enhance transportation date handling --- .../src/lib/components/AdventureModal.svelte | 55 ++++++++++--------- .../src/lib/components/LodgingCard.svelte | 4 +- .../lib/components/TransportationCard.svelte | 16 +++++- .../lib/components/TransportationModal.svelte | 38 ++++++++++++- frontend/src/lib/index.ts | 11 ++++ frontend/src/locales/de.json | 3 +- frontend/src/locales/en.json | 1 + frontend/src/locales/es.json | 3 +- frontend/src/locales/fr.json | 3 +- frontend/src/locales/it.json | 3 +- frontend/src/locales/ko.json | 3 +- frontend/src/locales/nl.json | 3 +- frontend/src/locales/pl.json | 3 +- frontend/src/locales/sv.json | 3 +- frontend/src/locales/zh.json | 3 +- .../src/routes/adventures/[id]/+page.svelte | 14 +++-- 16 files changed, 118 insertions(+), 48 deletions(-) diff --git a/frontend/src/lib/components/AdventureModal.svelte b/frontend/src/lib/components/AdventureModal.svelte index b9daa0f..1321db0 100644 --- a/frontend/src/lib/components/AdventureModal.svelte +++ b/frontend/src/lib/components/AdventureModal.svelte @@ -8,7 +8,7 @@ let fullStartDate: string = ''; let fullEndDate: string = ''; - let allDay: boolean = false; + let allDay: boolean = true; // Set full start and end dates from collection if (collection && collection.start_date && collection.end_date) { @@ -698,13 +698,13 @@ on:change={() => (constrainDates = !constrainDates)} /> {/if} - All Day + {$t('adventures.all_day')} (allDay = !allDay)} + bind:checked={allDay} />
@@ -782,30 +782,31 @@ }} >
- - + {#if !allDay} + + {/if}
diff --git a/frontend/src/lib/components/TransportationModal.svelte b/frontend/src/lib/components/TransportationModal.svelte index 9012dd9..1d4a516 100644 --- a/frontend/src/lib/components/TransportationModal.svelte +++ b/frontend/src/lib/components/TransportationModal.svelte @@ -16,10 +16,15 @@ let constrainDates: boolean = false; + // Format date as local datetime + // Convert an ISO date to a datetime-local value in local time. function toLocalDatetime(value: string | null): string { if (!value) return ''; const date = new Date(value); - return date.toISOString().slice(0, 16); // Format: YYYY-MM-DDTHH:mm + // Adjust the time by subtracting the timezone offset. + date.setMinutes(date.getMinutes() - date.getTimezoneOffset()); + // Return format YYYY-MM-DDTHH:mm + return date.toISOString().slice(0, 16); } let transportation: Transportation = { @@ -185,6 +190,14 @@ return; } + // Convert local dates to UTC + if (transportation.date && !transportation.date.includes('Z')) { + transportation.date = new Date(transportation.date).toISOString(); + } + if (transportation.end_date && !transportation.end_date.includes('Z')) { + transportation.end_date = new Date(transportation.end_date).toISOString(); + } + if (transportation.type != 'plane') { transportation.flight_number = ''; } @@ -422,6 +435,29 @@ {/if} + diff --git a/frontend/src/lib/index.ts b/frontend/src/lib/index.ts index fd21597..70aef59 100644 --- a/frontend/src/lib/index.ts +++ b/frontend/src/lib/index.ts @@ -338,6 +338,17 @@ export let LODGING_TYPES_ICONS = { other: '❓' }; +export let TRANSPORTATION_TYPES_ICONS = { + car: '🚗', + plane: '✈️', + train: '🚆', + bus: '🚌', + boat: '⛵', + bike: '🚲', + walking: '🚶', + other: '❓' +}; + // Helper to check if a given date string represents midnight (all-day) export function isAllDay(dateStr: string | string[]) { // Checks for the pattern "T00:00:00.000Z" diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 56c84dc..c0d939e 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -247,7 +247,8 @@ "price": "Preis", "reservation_number": "Reservierungsnummer", "welcome_map_info": "Frei zugängliche Abenteuer auf diesem Server", - "open_in_maps": "In Karten öffnen" + "open_in_maps": "In Karten öffnen", + "all_day": "Den ganzen Tag" }, "home": { "desc_1": "Entdecken, planen und erkunden Sie mühelos", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 25a79de..4e32577 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -250,6 +250,7 @@ "show_map": "Show Map", "emoji_picker": "Emoji Picker", "download_calendar": "Download Calendar", + "all_day": "All Day", "date_information": "Date Information", "flight_information": "Flight Information", "out_of_range": "Not in itinerary date range", diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json index 3814ec2..bd9b6a4 100644 --- a/frontend/src/locales/es.json +++ b/frontend/src/locales/es.json @@ -295,7 +295,8 @@ "region": "Región", "reservation_number": "Número de reserva", "welcome_map_info": "Aventuras públicas en este servidor", - "open_in_maps": "Abrir en mapas" + "open_in_maps": "Abrir en mapas", + "all_day": "Todo el día" }, "worldtravel": { "all": "Todo", diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json index 3e6ec37..2523fe5 100644 --- a/frontend/src/locales/fr.json +++ b/frontend/src/locales/fr.json @@ -247,7 +247,8 @@ "region": "Région", "reservation_number": "Numéro de réservation", "welcome_map_info": "Aventures publiques sur ce serveur", - "open_in_maps": "Ouvert dans les cartes" + "open_in_maps": "Ouvert dans les cartes", + "all_day": "Toute la journée" }, "home": { "desc_1": "Découvrez, planifiez et explorez en toute simplicité", diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.json index a68ce99..216d121 100644 --- a/frontend/src/locales/it.json +++ b/frontend/src/locales/it.json @@ -247,7 +247,8 @@ "region": "Regione", "welcome_map_info": "Avventure pubbliche su questo server", "reservation_number": "Numero di prenotazione", - "open_in_maps": "Aperto in mappe" + "open_in_maps": "Aperto in mappe", + "all_day": "Tutto il giorno" }, "home": { "desc_1": "Scopri, pianifica ed esplora con facilità", diff --git a/frontend/src/locales/ko.json b/frontend/src/locales/ko.json index bfe761b..2099c0c 100644 --- a/frontend/src/locales/ko.json +++ b/frontend/src/locales/ko.json @@ -247,7 +247,8 @@ "region": "지역", "reservation_number": "예약 번호", "welcome_map_info": "이 서버의 공개 모험", - "open_in_maps": "지도에서 열립니다" + "open_in_maps": "지도에서 열립니다", + "all_day": "하루 종일" }, "auth": { "both_passwords_required": "두 암호 모두 필요합니다", diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json index 4a783ec..6dbf2d7 100644 --- a/frontend/src/locales/nl.json +++ b/frontend/src/locales/nl.json @@ -247,7 +247,8 @@ "lodging_information": "Informatie overliggen", "price": "Prijs", "region": "Regio", - "open_in_maps": "Open in kaarten" + "open_in_maps": "Open in kaarten", + "all_day": "De hele dag" }, "home": { "desc_1": "Ontdek, plan en verken met gemak", diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.json index 3925de1..3eb73ac 100644 --- a/frontend/src/locales/pl.json +++ b/frontend/src/locales/pl.json @@ -295,7 +295,8 @@ "region": "Region", "reservation_number": "Numer rezerwacji", "welcome_map_info": "Publiczne przygody na tym serwerze", - "open_in_maps": "Otwarte w mapach" + "open_in_maps": "Otwarte w mapach", + "all_day": "Cały dzień" }, "worldtravel": { "country_list": "Lista krajów", diff --git a/frontend/src/locales/sv.json b/frontend/src/locales/sv.json index c6fd200..0baff34 100644 --- a/frontend/src/locales/sv.json +++ b/frontend/src/locales/sv.json @@ -247,7 +247,8 @@ "price": "Pris", "region": "Område", "reservation_number": "Bokningsnummer", - "open_in_maps": "Kappas in" + "open_in_maps": "Kappas in", + "all_day": "Hela dagen" }, "home": { "desc_1": "Upptäck, planera och utforska med lätthet", diff --git a/frontend/src/locales/zh.json b/frontend/src/locales/zh.json index 864d699..dfd5e8e 100644 --- a/frontend/src/locales/zh.json +++ b/frontend/src/locales/zh.json @@ -295,7 +295,8 @@ "lodging_information": "住宿信息", "price": "价格", "reservation_number": "预订号", - "open_in_maps": "在地图上打开" + "open_in_maps": "在地图上打开", + "all_day": "整天" }, "auth": { "forgot_password": "忘记密码?", diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index 17f1ae3..6d88e0e 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -456,12 +456,14 @@ {/if} - {$t('adventures.open_in_maps')} + {#if adventure.longitude && adventure.latitude} + {$t('adventures.open_in_maps')} + {/if}