From f0051f7cd1b69ee3fa3e71128c10e1c20dad74ef Mon Sep 17 00:00:00 2001 From: Angelo Reale <12191809+angeloreale@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:13:31 +0100 Subject: [PATCH] [DPCP-121] Fix Locale Parsing (#50) * ar(fix) DPCP-121: Locale Parsing * ar(fix) DPCP-121: Locale Parsing * ar(fix) DPCP-121: Locale Parsing * ar(fix) DPCP-121: Locale Parsing * ar(fix) DPCP-121: Locale Parsing * ar(fix) DPCP-121: Locale Parsing --- lib/model/decorators/hypnos-public-decorator.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/model/decorators/hypnos-public-decorator.ts b/lib/model/decorators/hypnos-public-decorator.ts index f27d44b9..7e60cd36 100644 --- a/lib/model/decorators/hypnos-public-decorator.ts +++ b/lib/model/decorators/hypnos-public-decorator.ts @@ -5,11 +5,15 @@ import type { ICard } from '@dreampipcom/oneiros'; /* private */ const decorateListing = (listing: Record, uMeta: any, locale?: string): ICard => { + const coerceStringLocale = (localeString: any) => { + const locArr = locale?.split('-') || []; + return localeString[locArr[1]] || localeString[locArr[0]]; + }; const decd: ICard = { id: `${listing.id}`, className: '', - title: `${listing?.title[locale || 'en']}`, - description: `${listing?.description[locale || 'en']}`, + title: `${coerceStringLocale(listing?.title)}`, + description: `${coerceStringLocale(listing?.description)}`, where: `${listing?.location?.name}`, latlng: `${listing?.location?.geo}`, when: `${listing?.scheduledFor}`,