From 96d982014f9a3e43d3350fee1df9b99206421761 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Thu, 4 Apr 2024 17:41:36 +0530 Subject: [PATCH] fix: locale string changes types added --- src/CardTheme.res | 35 ++++++++++++------------ src/LocaleStrings/LocaleStringHelper.res | 22 +++++++++++++++ src/LocaleStrings/LocaleStringTypes.res | 2 ++ 3 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 src/LocaleStrings/LocaleStringHelper.res diff --git a/src/CardTheme.res b/src/CardTheme.res index c01d51857..f5e9e4d8b 100644 --- a/src/CardTheme.res +++ b/src/CardTheme.res @@ -75,24 +75,23 @@ let getLocaleObject = string => { } else { string } - switch locale { - | "en" => EnglishLocale.localeStrings - | "he" => HebrewLocale.localeStrings - | "fr" => FrenchLocale.localeStrings - | "en-GB" => EnglishGBLocale.localeStrings - | "ar" => ArabicLocale.localeStrings - | "ja" => JapaneseLocale.localeStrings - | "de" => DeutschLocale.localeStrings - | "fr-BE" => FrenchBelgiumLocale.localeStrings - | "es" => SpanishLocale.localeStrings - | "ca" => CatalanLocale.localeStrings - | "pt" => PortugueseLocale.localeStrings - | "it" => ItalianLocale.localeStrings - | "pl" => PolishLocale.localeStrings - | "nl" => DutchLocale.localeStrings - | "sv" => SwedishLocale.localeStrings - | "ru" => RussianLocale.localeStrings - | _ => EnglishLocale.localeStrings + switch locale->LocaleStringHelper.mapLocalStringToTypeLocale { + | EN => EnglishLocale.localeStrings + | HE => HebrewLocale.localeStrings + | FR => FrenchLocale.localeStrings + | EN_GB => EnglishGBLocale.localeStrings + | AR => ArabicLocale.localeStrings + | JA => JapaneseLocale.localeStrings + | DE => DeutschLocale.localeStrings + | FR_BE => FrenchBelgiumLocale.localeStrings + | ES => SpanishLocale.localeStrings + | CA => CatalanLocale.localeStrings + | PT => PortugueseLocale.localeStrings + | IT => ItalianLocale.localeStrings + | PL => PolishLocale.localeStrings + | NL => DutchLocale.localeStrings + | SV => SwedishLocale.localeStrings + | RU => RussianLocale.localeStrings } } let defaultRecoilConfig: recoilConfig = { diff --git a/src/LocaleStrings/LocaleStringHelper.res b/src/LocaleStrings/LocaleStringHelper.res new file mode 100644 index 000000000..19acaaae5 --- /dev/null +++ b/src/LocaleStrings/LocaleStringHelper.res @@ -0,0 +1,22 @@ +open LocaleStringTypes +let mapLocalStringToTypeLocale = val => { + switch val { + | "en" => EN + | "he" => HE + | "fr" => FR + | "en-GB" => EN_GB + | "ar" => AR + | "ja" => JA + | "de" => DE + | "fr-BE" => FR_BE + | "es" => ES + | "ca" => CA + | "pt" => PT + | "it" => IT + | "pl" => PL + | "nl" => NL + | "sv" => SV + | "ru" => RU + | _ => EN + } +} diff --git a/src/LocaleStrings/LocaleStringTypes.res b/src/LocaleStrings/LocaleStringTypes.res index 81148aa26..884e95285 100644 --- a/src/LocaleStrings/LocaleStringTypes.res +++ b/src/LocaleStrings/LocaleStringTypes.res @@ -1,3 +1,5 @@ +type locale = EN | HE | FR | EN_GB | AR | JA | DE | FR_BE | ES | CA | PT | IT | PL | NL | SV | RU + type localeStrings = { locale: string, cardNumberLabel: string,