Skip to content

Commit f9ade03

Browse files
fix: use locales from shared-codebase
1 parent 1e7f2ba commit f9ade03

39 files changed

+113
-4956
lines changed

src/CardTheme.res

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ let defaultConfig = {
6868
type recoilConfig = {
6969
config: configClass,
7070
themeObj: themeClass,
71-
localeString: LocaleStringTypes.localeStrings,
72-
constantString: LocaleStringTypes.constantStrings,
71+
localeString: LocaleDataType.localeStrings,
72+
constantString: LocaleDataType.constantStrings,
7373
showLoader: bool,
7474
}
7575

76+
@val external importJSON: string => promise<LocaleDataType.localeStrings> = "import"
77+
7678
let getLocaleObject = async string => {
7779
try {
7880
let locale = if string == "auto" {
@@ -81,48 +83,62 @@ let getLocaleObject = async string => {
8183
string
8284
}
8385

84-
let promiseLocale = switch locale->LocaleStringHelper.mapLocalStringToTypeLocale {
85-
| EN => Js.import(EnglishLocale.localeStrings)
86-
| HE => Js.import(HebrewLocale.localeStrings)
87-
| FR => Js.import(FrenchLocale.localeStrings)
88-
| EN_GB => Js.import(EnglishGBLocale.localeStrings)
89-
| AR => Js.import(ArabicLocale.localeStrings)
90-
| JA => Js.import(JapaneseLocale.localeStrings)
91-
| DE => Js.import(DeutschLocale.localeStrings)
92-
| FR_BE => Js.import(FrenchBelgiumLocale.localeStrings)
93-
| ES => Js.import(SpanishLocale.localeStrings)
94-
| CA => Js.import(CatalanLocale.localeStrings)
95-
| ZH => Js.import(ChineseLocale.localeStrings)
96-
| PT => Js.import(PortugueseLocale.localeStrings)
97-
| IT => Js.import(ItalianLocale.localeStrings)
98-
| PL => Js.import(PolishLocale.localeStrings)
99-
| NL => Js.import(DutchLocale.localeStrings)
100-
| SV => Js.import(SwedishLocale.localeStrings)
101-
| RU => Js.import(RussianLocale.localeStrings)
102-
| ZH_HANT => Js.import(TraditionalChineseLocale.localeStrings)
103-
}
104-
86+
let promiseLocale = switch locale->LocaleDataType.localeStringToType {
87+
| Some(En) => importJSON("../shared-code/assets/v2/jsons/locales/en.json")
88+
| Some(He) => importJSON("../shared-code/assets/v2/jsons/locales/he.json")
89+
| Some(Fr) => importJSON("../shared-code/assets/v2/jsons/locales/fr.json")
90+
| Some(En_GB) => importJSON("../shared-code/assets/v2/jsons/locales/en-GB.json")
91+
| Some(Ar) => importJSON("../shared-code/assets/v2/jsons/locales/ar.json")
92+
| Some(Ja) => importJSON("../shared-code/assets/v2/jsons/locales/ja.json")
93+
| Some(De) => importJSON("../shared-code/assets/v2/jsons/locales/de.json")
94+
| Some(Fr_BE) => importJSON("../shared-code/assets/v2/jsons/locales/fr-BE.json")
95+
| Some(Es) => importJSON("../shared-code/assets/v2/jsons/locales/es.json")
96+
| Some(Ca) => importJSON("../shared-code/assets/v2/jsons/locales/ca.json")
97+
// | Some(Zh) => importJSON("../shared-code/assets/v2/jsons/locales/zh.json") // Pending support
98+
| Some(Pt) => importJSON("../shared-code/assets/v2/jsons/locales/pt.json")
99+
| Some(It) => importJSON("../shared-code/assets/v2/jsons/locales/it.json")
100+
| Some(Pl) => importJSON("../shared-code/assets/v2/jsons/locales/pl.json")
101+
| Some(Nl) => importJSON("../shared-code/assets/v2/jsons/locales/nl.json")
102+
| Some(NI_BE) => importJSON("../shared-code/assets/v2/jsons/locales/nl-BE.json") // to check
103+
| Some(Sv) => importJSON("../shared-code/assets/v2/jsons/locales/sv.json")
104+
| Some(Ru) => importJSON("../shared-code/assets/v2/jsons/locales/ru.json")
105+
// | Some(Zh_HANT) => importJSON("../shared-code/assets/v2/jsons/locales/zh-Hant.json") // Pending support
106+
| Some(Lt) => importJSON("../shared-code/assets/v2/jsons/locales/lt.json")
107+
| Some(Cs) => importJSON("../shared-code/assets/v2/jsons/locales/cs.json")
108+
| Some(Sk) => importJSON("../shared-code/assets/v2/jsons/locales/sk.json")
109+
| Some(Ls) => importJSON("../shared-code/assets/v2/jsons/locales/is.json") // to check
110+
| Some(Cy) => importJSON("../shared-code/assets/v2/jsons/locales/cy.json")
111+
| Some(El) => importJSON("../shared-code/assets/v2/jsons/locales/el.json")
112+
| Some(Et) => importJSON("../shared-code/assets/v2/jsons/locales/et.json")
113+
| Some(Fi) => importJSON("../shared-code/assets/v2/jsons/locales/fi.json")
114+
| Some(Nb) => importJSON("../shared-code/assets/v2/jsons/locales/no.json") // to check
115+
| Some(Bs) => importJSON("../shared-code/assets/v2/jsons/locales/bs.json")
116+
| Some(Da) => importJSON("../shared-code/assets/v2/jsons/locales/da.json")
117+
| Some(Ms) => importJSON("../shared-code/assets/v2/jsons/locales/ms.json")
118+
| Some(Tr_CY) => importJSON("../shared-code/assets/v2/jsons/locales/tr-CY.json")
119+
| None => importJSON("../shared-code/assets/v2/jsons/locales/en.json")
120+
}
105121
let awaitedLocaleValue = await promiseLocale
106122
awaitedLocaleValue
107123
} catch {
108-
| _ => EnglishLocale.localeStrings
124+
| _ => LocaleDataType.defaultLocale
109125
}
110126
}
111127

112128
let getConstantStringsObject = async () => {
113129
try {
114-
let promiseConstantStrings = Js.import(ConstantStrings.constantStrings)
130+
let promiseConstantStrings = Js.import(LocaleDataType.defaultConstantStrings)
115131
await promiseConstantStrings
116132
} catch {
117-
| _ => ConstantStrings.constantStrings
133+
| _ => LocaleDataType.defaultConstantStrings
118134
}
119135
}
120136

121137
let defaultRecoilConfig: recoilConfig = {
122138
config: defaultConfig,
123139
themeObj: defaultConfig.appearance.variables,
124-
localeString: EnglishLocale.localeStrings,
125-
constantString: ConstantStrings.constantStrings,
140+
localeString: LocaleDataType.defaultLocale,
141+
constantString: LocaleDataType.defaultConstantStrings,
126142
showLoader: false,
127143
}
128144

src/CardUtils.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,10 +736,10 @@ let getCardBrandFromStates = (cardBrand, cardScheme, showPaymentMethodsScreen) =
736736
!showPaymentMethodsScreen ? cardScheme : cardBrand
737737
}
738738

739-
let getCardBrandInvalidError = (~cardBrand, ~localeString: LocaleStringTypes.localeStrings) => {
739+
let getCardBrandInvalidError = (~cardBrand, ~localeString: LocaleDataType.localeStrings) => {
740740
switch cardBrand {
741741
| "" => localeString.enterValidCardNumberErrorText
742-
| cardBrandValue => localeString.cardBrandConfiguredErrorText(cardBrandValue)
742+
| cardBrandValue => `${localeString.cardBrandConfiguredErrorTextPart1}${cardBrandValue}${localeString.cardBrandConfiguredErrorTextPart2}`
743743
}
744744
}
745745

src/Components/BillingNamePaymentInput.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ let make = (~customFieldName=None, ~requiredFields as optionalRequiredFields=?)
3939
if billingName.value == "" {
4040
setBillingName(prev => {
4141
...prev,
42-
errorString: fieldName->localeString.nameEmptyText,
42+
errorString: `${localeString.nameEmptyTextPart1}${fieldName}`,
4343
})
4444
} else {
4545
switch optionalRequiredFields {
4646
| Some(requiredFields) =>
4747
if !DynamicFieldsUtils.checkIfNameIsValid(requiredFields, BillingName, billingName) {
4848
setBillingName(prev => {
4949
...prev,
50-
errorString: fieldName->localeString.completeNameEmptyText,
50+
errorString: `${localeString.completeNameEmptyTextPart1}${fieldName}`,
5151
})
5252
}
5353
| None => ()

src/Components/FullNamePaymentInput.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let make = (~customFieldName=None, ~optionalRequiredFields=None) => {
3737
if fullName.value == "" {
3838
setFullName(prev => {
3939
...prev,
40-
errorString: fieldName->localeString.nameEmptyText,
40+
errorString: `${localeString.nameEmptyTextPart1}${fieldName}`,
4141
})
4242
} else if !(fullName.isValid->Option.getOr(false)) {
4343
setFullName(prev => {
@@ -50,7 +50,7 @@ let make = (~customFieldName=None, ~optionalRequiredFields=None) => {
5050
if !DynamicFieldsUtils.checkIfNameIsValid(requiredFields, FullName, fullName) {
5151
setFullName(prev => {
5252
...prev,
53-
errorString: fieldName->localeString.completeNameEmptyText,
53+
errorString: `${localeString.completeNameEmptyTextPart1}${fieldName}`,
5454
})
5555
}
5656
| None => ()

src/Components/GiftCards.res

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ let make = (~giftCardOptions) => {
9999
let giftCardPaymentInfoMessage =
100100
remainingAmount === 0.0
101101
? ` ${localeString.giftCardPaymentCompleteMessage}`
102-
: ` ${localeString.giftCardPaymentRemainingMessage(
103-
remainingCurrency,
104-
remainingAmount->Float.toString,
105-
)}`
102+
: ` ${localeString.giftCardPaymentRemainingMessagePart1}${remainingCurrency} ${remainingAmount->Float.toString}${localeString.giftCardPaymentRemainingMessagePart2}`
106103

107104
let getPrimaryGiftCardData = (~appliedGiftCards: array<GiftCardTypes.appliedGiftCard>) =>
108105
appliedGiftCards->Array.get(0)->Option.getOr(GiftCardTypes.defaultAppliedGiftCard)

src/Components/SaveDetailsCheckbox.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ let make = (~isChecked, ~setIsChecked) => {
7070
} else if customMessageForCardTerms->String.length > 0 {
7171
customMessageForCardTerms
7272
} else {
73-
localeString.cardTerms(business.name)
73+
localeString.cardTermsPart1 ++ business.name ++ localeString.cardTermsPart2
7474
}
7575

7676
<div

src/Components/SurchargeUtils.res

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ type oneClickWallets = {
22
paymentMethodType: string,
33
displayName: string,
44
}
5-
let oneClickWallets = (~localeString: LocaleStringTypes.localeStrings) => [
5+
let oneClickWallets = (~localeString: LocaleDataType.localeStrings) => [
66
{
77
paymentMethodType: "apple_pay",
88
displayName: localeString.payment_methods_apple_pay,
@@ -80,15 +80,15 @@ let useMessageGetter = () => {
8080
let surchargeValue = surchargeDetails.displayTotalSurchargeAmount->Float.toString
8181

8282
if showShortSurchargeMessage {
83-
Some(localeString.shortSurchargeMessage(currency, surchargeValue))
83+
Some(React.string(`${localeString.shortSurchargeMessagePart1}${surchargeValue}${localeString.shortSurchargeMessagePart2}`))
8484
} else {
8585
let message = if paymentMethod === "card" {
86-
localeString.surchargeMsgAmountForCard(currency, surchargeValue)
86+
`${localeString.surchargeMsgAmountForCardPart1}${currency} ${surchargeValue}${localeString.surchargeMsgAmountForCardPart2}`
8787
} else {
88-
localeString.surchargeMsgAmount(currency, surchargeValue)
88+
`${localeString.surchargeMsgAmountPart1}${currency} ${surchargeValue}${localeString.surchargeMsgAmountPart2}`
8989
}
9090

91-
Some(message)
91+
Some(React.string(message))
9292
}
9393
}
9494
getMessage
@@ -112,7 +112,7 @@ let useOneClickWalletsMessageGetter = (~paymentMethodListValue) => {
112112
myMsg
113113
} else if index === oneClickWalletsArr->Array.length - 1 {
114114
<>
115-
{React.string(`${Utils.nbsp}${localeString.\"and"}${Utils.nbsp}`)}
115+
{React.string(`${Utils.nbsp}${localeString.and_}${Utils.nbsp}`)}
116116
{myMsg}
117117
</>
118118
} else {

src/Components/Terms.res

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ let make = (~styles: JsxDOMStyle.t={}, ~paymentMethod, ~paymentMethodType) => {
99
let cardTermsValue =
1010
customMessageForCardTerms != ""
1111
? customMessageForCardTerms
12-
: localeString.cardTerms(business.name)
12+
: `${localeString.cardTermsPart1}${business.name}${localeString.cardTermsPart2}`
1313

1414
let paymentMethodTermsDefaults = switch paymentMethod {
1515
| "bank_debit" =>
1616
switch paymentMethodType {
17-
| "sepa" => (localeString.sepaDebitTerms(business.name), terms.sepaDebit)
17+
| "sepa" => (
18+
`${localeString.sepaDebitTermsPart1}${business.name}${localeString.sepaDebitTermsPart2}${business.name}${localeString.sepaDebitTermsPart3}`,
19+
terms.sepaDebit,
20+
)
1821
| "becs" => (localeString.becsDebitTerms, terms.auBecsDebit)
19-
| "ach" => (localeString.achBankDebitTerms(business.name), terms.usBankAccount)
22+
| "ach" => (
23+
`${localeString.achBankDebitTermsPart1}${business.name}${localeString.achBankDebitTermsPart2}`,
24+
terms.usBankAccount,
25+
)
2026
| _ => ("", Never)
2127
}
2228
| "card" =>

src/FormViewJourney.res

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ let make = (
321321
| Card => localeString.formHeaderEnterCardText
322322
| BankRedirect
323323
| BankTransfer =>
324-
key->localeString.formHeaderBankText
325-
| Wallet => key->localeString.formHeaderWalletText
324+
`${localeString.formHeaderBankTextPart1}${key}${localeString.formHeaderBankTextPart2}`
325+
| Wallet =>
326+
`${localeString.formHeaderWalletTextPart1}${key}${localeString.formHeaderWalletTextPart2}`
326327
},
327328
true,
328329
)}
@@ -343,9 +344,7 @@ let make = (
343344
<img src={"merchantLogo"} alt="" className="h-6 w-auto" />
344345
<div className="ml-1.5">
345346
{React.string(
346-
pmt
347-
->getPaymentMethodTypeLabel
348-
->localeString.formHeaderReviewTabLayoutText,
347+
`${localeString.formHeaderReviewTabLayoutTextPart1}${pmt->getPaymentMethodTypeLabel}${localeString.formHeaderReviewTabLayoutTextPart2}`,
349348
)}
350349
</div>
351350
</div>
@@ -394,10 +393,7 @@ let make = (
394393
className="flex flex-row items-center min-w-full my-5 px-2.5 py-1.5 text-xs border border-solid border-blue-200 rounded bg-blue-50">
395394
<img src={"merchantLogo"} alt="" className="h-3 w-auto mr-1.5" />
396395
{React.string(
397-
pm
398-
->getPaymentMethodLabel
399-
->String.toLowerCase
400-
->localeString.formFundsCreditInfoText,
396+
`${localeString.formFundsCreditInfoTextPart1}${pm->getPaymentMethodLabel->String.toLowerCase}${localeString.formFundsCreditInfoTextPart2}`,
401397
)}
402398
</div>
403399
<div className="flex my-5 text-lg font-semibold w-full">

src/FormViewTabs.res

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ let make = (
242242
| Card(_) => localeString.formHeaderEnterCardText
243243
| BankRedirect(_)
244244
| BankTransfer(_) =>
245-
key->localeString.formHeaderBankText
246-
| Wallet(_) => key->localeString.formHeaderWalletText
245+
`${localeString.formHeaderBankTextPart1}${key}${localeString.formHeaderBankTextPart2}`
246+
| Wallet(_) =>
247+
`${localeString.formHeaderWalletTextPart1}${key}${localeString.formHeaderWalletTextPart2}`
247248
}->React.string}
248249
</div>
249250
{payoutDynamicFields.payoutMethodData->renderPayoutMethodForm->React.array}
@@ -277,9 +278,7 @@ let make = (
277278
<img src={"merchantLogo"} alt="" className="h-6 w-auto" />
278279
<div className="ml-1.5">
279280
{React.string(
280-
pmt
281-
->getPaymentMethodTypeLabel
282-
->localeString.formHeaderReviewTabLayoutText,
281+
`${localeString.formHeaderReviewTabLayoutTextPart1}${pmt->getPaymentMethodTypeLabel}${localeString.formHeaderReviewTabLayoutTextPart2}`,
283282
)}
284283
</div>
285284
</div>
@@ -328,10 +327,7 @@ let make = (
328327
className="flex flex-row items-center min-w-full my-5 px-2.5 py-1.5 text-xs border border-solid border-blue-200 rounded bg-blue-50">
329328
<img src={"merchantLogo"} alt="" className="h-3 w-auto mr-1.5" />
330329
{React.string(
331-
pm
332-
->getPaymentMethodLabel
333-
->String.toLowerCase
334-
->localeString.formFundsCreditInfoText,
330+
`${localeString.formFundsCreditInfoTextPart1}${pm->getPaymentMethodLabel->String.toLowerCase}${localeString.formFundsCreditInfoTextPart2}`,
335331
)}
336332
</div>
337333
<div className="flex my-5 text-lg font-semibold w-full">

0 commit comments

Comments
 (0)