From 91c36ee41c0c25a0c2e5e703770347dc00c8a13d Mon Sep 17 00:00:00 2001 From: Michael Zetterberg Date: Tue, 11 Mar 2025 13:12:06 +0100 Subject: [PATCH] fix: clean up dictionaries --- apps/scandic-web/app/global-error.tsx | 5 +- .../Carousel/CarouselNavigation.tsx | 9 ++- .../ContentType/DestinationPage/Map/index.tsx | 2 +- .../FormContent/BookingCode/index.tsx | 6 +- .../GuestsRoomsPicker/GuestsRoom/index.tsx | 9 ++- .../EnterDetails/Room/Multiroom.tsx | 7 ++- .../EnterDetails/Room/One.tsx | 7 ++- .../EnterDetails/Summary/UI/index.tsx | 7 ++- .../AddAncillaryFlowModal/index.tsx | 8 ++- .../ConfirmationStep/index.tsx | 5 +- .../Ancillaries/AddedAncillaries/index.tsx | 14 ++++- .../MyStay/CancelStay/Confirmation/index.tsx | 7 ++- .../MyStay/LinkedReservation/index.tsx | 41 ++++++++----- .../MyStay/ReferenceCard/index.tsx | 35 +++++++----- .../MyStay/Room/GuestDetails.tsx | 8 ++- .../HotelReservation/MyStay/Room/index.tsx | 57 ++++++++++++++----- .../PriceDetailsTable/index.tsx | 7 ++- .../SelectHotel/BookingCodeFilter/index.tsx | 2 +- .../HotelReservation/SelectHotel/index.tsx | 7 ++- .../RateSummary/MobileSummary/Summary.tsx | 7 ++- .../Rooms/MultiRoomWrapper/index.tsx | 36 +++++++----- .../RoomSelectionPanel/RoomCard/index.tsx | 16 ++++-- .../RoomTypeFilter/index.tsx | 2 +- .../HotelSidePeek/Accordions/Parking.tsx | 2 +- .../TempDesignSystem/AncillaryCard/index.tsx | 15 +++-- apps/scandic-web/i18n/dictionaries/da.json | 40 ++++++++----- apps/scandic-web/i18n/dictionaries/de.json | 40 ++++++++----- apps/scandic-web/i18n/dictionaries/en.json | 31 +++++----- apps/scandic-web/i18n/dictionaries/fi.json | 40 ++++++++----- apps/scandic-web/i18n/dictionaries/no.json | 40 ++++++++----- apps/scandic-web/i18n/dictionaries/sv.json | 40 ++++++++----- apps/scandic-web/providers/RatesProvider.tsx | 2 +- 32 files changed, 372 insertions(+), 182 deletions(-) diff --git a/apps/scandic-web/app/global-error.tsx b/apps/scandic-web/app/global-error.tsx index 1ff7f50d3..e317cfba4 100644 --- a/apps/scandic-web/app/global-error.tsx +++ b/apps/scandic-web/app/global-error.tsx @@ -2,6 +2,7 @@ import * as Sentry from "@sentry/nextjs" import { useEffect } from "react" +import { useIntl } from "react-intl" import styles from "./global-error.module.css" @@ -12,6 +13,8 @@ export default function GlobalError({ }) { console.log({ global_error: error }) + const intl = useIntl() + useEffect(() => { Sentry.captureException(error) }, [error]) @@ -20,7 +23,7 @@ export default function GlobalError({
-

Something went really wrong!

+

{intl.formatMessage({ id: "Something went really wrong!" })}

diff --git a/apps/scandic-web/components/Carousel/CarouselNavigation.tsx b/apps/scandic-web/components/Carousel/CarouselNavigation.tsx index 3f8566723..a367f13fc 100644 --- a/apps/scandic-web/components/Carousel/CarouselNavigation.tsx +++ b/apps/scandic-web/components/Carousel/CarouselNavigation.tsx @@ -1,6 +1,7 @@ "use client" import { cx } from "class-variance-authority" +import { useIntl } from "react-intl" import { ArrowRightIcon } from "@/components/Icons" @@ -13,13 +14,15 @@ import type { CarouselButtonProps } from "./types" export function CarouselPrevious({ className, ...props }: CarouselButtonProps) { const { scrollPrev, canScrollPrev } = useCarousel() + const intl = useIntl() + if (!canScrollPrev()) return null return ( ) } diff --git a/apps/scandic-web/components/GuestsRoomsPicker/GuestsRoom/index.tsx b/apps/scandic-web/components/GuestsRoomsPicker/GuestsRoom/index.tsx index e6ae3bb12..84f53ed8c 100644 --- a/apps/scandic-web/components/GuestsRoomsPicker/GuestsRoom/index.tsx +++ b/apps/scandic-web/components/GuestsRoomsPicker/GuestsRoom/index.tsx @@ -23,7 +23,12 @@ export function GuestsRoom({ onRemove: (index: number) => void }) { const intl = useIntl() - const roomLabel = intl.formatMessage({ id: "Room" }) + const roomLabel = intl.formatMessage( + { id: "Room {roomIndex}" }, + { + roomIndex: index + 1, + } + ) const childrenInAdultsBed = room.childrenInRoom.filter( (child) => child.bed === ChildBedMapEnum.IN_ADULTS_BED @@ -33,7 +38,7 @@ export function GuestsRoom({
- {roomLabel} {index + 1} + {roomLabel}
- {`${intl.formatMessage({ id: "Room" })} ${roomNr}`} + {intl.formatMessage( + { id: "Room {roomIndex}" }, + { + roomIndex: roomNr, + } + )}
diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Room/One.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Room/One.tsx index 84c98d560..090bf0988 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Room/One.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Room/One.tsx @@ -31,7 +31,12 @@ export default function RoomOne({ user }: { user: SafeUser }) { {isMultiroom ? (
- {`${intl.formatMessage({ id: "Room" })} 1`} + {intl.formatMessage( + { id: "Room {roomIndex}" }, + { + roomIndex: 1, + } + )}
) : null} diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx index 2ffa5aec2..220bc5ba9 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx @@ -149,7 +149,12 @@ export default function SummaryUI({
{rooms.length > 1 ? ( - {intl.formatMessage({ id: "Room" })} {roomNumber} + {intl.formatMessage( + { id: "Room {roomIndex}" }, + { + roomIndex: roomNumber, + } + )} ) : null}
diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx index 052e1945a..8fd73e3de 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/AddAncillaryFlowModal/index.tsx @@ -218,8 +218,12 @@ export default function AddAncillaryFlowModal({ <> - {selectedAncillary.points}{" "} - {intl.formatMessage({ id: "points" })} + {intl.formatMessage( + { id: "{value} points" }, + { + value: selectedAncillary.points, + } + )} )} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/ConfirmationStep/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/ConfirmationStep/index.tsx index c1a1fada4..87e5666e5 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/ConfirmationStep/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddAncillaryFlow/ConfirmationStep/index.tsx @@ -110,7 +110,10 @@ export default function ConfirmationStep() {
- {totalPoints} {intl.formatMessage({ id: "points" })} + {intl.formatMessage( + { id: "{value} points" }, + { value: totalPoints } + )}
)} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx index e5427a81a..97bc13c6f 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Ancillaries/AddedAncillaries/index.tsx @@ -73,7 +73,12 @@ export function AddedAncillaries({ color="baseSurfaceSubtleNormal" /> - {`${ancillary.points} ${intl.formatMessage({ id: "Points" })}`} + {intl.formatMessage( + { id: "{value} points" }, + { + value: ancillary.points, + } + )}
@@ -120,7 +125,12 @@ export function AddedAncillaries({ - {`${ancillary.points} ${intl.formatMessage({ id: "Points" })}`} + {intl.formatMessage( + { id: "{value} points" }, + { + value: ancillary.points, + } + )} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/CancelStay/Confirmation/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/CancelStay/Confirmation/index.tsx index bf6a1c379..a5fe0c871 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/CancelStay/Confirmation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/CancelStay/Confirmation/index.tsx @@ -68,7 +68,12 @@ export function CancelStayConfirmation({ >
- {intl.formatMessage({ id: "Room" })} {index + 1} + {intl.formatMessage( + { id: "Room {roomIndex}" }, + { + roomIndex: index + 1, + } + )} {roomDetail && ( <> diff --git a/apps/scandic-web/components/HotelReservation/MyStay/LinkedReservation/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/LinkedReservation/index.tsx index cb652616d..56e3e8d6a 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/LinkedReservation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/LinkedReservation/index.tsx @@ -56,11 +56,35 @@ export default function LinkedReservation({ const fromDate = dt(booking.checkInDate).locale(lang) const toDate = dt(booking.checkOutDate).locale(lang) + const adultsMsg = intl.formatMessage( + { id: "{adults, plural, one {# adult} other {# adults}}" }, + { + adults: booking.adults, + } + ) + + const childrenMsg = intl.formatMessage( + { + id: "{children, plural, one {# child} other {# children}}", + }, + { + children: booking.childrenAges.length, + } + ) + + const adultsOnlyMsg = adultsMsg + const adultsAndChildrenMsg = [adultsMsg, childrenMsg].join(", ") + return (
- {intl.formatMessage({ id: "Room" }) + " " + (index + 2)} + {intl.formatMessage( + { id: "Room {roomIndex}" }, + { + roomIndex: index + 2, + } + )}
@@ -70,19 +94,8 @@ export default function LinkedReservation({
{booking.childrenAges.length > 0 - ? intl.formatMessage( - { id: "{adults} adults, {children} children" }, - { - adults: booking.adults, - children: booking.childrenAges.length, - } - ) - : intl.formatMessage( - { id: "{adults} adults" }, - { - adults: booking.adults, - } - )} + ? adultsAndChildrenMsg + : adultsOnlyMsg}
diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/index.tsx index e2ccdf823..adb0ef530 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/index.tsx @@ -49,6 +49,7 @@ export function ReferenceCard({ booking, hotel }: ReferenceCardProps) { (acc, linkedReservation) => acc + linkedReservation.adults, 0 ) ?? 0) + const children = booking.childrenAges.length + (booking.linkedReservations?.reduce( @@ -56,6 +57,25 @@ export function ReferenceCard({ booking, hotel }: ReferenceCardProps) { 0 ) ?? 0) + const adultsMsg = intl.formatMessage( + { id: "{adults, plural, one {# adult} other {# adults}}" }, + { + adults: adults, + } + ) + + const childrenMsg = intl.formatMessage( + { + id: "{children, plural, one {# child} other {# children}}", + }, + { + children: children, + } + ) + + const adultsOnlyMsg = adultsMsg + const adultsAndChildrenMsg = [adultsMsg, childrenMsg].join(", ") + return (
@@ -83,20 +103,7 @@ export function ReferenceCard({ booking, hotel }: ReferenceCardProps) { {intl.formatMessage({ id: "Guests" })} - {children > 0 - ? intl.formatMessage( - { id: "{adults} adults, {children} children" }, - { - adults: adults, - children: children, - } - ) - : intl.formatMessage( - { id: "{adults} adults" }, - { - adults: adults, - } - )} + {children > 0 ? adultsAndChildrenMsg : adultsOnlyMsg}
diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Room/GuestDetails.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Room/GuestDetails.tsx index 3907cf9e6..cac20bf22 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Room/GuestDetails.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Room/GuestDetails.tsx @@ -158,8 +158,12 @@ export default function GuestDetails({ {isMemberBooking && ( - {intl.formatMessage({ id: "Member no." })}{" "} - {user.membership!.membershipNumber} + {intl.formatMessage( + { id: "Member no. {nr}" }, + { + nr: user.membership!.membershipNumber, + } + )} )} {guestDetails.email} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Room/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Room/index.tsx index 6c7a8f91f..a37ea5bd3 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Room/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Room/index.tsx @@ -87,6 +87,44 @@ export function Room({ booking, room, hotel, user }: RoomProps) { const fromDate = dt(booking.checkInDate).locale(lang) + const mainBedWidthValueMsg = intl.formatMessage( + { id: "{value} cm" }, + { + value: room.bedType.mainBed.widthRange.min, + } + ) + + const mainBedWidthRangeMsg = intl.formatMessage( + { + id: "{min}–{max} cm", + }, + { + min: room.bedType.mainBed.widthRange.min, + max: room.bedType.mainBed.widthRange.max, + } + ) + + const adultsMsg = intl.formatMessage( + { + id: "{adults, plural, one {# adult} other {# adults}}", + }, + { + adults: booking.adults, + } + ) + + const childrenMsg = intl.formatMessage( + { + id: "{children, plural, one {# child} other {# children}}", + }, + { + children: booking.childrenAges.length, + } + ) + + const adultsOnlyMsg = adultsMsg + const adultsAndChildrenMsg = [adultsMsg, childrenMsg].join(", ") + return (
@@ -189,19 +227,8 @@ export function Room({ booking, room, hotel, user }: RoomProps) {
{booking.childrenAges.length > 0 - ? intl.formatMessage( - { id: "{adults} adults, {children} children" }, - { - adults: booking.adults, - children: booking.childrenAges.length, - } - ) - : intl.formatMessage( - { id: "{adults} adults" }, - { - adults: booking.adults, - } - )} + ? adultsAndChildrenMsg + : adultsOnlyMsg}
@@ -232,8 +259,8 @@ export function Room({ booking, room, hotel, user }: RoomProps) { {room.bedType.mainBed.description} {room.bedType.mainBed.widthRange.min === room.bedType.mainBed.widthRange.max - ? ` (${room.bedType.mainBed.widthRange.min} ${intl.formatMessage({ id: "cm" })})` - : ` (${room.bedType.mainBed.widthRange.min} - ${room.bedType.mainBed.widthRange.max} ${intl.formatMessage({ id: "cm" })})`} + ? ` (${mainBedWidthValueMsg})` + : ` (${mainBedWidthRangeMsg})`}
diff --git a/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx b/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx index 9bdebdfaf..7882d029f 100644 --- a/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx +++ b/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx @@ -110,7 +110,12 @@ export default function PriceDetailsTable({ {rooms.length > 1 && ( - {intl.formatMessage({ id: "Room" })} {idx + 1} + {intl.formatMessage( + { id: "Room {roomIndex}" }, + { + roomIndex: idx + 1, + } + )} )} diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/BookingCodeFilter/index.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/BookingCodeFilter/index.tsx index cfcd29a7a..fe544bfc2 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/BookingCodeFilter/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/BookingCodeFilter/index.tsx @@ -43,7 +43,7 @@ export default function BookingCodeFilter() { <>