From d3ce99f69311fb01302919cdb565a87507a3069e Mon Sep 17 00:00:00 2001 From: Shiva Nandan Date: Thu, 28 Mar 2024 13:49:04 +0530 Subject: [PATCH] refactor: use locale values directly --- src/CardTheme.res | 16 +++++++++++----- src/LocaleStrings/LocaleString.res | 12 ------------ 2 files changed, 11 insertions(+), 17 deletions(-) delete mode 100644 src/LocaleStrings/LocaleString.res diff --git a/src/CardTheme.res b/src/CardTheme.res index f386df2af..bf09d1209 100644 --- a/src/CardTheme.res +++ b/src/CardTheme.res @@ -70,15 +70,21 @@ type recoilConfig = { showLoader: bool, } let getLocaleObject = string => { - let val = if string == "auto" { + let locale = if string == "auto" { navigator["language"] } else { string } - LocaleString.localeStrings - ->Array.filter(item => item.locale == val) - ->Array.get(0) - ->Option.getOr(LocaleString.defaultLocale) + switch locale { + | "en" => EnglishLocale2.localeStrings + | "he" => HebrewLocale.localeStrings + | "fr" => FrenchLocale.localeStrings + | "en-GB" => EnglishGBLocale.localeStrings + | "ar" => ArabicLocale.localeStrings + | "ja" => JapaneseLocale.localeStrings + | "de" => DeutschLocale.localeStrings + | _ => EnglishLocale.localeStrings + } } let defaultRecoilConfig: recoilConfig = { config: defaultConfig, diff --git a/src/LocaleStrings/LocaleString.res b/src/LocaleStrings/LocaleString.res deleted file mode 100644 index 923f46ac3..000000000 --- a/src/LocaleStrings/LocaleString.res +++ /dev/null @@ -1,12 +0,0 @@ -let defaultLocale = EnglishLocale.localeStrings - -// type locale = {localeStrings: array} -let localeStrings: array = [ - EnglishLocale2.localeStrings, - HebrewLocale.localeStrings, - FrenchLocale.localeStrings, - EnglishGBLocale.localeStrings, - ArabicLocale.localeStrings, - JapaneseLocale.localeStrings, - DeutschLocale.localeStrings, -]