@incodetech/web 2.4.0 → 2.4.1-agentic.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.txt +1 -4
- package/dist/{GeolocationPermissionDenied-NCe8TBk4.js → GeolocationPermissionDenied-ClGp0a23.js} +13 -8
- package/dist/ae-signature/ae-signature.es.js +4 -4
- package/dist/{af-ZA-BbU0OdlG.js → af-ZA-BKpmmWDe.js} +165 -869
- package/dist/{ageVerification-B5ownHdO.js → ageVerification-CtuJDuRV.js} +11 -8
- package/dist/{am-BuvQtV50.js → am-CW_ro5Ws.js} +165 -869
- package/dist/antifraud/antifraud.es.js +5 -4
- package/dist/applyStudioConfig-C6-Ak0q6.js +127 -0
- package/dist/{ar-AE-Bdk7NfI2.js → ar-AE-D9h8UMbm.js} +165 -869
- package/dist/{ar-Ba-wMBXP.js → ar-B5ToweVl.js} +166 -870
- package/dist/{ar-EG-C9FVwsEB.js → ar-EG-DQqE9B26.js} +165 -869
- package/dist/assertClassBrand-DJr5K93j.js +17 -0
- package/dist/asset-Ctwd_20H.js +355 -0
- package/dist/authentication/authentication.es.js +7 -5
- package/dist/{autoFocusTitle-BQltp_Nn.js → autoFocusTitle-CzaCWWW5.js} +2 -2
- package/dist/{az-DHRJfgCV.js → az-DAZq-CQj.js} +165 -869
- package/dist/{back-horizontal-hint-BztyPanp.js → back-horizontal-hint-qzSaNkEU.js} +1 -1
- package/dist/{back-vertical-hint-BSzA4QbJ.js → back-vertical-hint-DkYLOege.js} +1 -1
- package/dist/base.css +1 -1
- package/dist/{baseTutorial-CL2A9XLh.js → baseTutorial-CF6WiVYt.js} +10 -7
- package/dist/{bn-BfE2MHPG.js → bn-DRTyq2Y9.js} +165 -869
- package/dist/{bottomSheet-DU4SrMOH.js → bottomSheet-DylE2INk.js} +3 -3
- package/dist/{bs-Ck9dCVYh.js → bs-B8q0B86-.js} +164 -868
- package/dist/{ca-yJUG5zqw.js → ca-DvsHXRB-.js} +164 -868
- package/dist/cameraOverlay-DNf0PEF4.js +2 -0
- package/dist/{cameraOverlayHeader-Bp7NCrl9.js → cameraOverlayHeader-CuVGnyXI.js} +9 -8
- package/dist/{cameraView-CLlWARBI.js → cameraView-D9ZxLKtA.js} +13 -14
- package/dist/capture-0jMDSGCE.js +762 -0
- package/dist/{tutorial-Bwt7rxfr.js → capture-BlGlXoTx.js} +212 -51
- package/dist/capture-DKBA5j5A.js +3 -0
- package/dist/capture-D_Dwrj1F.js +2 -0
- package/dist/captureButtonIcon-A9kn2E_m.js +1 -0
- package/dist/captureFocusContext-9789qOe3.js +729 -0
- package/dist/captureFooter-B6WUFQCV.js +47 -0
- package/dist/{ceb-oov4R9JM.js → ceb-pvlomXHV.js} +165 -869
- package/dist/certificate-issuance/certificate-issuance.es.js +23 -13
- package/dist/{check-icon-BpjpKqhJ.js → check-icon-BdHltEK6.js} +1 -1
- package/dist/{checkbox-DbYUeTao.js → checkbox-BwUQ0Rs9.js} +4 -4
- package/dist/chooser-CmG71-lh.js +1589 -0
- package/dist/connectionError-DexRpKWs.js +90 -0
- package/dist/consent/consent.es.js +19 -14
- package/dist/consent/styles.css +1 -1
- package/dist/consent/styles.css.js +1 -1
- package/dist/{countryFlag-2Vj85OIZ.js → countryFlag-CQMfCnE9.js} +1 -1
- package/dist/{countrySelector-El6_zLMs.js → countrySelector-C0OEKMqL.js} +6 -5
- package/dist/cross-document-data-match/cross-document-data-match.es.js +5 -4
- package/dist/{cs-CZ-B9jWzmE_.js → cs-CZ-GgvnJLMj.js} +164 -868
- package/dist/{cs-ovOFxGB0.js → cs-DB5PLEdt.js} +164 -868
- package/dist/curp-validation/curp-validation.es.js +34 -19
- package/dist/curp-validation/styles.css +1 -1
- package/dist/curp-validation/styles.css.js +1 -1
- package/dist/{customFields-BlYfgYje.js → customFields-DQgRumW0.js} +17 -12
- package/dist/{customWatchlist-BsBTzCCN.js → customWatchlist-BbC0fA-6.js} +8 -7
- package/dist/{da-DK-C0l5MGWM.js → da-DK-ZhpcfE_F.js} +164 -868
- package/dist/{dashboardTheme-MVQerNVn.js → dashboardTheme-DtXsx9IK.js} +22 -23
- package/dist/{dateInputComposed-DXCc1HRe.js → dateInputComposed-1IcnucPq.js} +5 -5
- package/dist/dateInputComposed-BFlCk-sg.js +1 -0
- package/dist/{de-B0IRPjwJ.js → de-DEBjzaow.js} +164 -868
- package/dist/{denied-wXsbFjy_.js → denied-CwdVWAUw.js} +12 -9
- package/dist/devWarn-CW20j1Qd.js +9 -0
- package/dist/deviceWallet-CMjguFJO.js +37 -0
- package/dist/{digitalIdRedirect-CF7zG3wS.js → digitalIdRedirect-MNty16-5.js} +4 -4
- package/dist/{digitalIdUpload-CbPm090z.js → digitalIdUpload-CUzTaoaI.js} +39 -15
- package/dist/document-capture/document-capture.es.js +1 -1
- package/dist/document-capture/styles.css +1 -1
- package/dist/document-capture/styles.css.js +1 -1
- package/dist/{documentCapture-CgpHXm_8.js → documentCapture-BUMyJ8vw.js} +115 -44
- package/dist/documentCapture-rECLkwpi.js +2 -0
- package/dist/dropdownComposed-C9sLQE6i.js +1 -0
- package/dist/{dropdownComposed-qb9GgX5X.js → dropdownComposed-x3ewHxbT.js} +4 -4
- package/dist/dynamic-forms/dynamic-forms.es.js +20 -15
- package/dist/ekyb/ekyb.es.js +1 -1
- package/dist/ekyb/styles.css +1 -1
- package/dist/ekyb/styles.css.js +1 -1
- package/dist/ekybModule-B5IEiSyi.js +2 -0
- package/dist/{ekybModule-BgZIkVVl.js → ekybModule-C5hEBLMs.js} +27 -23
- package/dist/ekyc/ekyc.es.js +1 -1
- package/dist/ekyc/styles.css +1 -1
- package/dist/ekyc/styles.css.js +1 -1
- package/dist/ekycModule-B7OFnP3H.js +2 -0
- package/dist/{ekycModule-DEVrRrnH.js → ekycModule-TVKk0qdS.js} +71 -44
- package/dist/{el-Do7wYurZ.js → el-Dplr_D5N.js} +164 -868
- package/dist/{el-GR-BZEKLkvc.js → el-GR-IZ4reOR7.js} +164 -868
- package/dist/electronic-signature/electronic-signature.es.js +1 -1
- package/dist/{electronic-signature-DE6FJfvu.js → electronic-signature-BMda_cf3.js} +49 -34
- package/dist/email/email.es.js +15 -11
- package/dist/{emailInput-Cp77LavN.js → emailInput-BI8gWC0D.js} +4 -4
- package/dist/{en-DG-Cvwm0nfj.js → en-DG-C6tsWvHi.js} +165 -869
- package/dist/{en-CJ6l68pH.js → en-Db1L_u7B.js} +165 -869
- package/dist/{errorContent-YeJNVb1U.js → errorContent-pPAgyy2i.js} +10 -7
- package/dist/es-419-DxKrJq7W.js +5 -0
- package/dist/{es-rayGAvsH.js → es-C5unKsaF.js} +164 -868
- package/dist/{es-ES-B8h3jMgN.js → es-ES-sHbsufzT.js} +164 -868
- package/dist/{es-MX-DA__jQOC.js → es-MX-Cd_DCR0A.js} +164 -868
- package/dist/{et-DvX7tm-R.js → et-BoGq2cx8.js} +165 -869
- package/dist/{expiredId-CsKNCK5M.js → expiredId-DWjw94rT.js} +12 -8
- package/dist/extensibility.es.js +100 -55
- package/dist/{fa-IR-DfrzWcH0.js → fa-IR-DuUxGXrf.js} +165 -869
- package/dist/face-match/face-match.es.js +1 -1
- package/dist/face-match/styles.css +1 -1
- package/dist/face-match/styles.css.js +1 -1
- package/dist/faceMatch-B2aMz3X2.js +2 -0
- package/dist/{faceMatch-Bqspq0cw.js → faceMatch-DV7NxYu_.js} +15 -20
- package/dist/{fi-FI-CcFDkeiE.js → fi-FI-DMOBNTjA.js} +164 -868
- package/dist/field-comparison/field-comparison.es.js +1 -1
- package/dist/fieldComparison-BY2XXsp3.js +2 -0
- package/dist/{fieldComparison-CmQN2MEj.js → fieldComparison-CFLU1h6n.js} +15 -11
- package/dist/{fieldLabelHint-CxjArYkQ.js → fieldLabelHint-CjrLxBaj.js} +3 -3
- package/dist/{finalSuccessScreen-1Ea3wZWM.js → finalSuccessScreen-C50L96j9.js} +20 -16
- package/dist/fiscal-qr/fiscal-qr.es.js +24 -18
- package/dist/flipAnimation-8x-qdtF_.js +33 -0
- package/dist/flipCapturedCardEligibility-DLr9F2g2.js +210 -0
- package/dist/flow/flow.es.js +209 -186
- package/dist/flow/shell/styles.css +1 -1
- package/dist/flow/shell/styles.css.js +1 -1
- package/dist/flow/styles.css +1 -1
- package/dist/{formField-DoXWcoL9.js → formField-CfQKYeGF.js} +19 -11
- package/dist/{fr-CA-CeL7RQc-.js → fr-CA-DZ8jlsp3.js} +164 -868
- package/dist/{fr-DtdqfaF8.js → fr-DSR-AP0e.js} +164 -868
- package/dist/{front-horizontal-hint-DEHmtcdg.js → front-horizontal-hint-DOphQZg2.js} +1 -1
- package/dist/{front-vertical-hint-Cb1NO-xT.js → front-vertical-hint-S6PcS9_m.js} +1 -1
- package/dist/geolocation/geolocation.es.js +15 -12
- package/dist/government-validation/government-validation.es.js +7 -6
- package/dist/{he-CPeNHo0I.js → he-N5dfJeyd.js} +165 -869
- package/dist/helpButtonConfig-CjbrBQaV.js +24 -0
- package/dist/{hi-DIbkmie6.js → hi-JR6K9zbd.js} +165 -869
- package/dist/{hmn-CscGik4W.js → hmn-j2YA7FxW.js} +165 -869
- package/dist/{homeScreen-C0j_8KKD.js → homeScreen-C3pPw52y.js} +24 -13
- package/dist/{incodeComponent-CMBg2gpq.js → hooks-BFP0WaJM.js} +192 -262
- package/dist/{hr-DWUsAZnf.js → hr-8cOdwB0t.js} +164 -868
- package/dist/{ht-DgaboG3c.js → ht-DDNL4C__.js} +165 -869
- package/dist/{hu-Lz2qVC3S.js → hu-CynQQUFQ.js} +166 -870
- package/dist/i18n-Dp014ljG.js +942 -0
- package/dist/{icons-OQDvn5r2.js → icons-c-hFaG4L.js} +153 -56
- package/dist/id/id.es.js +101 -197
- package/dist/id/styles.css +1 -1
- package/dist/id/styles.css.js +1 -1
- package/dist/{id-back-of-card-C7Au2tqk.js → id-back-of-card-Bk6ZQUE9.js} +1 -1
- package/dist/{id-back-of-card-vertical-CtQBFw8w.js → id-back-of-card-vertical-BZo00s50.js} +1 -1
- package/dist/{id-front-of-card-BmHL_keG.js → id-front-of-card-BJ96se7u.js} +1 -1
- package/dist/{id-front-of-card-vertical-DkNUn2Vx.js → id-front-of-card-vertical-DSfJB0lX.js} +1 -1
- package/dist/{id-C5eOEjgu.js → id-o_Yg0n8W.js} +165 -869
- package/dist/id-selfie-flow/id-selfie-flow.es.js +12 -11
- package/dist/id-selfie-flow/styles.css +1 -1
- package/dist/id-verification/id-verification.es.js +6 -5
- package/dist/idFlipTransition-DXdtXYza.js +158 -0
- package/dist/{idOcr-C-kHrU_d.js → idOcr-CjqfkRJ7.js} +18 -14
- package/dist/identity-reuse/identity-reuse.es.js +28 -18
- package/dist/incodeComponent-DtKh-UUm.js +237 -0
- package/dist/incodeModule-DCHXAeYU.js +41 -0
- package/dist/index.es.js +5 -3
- package/dist/{inputComposed-CR1IW-mQ.js → inputComposed-CmVsaHOa.js} +4 -4
- package/dist/inputComposed-DvGrso7g.js +1 -0
- package/dist/{it-CQGuLrxZ.js → it-BXevrtHn.js} +165 -869
- package/dist/{ja-CBD-jOkP.js → ja-DiTXnTx-.js} +165 -869
- package/dist/{ja-JP-Dgbzh2aL.js → ja-JP-D1IRWR-p.js} +166 -870
- package/dist/{jv-C-E67yDR.js → jv-Us70GzGp.js} +164 -868
- package/dist/{ka-CcCqDmzw.js → ka-BSsWQ4yU.js} +165 -869
- package/dist/{kk-B_5WgCfa.js → kk-D5R6r4H7.js} +164 -868
- package/dist/{km-CucJh4em.js → km-CCCb2Rnt.js} +171 -875
- package/dist/{ko-KP-BSjl3hdX.js → ko-KP-JF4khv1Y.js} +165 -869
- package/dist/{ko-BEd2Jz4C.js → ko-kQioCg2w.js} +165 -869
- package/dist/{ky-Bb9MfmYr.js → ky-CLOemVjC.js} +164 -868
- package/dist/kyb-checks/kyb-checks.es.js +2 -0
- package/dist/kyb-checks/styles.css +2 -0
- package/dist/kyb-checks/styles.css.js +1 -0
- package/dist/kybChecksModule-C6Y9Hxpr.js +329 -0
- package/dist/kybChecksModule-r3MIpFhS.js +2 -0
- package/dist/{lo-CD_Ehkf5.js → lo-tzHUt1CQ.js} +165 -869
- package/dist/{lt-DHkwvJ8e.js → lt-B2ZI-Cgu.js} +165 -869
- package/dist/{lv-CPuPO_jU.js → lv-BJnxtSYw.js} +165 -869
- package/dist/{mandatoryConsent-BHMWyBUp.js → mandatoryConsent-BiQuEZRu.js} +23 -16
- package/dist/{manualCaptureButton-D_tGP6tv.js → manualCaptureButton-BRSmPTeR.js} +8 -7
- package/dist/{manualCaptureButton-D5XP3Oaf.js → manualCaptureButton-Dw0MMSkc.js} +17 -12
- package/dist/{mk-DO85nJp4.js → mk-Cj7Iw2Q4.js} +165 -869
- package/dist/{mn-D5fhne6X.js → mn-CA_rNxtz.js} +164 -868
- package/dist/{ms-D_FFGDor.js → ms-BydA1Zjz.js} +164 -868
- package/dist/{my-D1JKF20F.js → my-gFKufKaG.js} +165 -869
- package/dist/{nb-NO-oEMuavpl.js → nb-NO-CDsGQbOZ.js} +164 -868
- package/dist/{ne-Ds3QEMQ4.js → ne-Cyfi0vFI.js} +165 -869
- package/dist/{nl-DGyLucC1.js → nl-e1gbmAFO.js} +165 -869
- package/dist/{numberedStep-CvbL3ht2.js → numberedStep-CeN77hnQ.js} +1 -1
- package/dist/{optionAccessibleLabel-SwDCMYKc.js → optionAccessibleLabel-BTUieMxH.js} +8 -7
- package/dist/{otpInput-DIUf37GR.js → otpInput-D3L3QhnR.js} +24 -17
- package/dist/{page-BGUJaLaG.js → page-U6jZ7BBI.js} +85 -58
- package/dist/{incode-logo-BBYHyycP.js → pageUiConfig-Qf6ItVv9.js} +28 -4
- package/dist/{passport-horizontal-hint-DgNc6F0-.js → passport-horizontal-hint-Ddsh6fUS.js} +1 -1
- package/dist/{passport-vertical-hint-B-toVsfT.js → passport-vertical-hint-Dukxq6-T.js} +1 -1
- package/dist/{passwordInputComposed-Cd-3kyua.js → passwordInputComposed-CW_1DcB8.js} +5 -5
- package/dist/{pdf-BKHLi5Ac.js → pdf-Bd5QplFS.js} +2 -17
- package/dist/{pdfViewer-EDgSzrdc.js → pdfViewer-BrqSEtbr.js} +11 -14
- package/dist/pdfViewer-rDnnHzmw.js +2 -0
- package/dist/{permissions-Vh-QG2Tj.js → permissions-KUDhffd9.js} +36 -23
- package/dist/phone/phone.es.js +16 -12
- package/dist/{phoneInputComposed-wZaDiedP.js → phoneInputComposed-DlJMTavK.js} +49 -12
- package/dist/{pl-nEtI_VZQ.js → pl-BSMcCWS-.js} +164 -868
- package/dist/preloadableLazy-C8_OYaTC.js +37 -0
- package/dist/{processing-SzW6Mfrg.js → processing-B5EH7yNg.js} +2 -2
- package/dist/{progressBar-KEnpi8uj.js → progressBar-CSpS29pV.js} +2 -2
- package/dist/{pt-EmaaUJGm.js → pt-BNFC2quK.js} +165 -869
- package/dist/{pt-BR-BkLAWIbx.js → pt-BR-bH8DC2gH.js} +165 -869
- package/dist/{pt-PT-Py_4_Z05.js → pt-PT-B8PXmgwU.js} +165 -869
- package/dist/qe-signature/qe-signature.es.js +4 -4
- package/dist/{radioGroupComposed-CRr_78He.js → radioGroupComposed-CW8ElYSR.js} +4 -4
- package/dist/radioGroupComposed-flIYNffL.js +1 -0
- package/dist/realtimeFeedbackConfig-tBX94SOm.js +16 -0
- package/dist/redirect-to-mobile/redirect-to-mobile.es.js +51 -50
- package/dist/redirect-to-mobile/styles.css +1 -1
- package/dist/redirect-to-mobile/styles.css.js +1 -1
- package/dist/{registerIncodeElement-D_cn4dSI.js → registerIncodeElement-oiLvm6xq.js} +1 -1
- package/dist/{reload-icon-elAFo9-k.js → reload-icon-FD2e9Wet.js} +1 -1
- package/dist/{resendTimer-EhLnxeID.js → resendTimer-D1H3gwkI.js} +2 -2
- package/dist/richText-sUdTiRDE.js +1761 -0
- package/dist/{ro-BKmZhZl1.js → ro-DnN8QNYa.js} +165 -869
- package/dist/{ru-BYQKvZtn.js → ru-DAwUFXHq.js} +165 -869
- package/dist/{ru-RU-BdhCs3uF.js → ru-RU-Coxt0VCU.js} +164 -868
- package/dist/{sanitizeSvg-BC-qLUgS.js → sanitizeSvg-OdNh1mqY.js} +1 -1
- package/dist/selfie/selfie.es.js +36 -14
- package/dist/selfie/styles.css +1 -1
- package/dist/selfie/styles.css.js +1 -1
- package/dist/signature/signature.es.js +18 -13
- package/dist/{sk-CZipa19k.js → sk-AB8sSlNw.js} +166 -870
- package/dist/{sl-_sx3gvEv.js → sl-6Dfzfi7s.js} +165 -869
- package/dist/{smsTabContent-DHuEgl3E.js → smsTabContent-CBEKgzFv.js} +32 -23
- package/dist/{so-D3T7YyfC.js → so-X5BdrDvV.js} +165 -869
- package/dist/spacer-Jaru_3sb.js +82 -0
- package/dist/spinner-51btbot0.js +407 -0
- package/dist/{sr-D0lglPAd.js → sr-JHjMcbGs.js} +164 -868
- package/dist/{sr-Latn-Dy2rgSEv.js → sr-Latn-DgT7eTG2.js} +171 -875
- package/dist/sr-YU-BBhB_G63.js +5 -0
- package/dist/{sv-SE-VsDd4VP5.js → sv-SE-CvX8mC8T.js} +164 -868
- package/dist/{sw-D2VfTj6a.js → sw-CN0TdnY4.js} +165 -869
- package/dist/{th-BzmKSnbD.js → th-BmFntKib.js} +165 -869
- package/dist/{th-TH-BU_NqN97.js → th-TH-CWr4z3JK.js} +165 -869
- package/dist/themes/dark.css +1 -1
- package/dist/themes/light.css +1 -1
- package/dist/{tl-PH-BJJNA9rs.js → tl-PH-BRIbtBRN.js} +165 -869
- package/dist/{tl-GXkKKnzb.js → tl-rzkk5P_n.js} +165 -869
- package/dist/{tr-C1MJnwIJ.js → tr-DKuVBwqW.js} +166 -870
- package/dist/{transitionSpinner-Bkjw-WAJ.js → transitionSpinner-Di0XBAix.js} +5 -4
- package/dist/tutorial-C9psDR2i.js +28 -0
- package/dist/types/ae-signature.d.ts +10 -1
- package/dist/types/antifraud.d.ts +10 -1
- package/dist/types/authentication.d.ts +10 -1
- package/dist/types/certificate-issuance.d.ts +10 -1
- package/dist/types/consent.d.ts +10 -1
- package/dist/types/cross-document-data-match.d.ts +10 -1
- package/dist/types/curp-validation.d.ts +10 -1
- package/dist/types/document-capture.d.ts +10 -1
- package/dist/types/dynamic-forms.d.ts +10 -1
- package/dist/types/ekyb.d.ts +10 -1
- package/dist/types/ekyc.d.ts +10 -1
- package/dist/types/electronic-signature.d.ts +10 -1
- package/dist/types/email.d.ts +10 -1
- package/dist/types/extensibility.d.ts +147 -21
- package/dist/types/face-match.d.ts +10 -1
- package/dist/types/field-comparison.d.ts +10 -1
- package/dist/types/fiscal-qr.d.ts +10 -1
- package/dist/types/flow.d.ts +22 -2
- package/dist/types/geolocation.d.ts +10 -1
- package/dist/types/government-validation.d.ts +10 -1
- package/dist/types/id-selfie-flow.d.ts +10 -1
- package/dist/types/id-verification.d.ts +10 -1
- package/dist/types/id.d.ts +10 -1
- package/dist/types/identity-reuse.d.ts +10 -1
- package/dist/types/index.d.ts +92 -10
- package/dist/types/kyb-checks.d.ts +209 -0
- package/dist/types/phone.d.ts +10 -1
- package/dist/types/qe-signature.d.ts +10 -1
- package/dist/types/redirect-to-mobile.d.ts +1 -1
- package/dist/types/selfie.d.ts +10 -1
- package/dist/types/signature.d.ts +10 -1
- package/dist/types/video-selfie.d.ts +1 -1
- package/dist/types/watchlist.d.ts +10 -1
- package/dist/types/workflow.d.ts +10 -1
- package/dist/{typography-DKXgPZsU.js → typography-CiGhKJGx.js} +2 -2
- package/dist/uiConfig-BJAuZQWc.js +77 -0
- package/dist/{uk-DFL26I5l.js → uk-CXjqq4lX.js} +164 -868
- package/dist/{uk-UA-3o9Xbam-.js → uk-UA-BIE9WByU.js} +165 -869
- package/dist/{ur-DXJAfyQA.js → ur-vNGesC3r.js} +165 -869
- package/dist/useCameraPreview-Bd7AYE9h.js +93 -0
- package/dist/useCaptureHelpButton-Dj-jESrS.js +43 -0
- package/dist/useIsDarkTheme-Bu9CvKxW.js +27 -0
- package/dist/{useModuleLoader-BdIp6TNQ.js → useModuleLoader-BBCNkJmc.js} +2 -2
- package/dist/{uz-BXvj8vlH.js → uz-Gmw1XRgv.js} +165 -869
- package/dist/{vendor-preact-C0jX1Cbq.js → vendor-preact-DHGqBGMH.js} +19 -1
- package/dist/{verificationResult-BVrKFRMf.js → verificationResult-Clxdxm_s.js} +18 -10
- package/dist/{vi-DRfsxu1a.js → vi-DTxxRUw0.js} +165 -869
- package/dist/video-selfie/styles.css +1 -1
- package/dist/video-selfie/styles.css.js +1 -1
- package/dist/video-selfie/video-selfie.es.js +103 -67
- package/dist/watchlist/watchlist.es.js +8 -7
- package/dist/{watchlistForBusiness-CyAmoIrv.js → watchlistForBusiness-CpFp2EYX.js} +44 -14
- package/dist/{withEndScreenTexts-MHocOODe.js → withEndScreenTexts-Bd3mof3s.js} +225 -45
- package/dist/workflow/styles.css +1 -1
- package/dist/workflow/workflow.es.js +32 -21
- package/dist/{zh-CN-DMfj1_Nh.js → zh-CN-aB48G_R1.js} +164 -868
- package/dist/{zh-Ct8GKGhw.js → zh-DjtyfO4e.js} +164 -868
- package/dist/{zh-HANT-NZFdeKuE.js → zh-HANT-8p8SH8C3.js} +165 -869
- package/dist/{zh-TW-8wkrOHM8.js → zh-TW-CCsz9gKq.js} +165 -869
- package/package.json +35 -10
- package/dist/browser-ponyfill-DT11p-Ob.js +0 -441
- package/dist/cameraOverlay-CBTjtbNP.js +0 -2
- package/dist/connectionError-DX3wd4vm.js +0 -45
- package/dist/dateInputComposed-BzW0cv1o.js +0 -1
- package/dist/deviceWallet-CImevqFB.js +0 -66
- package/dist/documentCapture-CmWd-wNL.js +0 -2
- package/dist/dropdownComposed-B76j7pz9.js +0 -1
- package/dist/ekybModule-Bshc_ANM.js +0 -2
- package/dist/ekycModule-MmJYwp1l.js +0 -2
- package/dist/es-419-DlCbbvcc.js +0 -3145
- package/dist/esm-15CISqPe.js +0 -430
- package/dist/faceMatch-BVSCpwmA.js +0 -2
- package/dist/fieldComparison-nFj9pSeZ.js +0 -2
- package/dist/flipAnimation-DY9K2zel.js +0 -3048
- package/dist/incodeModule-D6oey1Mb.js +0 -68
- package/dist/inputComposed-45HxIMO0.js +0 -1
- package/dist/pdfViewer-CFkuHOV4.js +0 -2
- package/dist/radioGroupComposed-DJ71F9KK.js +0 -1
- package/dist/richText-aCnLd3j2.js +0 -1549
- package/dist/spacer-BvrtrwSF.js +0 -741
- package/dist/spinner-CkN8sW0d.js +0 -88
- package/dist/sr-YU-UEhyvXZ-.js +0 -3149
- package/dist/statusPage-3zRxvkSE.js +0 -36
- package/dist/uiConfig-BA7U_zLr.js +0 -2589
- package/dist/useCaptureHelpButton-CSG3fO48.js +0 -86
- package/dist/useCoverMedia-VLw3OYN_.js +0 -149
- /package/dist/{aligndevicelottie-BARt-rhe.js → aligndevicelottie-BEKzL4SB.js} +0 -0
- /package/dist/{back-tutorial-CZrMmj1_.js → back-tutorial-B9W63fa-.js} +0 -0
- /package/dist/{backdevicelottie-CIM3ekd8.js → backdevicelottie-DsN8QBV3.js} +0 -0
- /package/dist/{blurdevicelottie-BRyXfLB6.js → blurdevicelottie-DkV7Kwo4.js} +0 -0
- /package/dist/{countryDefinitions-BO9OSKQO.js → countryDefinitions-RBVGM1D_.js} +0 -0
- /package/dist/{defineProperty-CjeJoXkx.js → defineProperty-E9wRIIo9.js} +0 -0
- /package/dist/{flip-animation-BU5LNKYx.js → flip-animation-DJVnWWL5.js} +0 -0
- /package/dist/{frontdevicelottie-arpyu_Fz.js → frontdevicelottie-DiW1Wmya.js} +0 -0
- /package/dist/{glaredevicelottie-TwTFxe7h.js → glaredevicelottie-CK-fnX_s.js} +0 -0
- /package/dist/{id-laser-h-Dr-hBxrq.js → id-laser-h-6Am_cjM8.js} +0 -0
- /package/dist/{id-laser-v-D_r0QNY8.js → id-laser-v-DXoF3flH.js} +0 -0
- /package/dist/{id-tutorial-DM9Pkfs-.js → id-tutorial-DkKH3eTE.js} +0 -0
- /package/dist/{lottie_light-aMg9Q9iO.js → lottie_light-B819EhaL.js} +0 -0
- /package/dist/{passport-tutorial-CKZZuDf_.js → passport-tutorial-D3Fpk-Tj.js} +0 -0
- /package/dist/{pdf.worker.min-BM1b2w9V.js → pdf.worker.min-DzBNMoKS.js} +0 -0
- /package/dist/{policyUrls-B3M8nLRh.js → policyUrls-Benduf-R.js} +0 -0
- /package/dist/{purify.es-0fCPkEV1.js → purify.es-CSPoFViI.js} +0 -0
- /package/dist/{selfieTutorial-Dz6lDFMn.js → selfieTutorial-DnsRD1Z9.js} +0 -0
|
@@ -1,2589 +0,0 @@
|
|
|
1
|
-
import { S as k, _ as y, f as d, h as q, r as C, u as T, v as u, y as K } from "./vendor-preact-C0jX1Cbq.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/i18next@25.7.1_typescript@5.9.3/node_modules/i18next/dist/esm/i18next.js
|
|
3
|
-
var isString = (obj) => typeof obj === "string";
|
|
4
|
-
var defer = () => {
|
|
5
|
-
let res;
|
|
6
|
-
let rej;
|
|
7
|
-
const promise = new Promise((resolve, reject) => {
|
|
8
|
-
res = resolve;
|
|
9
|
-
rej = reject;
|
|
10
|
-
});
|
|
11
|
-
promise.resolve = res;
|
|
12
|
-
promise.reject = rej;
|
|
13
|
-
return promise;
|
|
14
|
-
};
|
|
15
|
-
var makeString = (object) => {
|
|
16
|
-
if (object == null) return "";
|
|
17
|
-
return "" + object;
|
|
18
|
-
};
|
|
19
|
-
var copy = (a, s, t) => {
|
|
20
|
-
a.forEach((m) => {
|
|
21
|
-
if (s[m]) t[m] = s[m];
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var lastOfPathSeparatorRegExp = /###/g;
|
|
25
|
-
var cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
|
|
26
|
-
var canNotTraverseDeeper = (object) => !object || isString(object);
|
|
27
|
-
var getLastOfPath = (object, path, Empty) => {
|
|
28
|
-
const stack = !isString(path) ? path : path.split(".");
|
|
29
|
-
let stackIndex = 0;
|
|
30
|
-
while (stackIndex < stack.length - 1) {
|
|
31
|
-
if (canNotTraverseDeeper(object)) return {};
|
|
32
|
-
const key = cleanKey(stack[stackIndex]);
|
|
33
|
-
if (!object[key] && Empty) object[key] = new Empty();
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(object, key)) object = object[key];
|
|
35
|
-
else object = {};
|
|
36
|
-
++stackIndex;
|
|
37
|
-
}
|
|
38
|
-
if (canNotTraverseDeeper(object)) return {};
|
|
39
|
-
return {
|
|
40
|
-
obj: object,
|
|
41
|
-
k: cleanKey(stack[stackIndex])
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
var setPath = (object, path, newValue) => {
|
|
45
|
-
const { obj, k } = getLastOfPath(object, path, Object);
|
|
46
|
-
if (obj !== void 0 || path.length === 1) {
|
|
47
|
-
obj[k] = newValue;
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
let e = path[path.length - 1];
|
|
51
|
-
let p = path.slice(0, path.length - 1);
|
|
52
|
-
let last = getLastOfPath(object, p, Object);
|
|
53
|
-
while (last.obj === void 0 && p.length) {
|
|
54
|
-
e = `${p[p.length - 1]}.${e}`;
|
|
55
|
-
p = p.slice(0, p.length - 1);
|
|
56
|
-
last = getLastOfPath(object, p, Object);
|
|
57
|
-
if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== "undefined") last.obj = void 0;
|
|
58
|
-
}
|
|
59
|
-
last.obj[`${last.k}.${e}`] = newValue;
|
|
60
|
-
};
|
|
61
|
-
var pushPath = (object, path, newValue, concat) => {
|
|
62
|
-
const { obj, k } = getLastOfPath(object, path, Object);
|
|
63
|
-
obj[k] = obj[k] || [];
|
|
64
|
-
obj[k].push(newValue);
|
|
65
|
-
};
|
|
66
|
-
var getPath = (object, path) => {
|
|
67
|
-
const { obj, k } = getLastOfPath(object, path);
|
|
68
|
-
if (!obj) return void 0;
|
|
69
|
-
if (!Object.prototype.hasOwnProperty.call(obj, k)) return void 0;
|
|
70
|
-
return obj[k];
|
|
71
|
-
};
|
|
72
|
-
var getPathWithDefaults = (data, defaultData, key) => {
|
|
73
|
-
const value = getPath(data, key);
|
|
74
|
-
if (value !== void 0) return value;
|
|
75
|
-
return getPath(defaultData, key);
|
|
76
|
-
};
|
|
77
|
-
var deepExtend = (target, source, overwrite) => {
|
|
78
|
-
for (const prop in source) if (prop !== "__proto__" && prop !== "constructor") if (prop in target) if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
|
|
79
|
-
if (overwrite) target[prop] = source[prop];
|
|
80
|
-
} else deepExtend(target[prop], source[prop], overwrite);
|
|
81
|
-
else target[prop] = source[prop];
|
|
82
|
-
return target;
|
|
83
|
-
};
|
|
84
|
-
var regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
85
|
-
var _entityMap = {
|
|
86
|
-
"&": "&",
|
|
87
|
-
"<": "<",
|
|
88
|
-
">": ">",
|
|
89
|
-
"\"": """,
|
|
90
|
-
"'": "'",
|
|
91
|
-
"/": "/"
|
|
92
|
-
};
|
|
93
|
-
var escape = (data) => {
|
|
94
|
-
if (isString(data)) return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
|
|
95
|
-
return data;
|
|
96
|
-
};
|
|
97
|
-
var RegExpCache = class {
|
|
98
|
-
constructor(capacity) {
|
|
99
|
-
this.capacity = capacity;
|
|
100
|
-
this.regExpMap = /* @__PURE__ */ new Map();
|
|
101
|
-
this.regExpQueue = [];
|
|
102
|
-
}
|
|
103
|
-
getRegExp(pattern) {
|
|
104
|
-
const regExpFromCache = this.regExpMap.get(pattern);
|
|
105
|
-
if (regExpFromCache !== void 0) return regExpFromCache;
|
|
106
|
-
const regExpNew = new RegExp(pattern);
|
|
107
|
-
if (this.regExpQueue.length === this.capacity) this.regExpMap.delete(this.regExpQueue.shift());
|
|
108
|
-
this.regExpMap.set(pattern, regExpNew);
|
|
109
|
-
this.regExpQueue.push(pattern);
|
|
110
|
-
return regExpNew;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var chars = [
|
|
114
|
-
" ",
|
|
115
|
-
",",
|
|
116
|
-
"?",
|
|
117
|
-
"!",
|
|
118
|
-
";"
|
|
119
|
-
];
|
|
120
|
-
var looksLikeObjectPathRegExpCache = new RegExpCache(20);
|
|
121
|
-
var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
|
122
|
-
nsSeparator = nsSeparator || "";
|
|
123
|
-
keySeparator = keySeparator || "";
|
|
124
|
-
const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
|
|
125
|
-
if (possibleChars.length === 0) return true;
|
|
126
|
-
const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
|
|
127
|
-
let matched = !r.test(key);
|
|
128
|
-
if (!matched) {
|
|
129
|
-
const ki = key.indexOf(keySeparator);
|
|
130
|
-
if (ki > 0 && !r.test(key.substring(0, ki))) matched = true;
|
|
131
|
-
}
|
|
132
|
-
return matched;
|
|
133
|
-
};
|
|
134
|
-
var deepFind = (obj, path, keySeparator = ".") => {
|
|
135
|
-
if (!obj) return void 0;
|
|
136
|
-
if (obj[path]) {
|
|
137
|
-
if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
|
|
138
|
-
return obj[path];
|
|
139
|
-
}
|
|
140
|
-
const tokens = path.split(keySeparator);
|
|
141
|
-
let current = obj;
|
|
142
|
-
for (let i = 0; i < tokens.length;) {
|
|
143
|
-
if (!current || typeof current !== "object") return;
|
|
144
|
-
let next;
|
|
145
|
-
let nextPath = "";
|
|
146
|
-
for (let j = i; j < tokens.length; ++j) {
|
|
147
|
-
if (j !== i) nextPath += keySeparator;
|
|
148
|
-
nextPath += tokens[j];
|
|
149
|
-
next = current[nextPath];
|
|
150
|
-
if (next !== void 0) {
|
|
151
|
-
if ([
|
|
152
|
-
"string",
|
|
153
|
-
"number",
|
|
154
|
-
"boolean"
|
|
155
|
-
].indexOf(typeof next) > -1 && j < tokens.length - 1) continue;
|
|
156
|
-
i += j - i + 1;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
current = next;
|
|
161
|
-
}
|
|
162
|
-
return current;
|
|
163
|
-
};
|
|
164
|
-
var getCleanedCode = (code) => code?.replace("_", "-");
|
|
165
|
-
var consoleLogger = {
|
|
166
|
-
type: "logger",
|
|
167
|
-
log(args) {
|
|
168
|
-
this.output("log", args);
|
|
169
|
-
},
|
|
170
|
-
warn(args) {
|
|
171
|
-
this.output("warn", args);
|
|
172
|
-
},
|
|
173
|
-
error(args) {
|
|
174
|
-
this.output("error", args);
|
|
175
|
-
},
|
|
176
|
-
output(type, args) {
|
|
177
|
-
console?.[type]?.apply?.(console, args);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
var baseLogger = new class Logger {
|
|
181
|
-
constructor(concreteLogger, options = {}) {
|
|
182
|
-
this.init(concreteLogger, options);
|
|
183
|
-
}
|
|
184
|
-
init(concreteLogger, options = {}) {
|
|
185
|
-
this.prefix = options.prefix || "i18next:";
|
|
186
|
-
this.logger = concreteLogger || consoleLogger;
|
|
187
|
-
this.options = options;
|
|
188
|
-
this.debug = options.debug;
|
|
189
|
-
}
|
|
190
|
-
log(...args) {
|
|
191
|
-
return this.forward(args, "log", "", true);
|
|
192
|
-
}
|
|
193
|
-
warn(...args) {
|
|
194
|
-
return this.forward(args, "warn", "", true);
|
|
195
|
-
}
|
|
196
|
-
error(...args) {
|
|
197
|
-
return this.forward(args, "error", "");
|
|
198
|
-
}
|
|
199
|
-
deprecate(...args) {
|
|
200
|
-
return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
|
|
201
|
-
}
|
|
202
|
-
forward(args, lvl, prefix, debugOnly) {
|
|
203
|
-
if (debugOnly && !this.debug) return null;
|
|
204
|
-
if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
|
205
|
-
return this.logger[lvl](args);
|
|
206
|
-
}
|
|
207
|
-
create(moduleName) {
|
|
208
|
-
return new Logger(this.logger, {
|
|
209
|
-
prefix: `${this.prefix}:${moduleName}:`,
|
|
210
|
-
...this.options
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
clone(options) {
|
|
214
|
-
options = options || this.options;
|
|
215
|
-
options.prefix = options.prefix || this.prefix;
|
|
216
|
-
return new Logger(this.logger, options);
|
|
217
|
-
}
|
|
218
|
-
}();
|
|
219
|
-
var EventEmitter = class {
|
|
220
|
-
constructor() {
|
|
221
|
-
this.observers = {};
|
|
222
|
-
}
|
|
223
|
-
on(events, listener) {
|
|
224
|
-
events.split(" ").forEach((event) => {
|
|
225
|
-
if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
|
|
226
|
-
const numListeners = this.observers[event].get(listener) || 0;
|
|
227
|
-
this.observers[event].set(listener, numListeners + 1);
|
|
228
|
-
});
|
|
229
|
-
return this;
|
|
230
|
-
}
|
|
231
|
-
off(event, listener) {
|
|
232
|
-
if (!this.observers[event]) return;
|
|
233
|
-
if (!listener) {
|
|
234
|
-
delete this.observers[event];
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
this.observers[event].delete(listener);
|
|
238
|
-
}
|
|
239
|
-
emit(event, ...args) {
|
|
240
|
-
if (this.observers[event]) Array.from(this.observers[event].entries()).forEach(([observer, numTimesAdded]) => {
|
|
241
|
-
for (let i = 0; i < numTimesAdded; i++) observer(...args);
|
|
242
|
-
});
|
|
243
|
-
if (this.observers["*"]) Array.from(this.observers["*"].entries()).forEach(([observer, numTimesAdded]) => {
|
|
244
|
-
for (let i = 0; i < numTimesAdded; i++) observer.apply(observer, [event, ...args]);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var ResourceStore = class extends EventEmitter {
|
|
249
|
-
constructor(data, options = {
|
|
250
|
-
ns: ["translation"],
|
|
251
|
-
defaultNS: "translation"
|
|
252
|
-
}) {
|
|
253
|
-
super();
|
|
254
|
-
this.data = data || {};
|
|
255
|
-
this.options = options;
|
|
256
|
-
if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
|
|
257
|
-
if (this.options.ignoreJSONStructure === void 0) this.options.ignoreJSONStructure = true;
|
|
258
|
-
}
|
|
259
|
-
addNamespaces(ns) {
|
|
260
|
-
if (this.options.ns.indexOf(ns) < 0) this.options.ns.push(ns);
|
|
261
|
-
}
|
|
262
|
-
removeNamespaces(ns) {
|
|
263
|
-
const index = this.options.ns.indexOf(ns);
|
|
264
|
-
if (index > -1) this.options.ns.splice(index, 1);
|
|
265
|
-
}
|
|
266
|
-
getResource(lng, ns, key, options = {}) {
|
|
267
|
-
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
268
|
-
const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
269
|
-
let path;
|
|
270
|
-
if (lng.indexOf(".") > -1) path = lng.split(".");
|
|
271
|
-
else {
|
|
272
|
-
path = [lng, ns];
|
|
273
|
-
if (key) if (Array.isArray(key)) path.push(...key);
|
|
274
|
-
else if (isString(key) && keySeparator) path.push(...key.split(keySeparator));
|
|
275
|
-
else path.push(key);
|
|
276
|
-
}
|
|
277
|
-
const result = getPath(this.data, path);
|
|
278
|
-
if (!result && !ns && !key && lng.indexOf(".") > -1) {
|
|
279
|
-
lng = path[0];
|
|
280
|
-
ns = path[1];
|
|
281
|
-
key = path.slice(2).join(".");
|
|
282
|
-
}
|
|
283
|
-
if (result || !ignoreJSONStructure || !isString(key)) return result;
|
|
284
|
-
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
285
|
-
}
|
|
286
|
-
addResource(lng, ns, key, value, options = { silent: false }) {
|
|
287
|
-
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
288
|
-
let path = [lng, ns];
|
|
289
|
-
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
290
|
-
if (lng.indexOf(".") > -1) {
|
|
291
|
-
path = lng.split(".");
|
|
292
|
-
value = ns;
|
|
293
|
-
ns = path[1];
|
|
294
|
-
}
|
|
295
|
-
this.addNamespaces(ns);
|
|
296
|
-
setPath(this.data, path, value);
|
|
297
|
-
if (!options.silent) this.emit("added", lng, ns, key, value);
|
|
298
|
-
}
|
|
299
|
-
addResources(lng, ns, resources, options = { silent: false }) {
|
|
300
|
-
for (const m in resources) if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], { silent: true });
|
|
301
|
-
if (!options.silent) this.emit("added", lng, ns, resources);
|
|
302
|
-
}
|
|
303
|
-
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
|
304
|
-
silent: false,
|
|
305
|
-
skipCopy: false
|
|
306
|
-
}) {
|
|
307
|
-
let path = [lng, ns];
|
|
308
|
-
if (lng.indexOf(".") > -1) {
|
|
309
|
-
path = lng.split(".");
|
|
310
|
-
deep = resources;
|
|
311
|
-
resources = ns;
|
|
312
|
-
ns = path[1];
|
|
313
|
-
}
|
|
314
|
-
this.addNamespaces(ns);
|
|
315
|
-
let pack = getPath(this.data, path) || {};
|
|
316
|
-
if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
|
|
317
|
-
if (deep) deepExtend(pack, resources, overwrite);
|
|
318
|
-
else pack = {
|
|
319
|
-
...pack,
|
|
320
|
-
...resources
|
|
321
|
-
};
|
|
322
|
-
setPath(this.data, path, pack);
|
|
323
|
-
if (!options.silent) this.emit("added", lng, ns, resources);
|
|
324
|
-
}
|
|
325
|
-
removeResourceBundle(lng, ns) {
|
|
326
|
-
if (this.hasResourceBundle(lng, ns)) delete this.data[lng][ns];
|
|
327
|
-
this.removeNamespaces(ns);
|
|
328
|
-
this.emit("removed", lng, ns);
|
|
329
|
-
}
|
|
330
|
-
hasResourceBundle(lng, ns) {
|
|
331
|
-
return this.getResource(lng, ns) !== void 0;
|
|
332
|
-
}
|
|
333
|
-
getResourceBundle(lng, ns) {
|
|
334
|
-
if (!ns) ns = this.options.defaultNS;
|
|
335
|
-
return this.getResource(lng, ns);
|
|
336
|
-
}
|
|
337
|
-
getDataByLanguage(lng) {
|
|
338
|
-
return this.data[lng];
|
|
339
|
-
}
|
|
340
|
-
hasLanguageSomeTranslations(lng) {
|
|
341
|
-
const data = this.getDataByLanguage(lng);
|
|
342
|
-
return !!(data && Object.keys(data) || []).find((v) => data[v] && Object.keys(data[v]).length > 0);
|
|
343
|
-
}
|
|
344
|
-
toJSON() {
|
|
345
|
-
return this.data;
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
var postProcessor = {
|
|
349
|
-
processors: {},
|
|
350
|
-
addPostProcessor(module) {
|
|
351
|
-
this.processors[module.name] = module;
|
|
352
|
-
},
|
|
353
|
-
handle(processors, value, key, options, translator) {
|
|
354
|
-
processors.forEach((processor) => {
|
|
355
|
-
value = this.processors[processor]?.process(value, key, options, translator) ?? value;
|
|
356
|
-
});
|
|
357
|
-
return value;
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
var PATH_KEY = Symbol("i18next/PATH_KEY");
|
|
361
|
-
function createProxy() {
|
|
362
|
-
const state = [];
|
|
363
|
-
const handler = Object.create(null);
|
|
364
|
-
let proxy;
|
|
365
|
-
handler.get = (target, key) => {
|
|
366
|
-
proxy?.revoke?.();
|
|
367
|
-
if (key === PATH_KEY) return state;
|
|
368
|
-
state.push(key);
|
|
369
|
-
proxy = Proxy.revocable(target, handler);
|
|
370
|
-
return proxy.proxy;
|
|
371
|
-
};
|
|
372
|
-
return Proxy.revocable(Object.create(null), handler).proxy;
|
|
373
|
-
}
|
|
374
|
-
function keysFromSelector(selector, opts) {
|
|
375
|
-
const { [PATH_KEY]: path } = selector(createProxy());
|
|
376
|
-
return path.join(opts?.keySeparator ?? ".");
|
|
377
|
-
}
|
|
378
|
-
var checkedLoadedFor = {};
|
|
379
|
-
var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
|
|
380
|
-
var Translator = class Translator extends EventEmitter {
|
|
381
|
-
constructor(services, options = {}) {
|
|
382
|
-
super();
|
|
383
|
-
copy([
|
|
384
|
-
"resourceStore",
|
|
385
|
-
"languageUtils",
|
|
386
|
-
"pluralResolver",
|
|
387
|
-
"interpolator",
|
|
388
|
-
"backendConnector",
|
|
389
|
-
"i18nFormat",
|
|
390
|
-
"utils"
|
|
391
|
-
], services, this);
|
|
392
|
-
this.options = options;
|
|
393
|
-
if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
|
|
394
|
-
this.logger = baseLogger.create("translator");
|
|
395
|
-
}
|
|
396
|
-
changeLanguage(lng) {
|
|
397
|
-
if (lng) this.language = lng;
|
|
398
|
-
}
|
|
399
|
-
exists(key, o = { interpolation: {} }) {
|
|
400
|
-
const opt = { ...o };
|
|
401
|
-
if (key == null) return false;
|
|
402
|
-
const resolved = this.resolve(key, opt);
|
|
403
|
-
if (resolved?.res === void 0) return false;
|
|
404
|
-
const isObject = shouldHandleAsObject(resolved.res);
|
|
405
|
-
if (opt.returnObjects === false && isObject) return false;
|
|
406
|
-
return true;
|
|
407
|
-
}
|
|
408
|
-
extractFromKey(key, opt) {
|
|
409
|
-
let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
|
|
410
|
-
if (nsSeparator === void 0) nsSeparator = ":";
|
|
411
|
-
const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
|
|
412
|
-
let namespaces = opt.ns || this.options.defaultNS || [];
|
|
413
|
-
const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
|
414
|
-
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
415
|
-
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
416
|
-
const m = key.match(this.interpolator.nestingRegexp);
|
|
417
|
-
if (m && m.length > 0) return {
|
|
418
|
-
key,
|
|
419
|
-
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
420
|
-
};
|
|
421
|
-
const parts = key.split(nsSeparator);
|
|
422
|
-
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
|
423
|
-
key = parts.join(keySeparator);
|
|
424
|
-
}
|
|
425
|
-
return {
|
|
426
|
-
key,
|
|
427
|
-
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
translate(keys, o, lastKey) {
|
|
431
|
-
let opt = typeof o === "object" ? { ...o } : o;
|
|
432
|
-
if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
433
|
-
if (typeof opt === "object") opt = { ...opt };
|
|
434
|
-
if (!opt) opt = {};
|
|
435
|
-
if (keys == null) return "";
|
|
436
|
-
if (typeof keys === "function") keys = keysFromSelector(keys, {
|
|
437
|
-
...this.options,
|
|
438
|
-
...opt
|
|
439
|
-
});
|
|
440
|
-
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
441
|
-
const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
|
|
442
|
-
const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
|
|
443
|
-
const { key, namespaces } = this.extractFromKey(keys[keys.length - 1], opt);
|
|
444
|
-
const namespace = namespaces[namespaces.length - 1];
|
|
445
|
-
let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
|
|
446
|
-
if (nsSeparator === void 0) nsSeparator = ":";
|
|
447
|
-
const lng = opt.lng || this.language;
|
|
448
|
-
const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
449
|
-
if (lng?.toLowerCase() === "cimode") {
|
|
450
|
-
if (appendNamespaceToCIMode) {
|
|
451
|
-
if (returnDetails) return {
|
|
452
|
-
res: `${namespace}${nsSeparator}${key}`,
|
|
453
|
-
usedKey: key,
|
|
454
|
-
exactUsedKey: key,
|
|
455
|
-
usedLng: lng,
|
|
456
|
-
usedNS: namespace,
|
|
457
|
-
usedParams: this.getUsedParamsDetails(opt)
|
|
458
|
-
};
|
|
459
|
-
return `${namespace}${nsSeparator}${key}`;
|
|
460
|
-
}
|
|
461
|
-
if (returnDetails) return {
|
|
462
|
-
res: key,
|
|
463
|
-
usedKey: key,
|
|
464
|
-
exactUsedKey: key,
|
|
465
|
-
usedLng: lng,
|
|
466
|
-
usedNS: namespace,
|
|
467
|
-
usedParams: this.getUsedParamsDetails(opt)
|
|
468
|
-
};
|
|
469
|
-
return key;
|
|
470
|
-
}
|
|
471
|
-
const resolved = this.resolve(keys, opt);
|
|
472
|
-
let res = resolved?.res;
|
|
473
|
-
const resUsedKey = resolved?.usedKey || key;
|
|
474
|
-
const resExactUsedKey = resolved?.exactUsedKey || key;
|
|
475
|
-
const noObject = [
|
|
476
|
-
"[object Number]",
|
|
477
|
-
"[object Function]",
|
|
478
|
-
"[object RegExp]"
|
|
479
|
-
];
|
|
480
|
-
const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
|
|
481
|
-
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
482
|
-
const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
|
|
483
|
-
const hasDefaultValue = Translator.hasDefaultValue(opt);
|
|
484
|
-
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
|
|
485
|
-
const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, { ordinal: false }) : "";
|
|
486
|
-
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
487
|
-
const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
|
|
488
|
-
let resForObjHndl = res;
|
|
489
|
-
if (handleAsObjectInI18nFormat && !res && hasDefaultValue) resForObjHndl = defaultValue;
|
|
490
|
-
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
491
|
-
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
492
|
-
if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
|
|
493
|
-
if (!opt.returnObjects && !this.options.returnObjects) {
|
|
494
|
-
if (!this.options.returnedObjectHandler) this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
495
|
-
const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
|
|
496
|
-
...opt,
|
|
497
|
-
ns: namespaces
|
|
498
|
-
}) : `key '${key} (${this.language})' returned an object instead of string.`;
|
|
499
|
-
if (returnDetails) {
|
|
500
|
-
resolved.res = r;
|
|
501
|
-
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
502
|
-
return resolved;
|
|
503
|
-
}
|
|
504
|
-
return r;
|
|
505
|
-
}
|
|
506
|
-
if (keySeparator) {
|
|
507
|
-
const resTypeIsArray = Array.isArray(resForObjHndl);
|
|
508
|
-
const copy = resTypeIsArray ? [] : {};
|
|
509
|
-
const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
510
|
-
for (const m in resForObjHndl) if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
|
|
511
|
-
const deepKey = `${newKeyToUse}${keySeparator}${m}`;
|
|
512
|
-
if (hasDefaultValue && !res) copy[m] = this.translate(deepKey, {
|
|
513
|
-
...opt,
|
|
514
|
-
defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : void 0,
|
|
515
|
-
joinArrays: false,
|
|
516
|
-
ns: namespaces
|
|
517
|
-
});
|
|
518
|
-
else copy[m] = this.translate(deepKey, {
|
|
519
|
-
...opt,
|
|
520
|
-
joinArrays: false,
|
|
521
|
-
ns: namespaces
|
|
522
|
-
});
|
|
523
|
-
if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
|
|
524
|
-
}
|
|
525
|
-
res = copy;
|
|
526
|
-
}
|
|
527
|
-
} else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
|
|
528
|
-
res = res.join(joinArrays);
|
|
529
|
-
if (res) res = this.extendTranslation(res, keys, opt, lastKey);
|
|
530
|
-
} else {
|
|
531
|
-
let usedDefault = false;
|
|
532
|
-
let usedKey = false;
|
|
533
|
-
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
534
|
-
usedDefault = true;
|
|
535
|
-
res = defaultValue;
|
|
536
|
-
}
|
|
537
|
-
if (!this.isValidLookup(res)) {
|
|
538
|
-
usedKey = true;
|
|
539
|
-
res = key;
|
|
540
|
-
}
|
|
541
|
-
const resForMissing = (opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && usedKey ? void 0 : res;
|
|
542
|
-
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
543
|
-
if (usedKey || usedDefault || updateMissing) {
|
|
544
|
-
this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
|
|
545
|
-
if (keySeparator) {
|
|
546
|
-
const fk = this.resolve(key, {
|
|
547
|
-
...opt,
|
|
548
|
-
keySeparator: false
|
|
549
|
-
});
|
|
550
|
-
if (fk && fk.res) this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
|
|
551
|
-
}
|
|
552
|
-
let lngs = [];
|
|
553
|
-
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
|
|
554
|
-
if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) for (let i = 0; i < fallbackLngs.length; i++) lngs.push(fallbackLngs[i]);
|
|
555
|
-
else if (this.options.saveMissingTo === "all") lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
|
|
556
|
-
else lngs.push(opt.lng || this.language);
|
|
557
|
-
const send = (l, k, specificDefaultValue) => {
|
|
558
|
-
const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
559
|
-
if (this.options.missingKeyHandler) this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
|
|
560
|
-
else if (this.backendConnector?.saveMissing) this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
|
|
561
|
-
this.emit("missingKey", l, namespace, k, res);
|
|
562
|
-
};
|
|
563
|
-
if (this.options.saveMissing) if (this.options.saveMissingPlurals && needsPluralHandling) lngs.forEach((language) => {
|
|
564
|
-
const suffixes = this.pluralResolver.getSuffixes(language, opt);
|
|
565
|
-
if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) suffixes.push(`${this.options.pluralSeparator}zero`);
|
|
566
|
-
suffixes.forEach((suffix) => {
|
|
567
|
-
send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
else send(lngs, key, defaultValue);
|
|
571
|
-
}
|
|
572
|
-
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
573
|
-
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}${nsSeparator}${key}`;
|
|
574
|
-
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
|
|
575
|
-
}
|
|
576
|
-
if (returnDetails) {
|
|
577
|
-
resolved.res = res;
|
|
578
|
-
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
579
|
-
return resolved;
|
|
580
|
-
}
|
|
581
|
-
return res;
|
|
582
|
-
}
|
|
583
|
-
extendTranslation(res, key, opt, resolved, lastKey) {
|
|
584
|
-
if (this.i18nFormat?.parse) res = this.i18nFormat.parse(res, {
|
|
585
|
-
...this.options.interpolation.defaultVariables,
|
|
586
|
-
...opt
|
|
587
|
-
}, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, { resolved });
|
|
588
|
-
else if (!opt.skipInterpolation) {
|
|
589
|
-
if (opt.interpolation) this.interpolator.init({
|
|
590
|
-
...opt,
|
|
591
|
-
interpolation: {
|
|
592
|
-
...this.options.interpolation,
|
|
593
|
-
...opt.interpolation
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
597
|
-
let nestBef;
|
|
598
|
-
if (skipOnVariables) {
|
|
599
|
-
const nb = res.match(this.interpolator.nestingRegexp);
|
|
600
|
-
nestBef = nb && nb.length;
|
|
601
|
-
}
|
|
602
|
-
let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
|
|
603
|
-
if (this.options.interpolation.defaultVariables) data = {
|
|
604
|
-
...this.options.interpolation.defaultVariables,
|
|
605
|
-
...data
|
|
606
|
-
};
|
|
607
|
-
res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
|
|
608
|
-
if (skipOnVariables) {
|
|
609
|
-
const na = res.match(this.interpolator.nestingRegexp);
|
|
610
|
-
const nestAft = na && na.length;
|
|
611
|
-
if (nestBef < nestAft) opt.nest = false;
|
|
612
|
-
}
|
|
613
|
-
if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
|
|
614
|
-
if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
|
|
615
|
-
if (lastKey?.[0] === args[0] && !opt.context) {
|
|
616
|
-
this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
|
|
617
|
-
return null;
|
|
618
|
-
}
|
|
619
|
-
return this.translate(...args, key);
|
|
620
|
-
}, opt);
|
|
621
|
-
if (opt.interpolation) this.interpolator.reset();
|
|
622
|
-
}
|
|
623
|
-
const postProcess = opt.postProcess || this.options.postProcess;
|
|
624
|
-
const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
|
|
625
|
-
if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
|
626
|
-
i18nResolved: {
|
|
627
|
-
...resolved,
|
|
628
|
-
usedParams: this.getUsedParamsDetails(opt)
|
|
629
|
-
},
|
|
630
|
-
...opt
|
|
631
|
-
} : opt, this);
|
|
632
|
-
return res;
|
|
633
|
-
}
|
|
634
|
-
resolve(keys, opt = {}) {
|
|
635
|
-
let found;
|
|
636
|
-
let usedKey;
|
|
637
|
-
let exactUsedKey;
|
|
638
|
-
let usedLng;
|
|
639
|
-
let usedNS;
|
|
640
|
-
if (isString(keys)) keys = [keys];
|
|
641
|
-
keys.forEach((k) => {
|
|
642
|
-
if (this.isValidLookup(found)) return;
|
|
643
|
-
const extracted = this.extractFromKey(k, opt);
|
|
644
|
-
const key = extracted.key;
|
|
645
|
-
usedKey = key;
|
|
646
|
-
let namespaces = extracted.namespaces;
|
|
647
|
-
if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
|
|
648
|
-
const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
|
|
649
|
-
const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
|
|
650
|
-
const needsContextHandling = opt.context !== void 0 && (isString(opt.context) || typeof opt.context === "number") && opt.context !== "";
|
|
651
|
-
const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
|
|
652
|
-
namespaces.forEach((ns) => {
|
|
653
|
-
if (this.isValidLookup(found)) return;
|
|
654
|
-
usedNS = ns;
|
|
655
|
-
if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
|
|
656
|
-
checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
|
657
|
-
this.logger.warn(`key "${usedKey}" for languages "${codes.join(", ")}" won't get resolved as namespace "${usedNS}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
658
|
-
}
|
|
659
|
-
codes.forEach((code) => {
|
|
660
|
-
if (this.isValidLookup(found)) return;
|
|
661
|
-
usedLng = code;
|
|
662
|
-
const finalKeys = [key];
|
|
663
|
-
if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
|
|
664
|
-
else {
|
|
665
|
-
let pluralSuffix;
|
|
666
|
-
if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
|
|
667
|
-
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
|
668
|
-
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
669
|
-
if (needsPluralHandling) {
|
|
670
|
-
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
671
|
-
finalKeys.push(key + pluralSuffix);
|
|
672
|
-
if (needsZeroSuffixLookup) finalKeys.push(key + zeroSuffix);
|
|
673
|
-
}
|
|
674
|
-
if (needsContextHandling) {
|
|
675
|
-
const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
|
|
676
|
-
finalKeys.push(contextKey);
|
|
677
|
-
if (needsPluralHandling) {
|
|
678
|
-
if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
679
|
-
finalKeys.push(contextKey + pluralSuffix);
|
|
680
|
-
if (needsZeroSuffixLookup) finalKeys.push(contextKey + zeroSuffix);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
let possibleKey;
|
|
685
|
-
while (possibleKey = finalKeys.pop()) if (!this.isValidLookup(found)) {
|
|
686
|
-
exactUsedKey = possibleKey;
|
|
687
|
-
found = this.getResource(code, ns, possibleKey, opt);
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
});
|
|
692
|
-
return {
|
|
693
|
-
res: found,
|
|
694
|
-
usedKey,
|
|
695
|
-
exactUsedKey,
|
|
696
|
-
usedLng,
|
|
697
|
-
usedNS
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
isValidLookup(res) {
|
|
701
|
-
return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
|
|
702
|
-
}
|
|
703
|
-
getResource(code, ns, key, options = {}) {
|
|
704
|
-
if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
705
|
-
return this.resourceStore.getResource(code, ns, key, options);
|
|
706
|
-
}
|
|
707
|
-
getUsedParamsDetails(options = {}) {
|
|
708
|
-
const optionsKeys = [
|
|
709
|
-
"defaultValue",
|
|
710
|
-
"ordinal",
|
|
711
|
-
"context",
|
|
712
|
-
"replace",
|
|
713
|
-
"lng",
|
|
714
|
-
"lngs",
|
|
715
|
-
"fallbackLng",
|
|
716
|
-
"ns",
|
|
717
|
-
"keySeparator",
|
|
718
|
-
"nsSeparator",
|
|
719
|
-
"returnObjects",
|
|
720
|
-
"returnDetails",
|
|
721
|
-
"joinArrays",
|
|
722
|
-
"postProcess",
|
|
723
|
-
"interpolation"
|
|
724
|
-
];
|
|
725
|
-
const useOptionsReplaceForData = options.replace && !isString(options.replace);
|
|
726
|
-
let data = useOptionsReplaceForData ? options.replace : options;
|
|
727
|
-
if (useOptionsReplaceForData && typeof options.count !== "undefined") data.count = options.count;
|
|
728
|
-
if (this.options.interpolation.defaultVariables) data = {
|
|
729
|
-
...this.options.interpolation.defaultVariables,
|
|
730
|
-
...data
|
|
731
|
-
};
|
|
732
|
-
if (!useOptionsReplaceForData) {
|
|
733
|
-
data = { ...data };
|
|
734
|
-
for (const key of optionsKeys) delete data[key];
|
|
735
|
-
}
|
|
736
|
-
return data;
|
|
737
|
-
}
|
|
738
|
-
static hasDefaultValue(options) {
|
|
739
|
-
const prefix = "defaultValue";
|
|
740
|
-
for (const option in options) if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, 12) && void 0 !== options[option]) return true;
|
|
741
|
-
return false;
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
var LanguageUtil = class {
|
|
745
|
-
constructor(options) {
|
|
746
|
-
this.options = options;
|
|
747
|
-
this.supportedLngs = this.options.supportedLngs || false;
|
|
748
|
-
this.logger = baseLogger.create("languageUtils");
|
|
749
|
-
}
|
|
750
|
-
getScriptPartFromCode(code) {
|
|
751
|
-
code = getCleanedCode(code);
|
|
752
|
-
if (!code || code.indexOf("-") < 0) return null;
|
|
753
|
-
const p = code.split("-");
|
|
754
|
-
if (p.length === 2) return null;
|
|
755
|
-
p.pop();
|
|
756
|
-
if (p[p.length - 1].toLowerCase() === "x") return null;
|
|
757
|
-
return this.formatLanguageCode(p.join("-"));
|
|
758
|
-
}
|
|
759
|
-
getLanguagePartFromCode(code) {
|
|
760
|
-
code = getCleanedCode(code);
|
|
761
|
-
if (!code || code.indexOf("-") < 0) return code;
|
|
762
|
-
const p = code.split("-");
|
|
763
|
-
return this.formatLanguageCode(p[0]);
|
|
764
|
-
}
|
|
765
|
-
formatLanguageCode(code) {
|
|
766
|
-
if (isString(code) && code.indexOf("-") > -1) {
|
|
767
|
-
let formattedCode;
|
|
768
|
-
try {
|
|
769
|
-
formattedCode = Intl.getCanonicalLocales(code)[0];
|
|
770
|
-
} catch (e) {}
|
|
771
|
-
if (formattedCode && this.options.lowerCaseLng) formattedCode = formattedCode.toLowerCase();
|
|
772
|
-
if (formattedCode) return formattedCode;
|
|
773
|
-
if (this.options.lowerCaseLng) return code.toLowerCase();
|
|
774
|
-
return code;
|
|
775
|
-
}
|
|
776
|
-
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
777
|
-
}
|
|
778
|
-
isSupportedCode(code) {
|
|
779
|
-
if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) code = this.getLanguagePartFromCode(code);
|
|
780
|
-
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
|
781
|
-
}
|
|
782
|
-
getBestMatchFromCodes(codes) {
|
|
783
|
-
if (!codes) return null;
|
|
784
|
-
let found;
|
|
785
|
-
codes.forEach((code) => {
|
|
786
|
-
if (found) return;
|
|
787
|
-
const cleanedLng = this.formatLanguageCode(code);
|
|
788
|
-
if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
|
789
|
-
});
|
|
790
|
-
if (!found && this.options.supportedLngs) codes.forEach((code) => {
|
|
791
|
-
if (found) return;
|
|
792
|
-
const lngScOnly = this.getScriptPartFromCode(code);
|
|
793
|
-
if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
|
|
794
|
-
const lngOnly = this.getLanguagePartFromCode(code);
|
|
795
|
-
if (this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
796
|
-
found = this.options.supportedLngs.find((supportedLng) => {
|
|
797
|
-
if (supportedLng === lngOnly) return supportedLng;
|
|
798
|
-
if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
|
|
799
|
-
if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
|
|
800
|
-
if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
|
|
801
|
-
});
|
|
802
|
-
});
|
|
803
|
-
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
|
804
|
-
return found;
|
|
805
|
-
}
|
|
806
|
-
getFallbackCodes(fallbacks, code) {
|
|
807
|
-
if (!fallbacks) return [];
|
|
808
|
-
if (typeof fallbacks === "function") fallbacks = fallbacks(code);
|
|
809
|
-
if (isString(fallbacks)) fallbacks = [fallbacks];
|
|
810
|
-
if (Array.isArray(fallbacks)) return fallbacks;
|
|
811
|
-
if (!code) return fallbacks.default || [];
|
|
812
|
-
let found = fallbacks[code];
|
|
813
|
-
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
|
814
|
-
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
|
815
|
-
if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
|
|
816
|
-
if (!found) found = fallbacks.default;
|
|
817
|
-
return found || [];
|
|
818
|
-
}
|
|
819
|
-
toResolveHierarchy(code, fallbackCode) {
|
|
820
|
-
const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
|
|
821
|
-
const codes = [];
|
|
822
|
-
const addCode = (c) => {
|
|
823
|
-
if (!c) return;
|
|
824
|
-
if (this.isSupportedCode(c)) codes.push(c);
|
|
825
|
-
else this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
|
|
826
|
-
};
|
|
827
|
-
if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
|
|
828
|
-
if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
|
|
829
|
-
if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
|
|
830
|
-
if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
|
|
831
|
-
} else if (isString(code)) addCode(this.formatLanguageCode(code));
|
|
832
|
-
fallbackCodes.forEach((fc) => {
|
|
833
|
-
if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
|
|
834
|
-
});
|
|
835
|
-
return codes;
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
var suffixesOrder = {
|
|
839
|
-
zero: 0,
|
|
840
|
-
one: 1,
|
|
841
|
-
two: 2,
|
|
842
|
-
few: 3,
|
|
843
|
-
many: 4,
|
|
844
|
-
other: 5
|
|
845
|
-
};
|
|
846
|
-
var dummyRule = {
|
|
847
|
-
select: (count) => count === 1 ? "one" : "other",
|
|
848
|
-
resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
|
|
849
|
-
};
|
|
850
|
-
var PluralResolver = class {
|
|
851
|
-
constructor(languageUtils, options = {}) {
|
|
852
|
-
this.languageUtils = languageUtils;
|
|
853
|
-
this.options = options;
|
|
854
|
-
this.logger = baseLogger.create("pluralResolver");
|
|
855
|
-
this.pluralRulesCache = {};
|
|
856
|
-
}
|
|
857
|
-
addRule(lng, obj) {
|
|
858
|
-
this.rules[lng] = obj;
|
|
859
|
-
}
|
|
860
|
-
clearCache() {
|
|
861
|
-
this.pluralRulesCache = {};
|
|
862
|
-
}
|
|
863
|
-
getRule(code, options = {}) {
|
|
864
|
-
const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
|
|
865
|
-
const type = options.ordinal ? "ordinal" : "cardinal";
|
|
866
|
-
const cacheKey = JSON.stringify({
|
|
867
|
-
cleanedCode,
|
|
868
|
-
type
|
|
869
|
-
});
|
|
870
|
-
if (cacheKey in this.pluralRulesCache) return this.pluralRulesCache[cacheKey];
|
|
871
|
-
let rule;
|
|
872
|
-
try {
|
|
873
|
-
rule = new Intl.PluralRules(cleanedCode, { type });
|
|
874
|
-
} catch (err) {
|
|
875
|
-
if (!Intl) {
|
|
876
|
-
this.logger.error("No Intl support, please use an Intl polyfill!");
|
|
877
|
-
return dummyRule;
|
|
878
|
-
}
|
|
879
|
-
if (!code.match(/-|_/)) return dummyRule;
|
|
880
|
-
const lngPart = this.languageUtils.getLanguagePartFromCode(code);
|
|
881
|
-
rule = this.getRule(lngPart, options);
|
|
882
|
-
}
|
|
883
|
-
this.pluralRulesCache[cacheKey] = rule;
|
|
884
|
-
return rule;
|
|
885
|
-
}
|
|
886
|
-
needsPlural(code, options = {}) {
|
|
887
|
-
let rule = this.getRule(code, options);
|
|
888
|
-
if (!rule) rule = this.getRule("dev", options);
|
|
889
|
-
return rule?.resolvedOptions().pluralCategories.length > 1;
|
|
890
|
-
}
|
|
891
|
-
getPluralFormsOfKey(code, key, options = {}) {
|
|
892
|
-
return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
|
|
893
|
-
}
|
|
894
|
-
getSuffixes(code, options = {}) {
|
|
895
|
-
let rule = this.getRule(code, options);
|
|
896
|
-
if (!rule) rule = this.getRule("dev", options);
|
|
897
|
-
if (!rule) return [];
|
|
898
|
-
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
|
|
899
|
-
}
|
|
900
|
-
getSuffix(code, count, options = {}) {
|
|
901
|
-
const rule = this.getRule(code, options);
|
|
902
|
-
if (rule) return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
|
|
903
|
-
this.logger.warn(`no plural rule found for: ${code}`);
|
|
904
|
-
return this.getSuffix("dev", count, options);
|
|
905
|
-
}
|
|
906
|
-
};
|
|
907
|
-
var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
|
|
908
|
-
let path = getPathWithDefaults(data, defaultData, key);
|
|
909
|
-
if (!path && ignoreJSONStructure && isString(key)) {
|
|
910
|
-
path = deepFind(data, key, keySeparator);
|
|
911
|
-
if (path === void 0) path = deepFind(defaultData, key, keySeparator);
|
|
912
|
-
}
|
|
913
|
-
return path;
|
|
914
|
-
};
|
|
915
|
-
var regexSafe = (val) => val.replace(/\$/g, "$$$$");
|
|
916
|
-
var Interpolator = class {
|
|
917
|
-
constructor(options = {}) {
|
|
918
|
-
this.logger = baseLogger.create("interpolator");
|
|
919
|
-
this.options = options;
|
|
920
|
-
this.format = options?.interpolation?.format || ((value) => value);
|
|
921
|
-
this.init(options);
|
|
922
|
-
}
|
|
923
|
-
init(options = {}) {
|
|
924
|
-
if (!options.interpolation) options.interpolation = { escapeValue: true };
|
|
925
|
-
const { escape: escape$1, escapeValue, useRawValueToEscape, prefix, prefixEscaped, suffix, suffixEscaped, formatSeparator, unescapeSuffix, unescapePrefix, nestingPrefix, nestingPrefixEscaped, nestingSuffix, nestingSuffixEscaped, nestingOptionsSeparator, maxReplaces, alwaysFormat } = options.interpolation;
|
|
926
|
-
this.escape = escape$1 !== void 0 ? escape$1 : escape;
|
|
927
|
-
this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
|
|
928
|
-
this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
|
|
929
|
-
this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
|
|
930
|
-
this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
|
|
931
|
-
this.formatSeparator = formatSeparator || ",";
|
|
932
|
-
this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
|
|
933
|
-
this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
|
|
934
|
-
this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
|
|
935
|
-
this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
|
|
936
|
-
this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
|
|
937
|
-
this.maxReplaces = maxReplaces || 1e3;
|
|
938
|
-
this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
|
|
939
|
-
this.resetRegExp();
|
|
940
|
-
}
|
|
941
|
-
reset() {
|
|
942
|
-
if (this.options) this.init(this.options);
|
|
943
|
-
}
|
|
944
|
-
resetRegExp() {
|
|
945
|
-
const getOrResetRegExp = (existingRegExp, pattern) => {
|
|
946
|
-
if (existingRegExp?.source === pattern) {
|
|
947
|
-
existingRegExp.lastIndex = 0;
|
|
948
|
-
return existingRegExp;
|
|
949
|
-
}
|
|
950
|
-
return new RegExp(pattern, "g");
|
|
951
|
-
};
|
|
952
|
-
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
|
953
|
-
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
|
954
|
-
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
955
|
-
}
|
|
956
|
-
interpolate(str, data, lng, options) {
|
|
957
|
-
let match;
|
|
958
|
-
let value;
|
|
959
|
-
let replaces;
|
|
960
|
-
const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
961
|
-
const handleFormat = (key) => {
|
|
962
|
-
if (key.indexOf(this.formatSeparator) < 0) {
|
|
963
|
-
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
964
|
-
return this.alwaysFormat ? this.format(path, void 0, lng, {
|
|
965
|
-
...options,
|
|
966
|
-
...data,
|
|
967
|
-
interpolationkey: key
|
|
968
|
-
}) : path;
|
|
969
|
-
}
|
|
970
|
-
const p = key.split(this.formatSeparator);
|
|
971
|
-
const k = p.shift().trim();
|
|
972
|
-
const f = p.join(this.formatSeparator).trim();
|
|
973
|
-
return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
|
|
974
|
-
...options,
|
|
975
|
-
...data,
|
|
976
|
-
interpolationkey: k
|
|
977
|
-
});
|
|
978
|
-
};
|
|
979
|
-
this.resetRegExp();
|
|
980
|
-
const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
981
|
-
const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
982
|
-
[{
|
|
983
|
-
regex: this.regexpUnescape,
|
|
984
|
-
safeValue: (val) => regexSafe(val)
|
|
985
|
-
}, {
|
|
986
|
-
regex: this.regexp,
|
|
987
|
-
safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
|
|
988
|
-
}].forEach((todo) => {
|
|
989
|
-
replaces = 0;
|
|
990
|
-
while (match = todo.regex.exec(str)) {
|
|
991
|
-
const matchedVar = match[1].trim();
|
|
992
|
-
value = handleFormat(matchedVar);
|
|
993
|
-
if (value === void 0) if (typeof missingInterpolationHandler === "function") {
|
|
994
|
-
const temp = missingInterpolationHandler(str, match, options);
|
|
995
|
-
value = isString(temp) ? temp : "";
|
|
996
|
-
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) value = "";
|
|
997
|
-
else if (skipOnVariables) {
|
|
998
|
-
value = match[0];
|
|
999
|
-
continue;
|
|
1000
|
-
} else {
|
|
1001
|
-
this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
|
|
1002
|
-
value = "";
|
|
1003
|
-
}
|
|
1004
|
-
else if (!isString(value) && !this.useRawValueToEscape) value = makeString(value);
|
|
1005
|
-
const safeValue = todo.safeValue(value);
|
|
1006
|
-
str = str.replace(match[0], safeValue);
|
|
1007
|
-
if (skipOnVariables) {
|
|
1008
|
-
todo.regex.lastIndex += value.length;
|
|
1009
|
-
todo.regex.lastIndex -= match[0].length;
|
|
1010
|
-
} else todo.regex.lastIndex = 0;
|
|
1011
|
-
replaces++;
|
|
1012
|
-
if (replaces >= this.maxReplaces) break;
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
1015
|
-
return str;
|
|
1016
|
-
}
|
|
1017
|
-
nest(str, fc, options = {}) {
|
|
1018
|
-
let match;
|
|
1019
|
-
let value;
|
|
1020
|
-
let clonedOptions;
|
|
1021
|
-
const handleHasOptions = (key, inheritedOptions) => {
|
|
1022
|
-
const sep = this.nestingOptionsSeparator;
|
|
1023
|
-
if (key.indexOf(sep) < 0) return key;
|
|
1024
|
-
const c = key.split(new RegExp(`${sep}[ ]*{`));
|
|
1025
|
-
let optionsString = `{${c[1]}`;
|
|
1026
|
-
key = c[0];
|
|
1027
|
-
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
1028
|
-
const matchedSingleQuotes = optionsString.match(/'/g);
|
|
1029
|
-
const matchedDoubleQuotes = optionsString.match(/"/g);
|
|
1030
|
-
if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) optionsString = optionsString.replace(/'/g, "\"");
|
|
1031
|
-
try {
|
|
1032
|
-
clonedOptions = JSON.parse(optionsString);
|
|
1033
|
-
if (inheritedOptions) clonedOptions = {
|
|
1034
|
-
...inheritedOptions,
|
|
1035
|
-
...clonedOptions
|
|
1036
|
-
};
|
|
1037
|
-
} catch (e) {
|
|
1038
|
-
this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
|
|
1039
|
-
return `${key}${sep}${optionsString}`;
|
|
1040
|
-
}
|
|
1041
|
-
if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
|
|
1042
|
-
return key;
|
|
1043
|
-
};
|
|
1044
|
-
while (match = this.nestingRegexp.exec(str)) {
|
|
1045
|
-
let formatters = [];
|
|
1046
|
-
clonedOptions = { ...options };
|
|
1047
|
-
clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
1048
|
-
clonedOptions.applyPostProcessor = false;
|
|
1049
|
-
delete clonedOptions.defaultValue;
|
|
1050
|
-
const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf("}") + 1 : match[1].indexOf(this.formatSeparator);
|
|
1051
|
-
if (keyEndIndex !== -1) {
|
|
1052
|
-
formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
|
|
1053
|
-
match[1] = match[1].slice(0, keyEndIndex);
|
|
1054
|
-
}
|
|
1055
|
-
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
1056
|
-
if (value && match[0] === str && !isString(value)) return value;
|
|
1057
|
-
if (!isString(value)) value = makeString(value);
|
|
1058
|
-
if (!value) {
|
|
1059
|
-
this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
|
|
1060
|
-
value = "";
|
|
1061
|
-
}
|
|
1062
|
-
if (formatters.length) value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
|
|
1063
|
-
...options,
|
|
1064
|
-
interpolationkey: match[1].trim()
|
|
1065
|
-
}), value.trim());
|
|
1066
|
-
str = str.replace(match[0], value);
|
|
1067
|
-
this.regexp.lastIndex = 0;
|
|
1068
|
-
}
|
|
1069
|
-
return str;
|
|
1070
|
-
}
|
|
1071
|
-
};
|
|
1072
|
-
var parseFormatStr = (formatStr) => {
|
|
1073
|
-
let formatName = formatStr.toLowerCase().trim();
|
|
1074
|
-
const formatOptions = {};
|
|
1075
|
-
if (formatStr.indexOf("(") > -1) {
|
|
1076
|
-
const p = formatStr.split("(");
|
|
1077
|
-
formatName = p[0].toLowerCase().trim();
|
|
1078
|
-
const optStr = p[1].substring(0, p[1].length - 1);
|
|
1079
|
-
if (formatName === "currency" && optStr.indexOf(":") < 0) {
|
|
1080
|
-
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
1081
|
-
} else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
|
|
1082
|
-
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
|
1083
|
-
} else optStr.split(";").forEach((opt) => {
|
|
1084
|
-
if (opt) {
|
|
1085
|
-
const [key, ...rest] = opt.split(":");
|
|
1086
|
-
const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
|
|
1087
|
-
const trimmedKey = key.trim();
|
|
1088
|
-
if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
|
|
1089
|
-
if (val === "false") formatOptions[trimmedKey] = false;
|
|
1090
|
-
if (val === "true") formatOptions[trimmedKey] = true;
|
|
1091
|
-
if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
|
|
1092
|
-
}
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
return {
|
|
1096
|
-
formatName,
|
|
1097
|
-
formatOptions
|
|
1098
|
-
};
|
|
1099
|
-
};
|
|
1100
|
-
var createCachedFormatter = (fn) => {
|
|
1101
|
-
const cache = {};
|
|
1102
|
-
return (v, l, o) => {
|
|
1103
|
-
let optForCache = o;
|
|
1104
|
-
if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) optForCache = {
|
|
1105
|
-
...optForCache,
|
|
1106
|
-
[o.interpolationkey]: void 0
|
|
1107
|
-
};
|
|
1108
|
-
const key = l + JSON.stringify(optForCache);
|
|
1109
|
-
let frm = cache[key];
|
|
1110
|
-
if (!frm) {
|
|
1111
|
-
frm = fn(getCleanedCode(l), o);
|
|
1112
|
-
cache[key] = frm;
|
|
1113
|
-
}
|
|
1114
|
-
return frm(v);
|
|
1115
|
-
};
|
|
1116
|
-
};
|
|
1117
|
-
var createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
|
|
1118
|
-
var Formatter = class {
|
|
1119
|
-
constructor(options = {}) {
|
|
1120
|
-
this.logger = baseLogger.create("formatter");
|
|
1121
|
-
this.options = options;
|
|
1122
|
-
this.init(options);
|
|
1123
|
-
}
|
|
1124
|
-
init(services, options = { interpolation: {} }) {
|
|
1125
|
-
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
1126
|
-
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
1127
|
-
this.formats = {
|
|
1128
|
-
number: cf((lng, opt) => {
|
|
1129
|
-
const formatter = new Intl.NumberFormat(lng, { ...opt });
|
|
1130
|
-
return (val) => formatter.format(val);
|
|
1131
|
-
}),
|
|
1132
|
-
currency: cf((lng, opt) => {
|
|
1133
|
-
const formatter = new Intl.NumberFormat(lng, {
|
|
1134
|
-
...opt,
|
|
1135
|
-
style: "currency"
|
|
1136
|
-
});
|
|
1137
|
-
return (val) => formatter.format(val);
|
|
1138
|
-
}),
|
|
1139
|
-
datetime: cf((lng, opt) => {
|
|
1140
|
-
const formatter = new Intl.DateTimeFormat(lng, { ...opt });
|
|
1141
|
-
return (val) => formatter.format(val);
|
|
1142
|
-
}),
|
|
1143
|
-
relativetime: cf((lng, opt) => {
|
|
1144
|
-
const formatter = new Intl.RelativeTimeFormat(lng, { ...opt });
|
|
1145
|
-
return (val) => formatter.format(val, opt.range || "day");
|
|
1146
|
-
}),
|
|
1147
|
-
list: cf((lng, opt) => {
|
|
1148
|
-
const formatter = new Intl.ListFormat(lng, { ...opt });
|
|
1149
|
-
return (val) => formatter.format(val);
|
|
1150
|
-
})
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
add(name, fc) {
|
|
1154
|
-
this.formats[name.toLowerCase().trim()] = fc;
|
|
1155
|
-
}
|
|
1156
|
-
addCached(name, fc) {
|
|
1157
|
-
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1158
|
-
}
|
|
1159
|
-
format(value, format, lng, options = {}) {
|
|
1160
|
-
const formats = format.split(this.formatSeparator);
|
|
1161
|
-
if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
|
|
1162
|
-
const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
|
|
1163
|
-
formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
|
|
1164
|
-
}
|
|
1165
|
-
return formats.reduce((mem, f) => {
|
|
1166
|
-
const { formatName, formatOptions } = parseFormatStr(f);
|
|
1167
|
-
if (this.formats[formatName]) {
|
|
1168
|
-
let formatted = mem;
|
|
1169
|
-
try {
|
|
1170
|
-
const valOptions = options?.formatParams?.[options.interpolationkey] || {};
|
|
1171
|
-
const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1172
|
-
formatted = this.formats[formatName](mem, l, {
|
|
1173
|
-
...formatOptions,
|
|
1174
|
-
...options,
|
|
1175
|
-
...valOptions
|
|
1176
|
-
});
|
|
1177
|
-
} catch (error) {
|
|
1178
|
-
this.logger.warn(error);
|
|
1179
|
-
}
|
|
1180
|
-
return formatted;
|
|
1181
|
-
} else this.logger.warn(`there was no format function for ${formatName}`);
|
|
1182
|
-
return mem;
|
|
1183
|
-
}, value);
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
var removePending = (q, name) => {
|
|
1187
|
-
if (q.pending[name] !== void 0) {
|
|
1188
|
-
delete q.pending[name];
|
|
1189
|
-
q.pendingCount--;
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
1192
|
-
var Connector = class extends EventEmitter {
|
|
1193
|
-
constructor(backend, store, services, options = {}) {
|
|
1194
|
-
super();
|
|
1195
|
-
this.backend = backend;
|
|
1196
|
-
this.store = store;
|
|
1197
|
-
this.services = services;
|
|
1198
|
-
this.languageUtils = services.languageUtils;
|
|
1199
|
-
this.options = options;
|
|
1200
|
-
this.logger = baseLogger.create("backendConnector");
|
|
1201
|
-
this.waitingReads = [];
|
|
1202
|
-
this.maxParallelReads = options.maxParallelReads || 10;
|
|
1203
|
-
this.readingCalls = 0;
|
|
1204
|
-
this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
1205
|
-
this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
1206
|
-
this.state = {};
|
|
1207
|
-
this.queue = [];
|
|
1208
|
-
this.backend?.init?.(services, options.backend, options);
|
|
1209
|
-
}
|
|
1210
|
-
queueLoad(languages, namespaces, options, callback) {
|
|
1211
|
-
const toLoad = {};
|
|
1212
|
-
const pending = {};
|
|
1213
|
-
const toLoadLanguages = {};
|
|
1214
|
-
const toLoadNamespaces = {};
|
|
1215
|
-
languages.forEach((lng) => {
|
|
1216
|
-
let hasAllNamespaces = true;
|
|
1217
|
-
namespaces.forEach((ns) => {
|
|
1218
|
-
const name = `${lng}|${ns}`;
|
|
1219
|
-
if (!options.reload && this.store.hasResourceBundle(lng, ns)) this.state[name] = 2;
|
|
1220
|
-
else if (this.state[name] < 0);
|
|
1221
|
-
else if (this.state[name] === 1) {
|
|
1222
|
-
if (pending[name] === void 0) pending[name] = true;
|
|
1223
|
-
} else {
|
|
1224
|
-
this.state[name] = 1;
|
|
1225
|
-
hasAllNamespaces = false;
|
|
1226
|
-
if (pending[name] === void 0) pending[name] = true;
|
|
1227
|
-
if (toLoad[name] === void 0) toLoad[name] = true;
|
|
1228
|
-
if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
|
|
1229
|
-
}
|
|
1230
|
-
});
|
|
1231
|
-
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1232
|
-
});
|
|
1233
|
-
if (Object.keys(toLoad).length || Object.keys(pending).length) this.queue.push({
|
|
1234
|
-
pending,
|
|
1235
|
-
pendingCount: Object.keys(pending).length,
|
|
1236
|
-
loaded: {},
|
|
1237
|
-
errors: [],
|
|
1238
|
-
callback
|
|
1239
|
-
});
|
|
1240
|
-
return {
|
|
1241
|
-
toLoad: Object.keys(toLoad),
|
|
1242
|
-
pending: Object.keys(pending),
|
|
1243
|
-
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
1244
|
-
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
1245
|
-
};
|
|
1246
|
-
}
|
|
1247
|
-
loaded(name, err, data) {
|
|
1248
|
-
const s = name.split("|");
|
|
1249
|
-
const lng = s[0];
|
|
1250
|
-
const ns = s[1];
|
|
1251
|
-
if (err) this.emit("failedLoading", lng, ns, err);
|
|
1252
|
-
if (!err && data) this.store.addResourceBundle(lng, ns, data, void 0, void 0, { skipCopy: true });
|
|
1253
|
-
this.state[name] = err ? -1 : 2;
|
|
1254
|
-
if (err && data) this.state[name] = 0;
|
|
1255
|
-
const loaded = {};
|
|
1256
|
-
this.queue.forEach((q) => {
|
|
1257
|
-
pushPath(q.loaded, [lng], ns);
|
|
1258
|
-
removePending(q, name);
|
|
1259
|
-
if (err) q.errors.push(err);
|
|
1260
|
-
if (q.pendingCount === 0 && !q.done) {
|
|
1261
|
-
Object.keys(q.loaded).forEach((l) => {
|
|
1262
|
-
if (!loaded[l]) loaded[l] = {};
|
|
1263
|
-
const loadedKeys = q.loaded[l];
|
|
1264
|
-
if (loadedKeys.length) loadedKeys.forEach((n) => {
|
|
1265
|
-
if (loaded[l][n] === void 0) loaded[l][n] = true;
|
|
1266
|
-
});
|
|
1267
|
-
});
|
|
1268
|
-
q.done = true;
|
|
1269
|
-
if (q.errors.length) q.callback(q.errors);
|
|
1270
|
-
else q.callback();
|
|
1271
|
-
}
|
|
1272
|
-
});
|
|
1273
|
-
this.emit("loaded", loaded);
|
|
1274
|
-
this.queue = this.queue.filter((q) => !q.done);
|
|
1275
|
-
}
|
|
1276
|
-
read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
|
|
1277
|
-
if (!lng.length) return callback(null, {});
|
|
1278
|
-
if (this.readingCalls >= this.maxParallelReads) {
|
|
1279
|
-
this.waitingReads.push({
|
|
1280
|
-
lng,
|
|
1281
|
-
ns,
|
|
1282
|
-
fcName,
|
|
1283
|
-
tried,
|
|
1284
|
-
wait,
|
|
1285
|
-
callback
|
|
1286
|
-
});
|
|
1287
|
-
return;
|
|
1288
|
-
}
|
|
1289
|
-
this.readingCalls++;
|
|
1290
|
-
const resolver = (err, data) => {
|
|
1291
|
-
this.readingCalls--;
|
|
1292
|
-
if (this.waitingReads.length > 0) {
|
|
1293
|
-
const next = this.waitingReads.shift();
|
|
1294
|
-
this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
1295
|
-
}
|
|
1296
|
-
if (err && data && tried < this.maxRetries) {
|
|
1297
|
-
setTimeout(() => {
|
|
1298
|
-
this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
1299
|
-
}, wait);
|
|
1300
|
-
return;
|
|
1301
|
-
}
|
|
1302
|
-
callback(err, data);
|
|
1303
|
-
};
|
|
1304
|
-
const fc = this.backend[fcName].bind(this.backend);
|
|
1305
|
-
if (fc.length === 2) {
|
|
1306
|
-
try {
|
|
1307
|
-
const r = fc(lng, ns);
|
|
1308
|
-
if (r && typeof r.then === "function") r.then((data) => resolver(null, data)).catch(resolver);
|
|
1309
|
-
else resolver(null, r);
|
|
1310
|
-
} catch (err) {
|
|
1311
|
-
resolver(err);
|
|
1312
|
-
}
|
|
1313
|
-
return;
|
|
1314
|
-
}
|
|
1315
|
-
return fc(lng, ns, resolver);
|
|
1316
|
-
}
|
|
1317
|
-
prepareLoading(languages, namespaces, options = {}, callback) {
|
|
1318
|
-
if (!this.backend) {
|
|
1319
|
-
this.logger.warn("No backend was added via i18next.use. Will not load resources.");
|
|
1320
|
-
return callback && callback();
|
|
1321
|
-
}
|
|
1322
|
-
if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
|
|
1323
|
-
if (isString(namespaces)) namespaces = [namespaces];
|
|
1324
|
-
const toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
1325
|
-
if (!toLoad.toLoad.length) {
|
|
1326
|
-
if (!toLoad.pending.length) callback();
|
|
1327
|
-
return null;
|
|
1328
|
-
}
|
|
1329
|
-
toLoad.toLoad.forEach((name) => {
|
|
1330
|
-
this.loadOne(name);
|
|
1331
|
-
});
|
|
1332
|
-
}
|
|
1333
|
-
load(languages, namespaces, callback) {
|
|
1334
|
-
this.prepareLoading(languages, namespaces, {}, callback);
|
|
1335
|
-
}
|
|
1336
|
-
reload(languages, namespaces, callback) {
|
|
1337
|
-
this.prepareLoading(languages, namespaces, { reload: true }, callback);
|
|
1338
|
-
}
|
|
1339
|
-
loadOne(name, prefix = "") {
|
|
1340
|
-
const s = name.split("|");
|
|
1341
|
-
const lng = s[0];
|
|
1342
|
-
const ns = s[1];
|
|
1343
|
-
this.read(lng, ns, "read", void 0, void 0, (err, data) => {
|
|
1344
|
-
if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
|
|
1345
|
-
if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
|
|
1346
|
-
this.loaded(name, err, data);
|
|
1347
|
-
});
|
|
1348
|
-
}
|
|
1349
|
-
saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
|
|
1350
|
-
if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
|
|
1351
|
-
this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
1352
|
-
return;
|
|
1353
|
-
}
|
|
1354
|
-
if (key === void 0 || key === null || key === "") return;
|
|
1355
|
-
if (this.backend?.create) {
|
|
1356
|
-
const opts = {
|
|
1357
|
-
...options,
|
|
1358
|
-
isUpdate
|
|
1359
|
-
};
|
|
1360
|
-
const fc = this.backend.create.bind(this.backend);
|
|
1361
|
-
if (fc.length < 6) try {
|
|
1362
|
-
let r;
|
|
1363
|
-
if (fc.length === 5) r = fc(languages, namespace, key, fallbackValue, opts);
|
|
1364
|
-
else r = fc(languages, namespace, key, fallbackValue);
|
|
1365
|
-
if (r && typeof r.then === "function") r.then((data) => clb(null, data)).catch(clb);
|
|
1366
|
-
else clb(null, r);
|
|
1367
|
-
} catch (err) {
|
|
1368
|
-
clb(err);
|
|
1369
|
-
}
|
|
1370
|
-
else fc(languages, namespace, key, fallbackValue, clb, opts);
|
|
1371
|
-
}
|
|
1372
|
-
if (!languages || !languages[0]) return;
|
|
1373
|
-
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
1376
|
-
var get = () => ({
|
|
1377
|
-
debug: false,
|
|
1378
|
-
initAsync: true,
|
|
1379
|
-
ns: ["translation"],
|
|
1380
|
-
defaultNS: ["translation"],
|
|
1381
|
-
fallbackLng: ["dev"],
|
|
1382
|
-
fallbackNS: false,
|
|
1383
|
-
supportedLngs: false,
|
|
1384
|
-
nonExplicitSupportedLngs: false,
|
|
1385
|
-
load: "all",
|
|
1386
|
-
preload: false,
|
|
1387
|
-
simplifyPluralSuffix: true,
|
|
1388
|
-
keySeparator: ".",
|
|
1389
|
-
nsSeparator: ":",
|
|
1390
|
-
pluralSeparator: "_",
|
|
1391
|
-
contextSeparator: "_",
|
|
1392
|
-
partialBundledLanguages: false,
|
|
1393
|
-
saveMissing: false,
|
|
1394
|
-
updateMissing: false,
|
|
1395
|
-
saveMissingTo: "fallback",
|
|
1396
|
-
saveMissingPlurals: true,
|
|
1397
|
-
missingKeyHandler: false,
|
|
1398
|
-
missingInterpolationHandler: false,
|
|
1399
|
-
postProcess: false,
|
|
1400
|
-
postProcessPassResolved: false,
|
|
1401
|
-
returnNull: false,
|
|
1402
|
-
returnEmptyString: true,
|
|
1403
|
-
returnObjects: false,
|
|
1404
|
-
joinArrays: false,
|
|
1405
|
-
returnedObjectHandler: false,
|
|
1406
|
-
parseMissingKeyHandler: false,
|
|
1407
|
-
appendNamespaceToMissingKey: false,
|
|
1408
|
-
appendNamespaceToCIMode: false,
|
|
1409
|
-
overloadTranslationOptionHandler: (args) => {
|
|
1410
|
-
let ret = {};
|
|
1411
|
-
if (typeof args[1] === "object") ret = args[1];
|
|
1412
|
-
if (isString(args[1])) ret.defaultValue = args[1];
|
|
1413
|
-
if (isString(args[2])) ret.tDescription = args[2];
|
|
1414
|
-
if (typeof args[2] === "object" || typeof args[3] === "object") {
|
|
1415
|
-
const options = args[3] || args[2];
|
|
1416
|
-
Object.keys(options).forEach((key) => {
|
|
1417
|
-
ret[key] = options[key];
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
return ret;
|
|
1421
|
-
},
|
|
1422
|
-
interpolation: {
|
|
1423
|
-
escapeValue: true,
|
|
1424
|
-
format: (value) => value,
|
|
1425
|
-
prefix: "{{",
|
|
1426
|
-
suffix: "}}",
|
|
1427
|
-
formatSeparator: ",",
|
|
1428
|
-
unescapePrefix: "-",
|
|
1429
|
-
nestingPrefix: "$t(",
|
|
1430
|
-
nestingSuffix: ")",
|
|
1431
|
-
nestingOptionsSeparator: ",",
|
|
1432
|
-
maxReplaces: 1e3,
|
|
1433
|
-
skipOnVariables: true
|
|
1434
|
-
},
|
|
1435
|
-
cacheInBuiltFormats: true
|
|
1436
|
-
});
|
|
1437
|
-
var transformOptions = (options) => {
|
|
1438
|
-
if (isString(options.ns)) options.ns = [options.ns];
|
|
1439
|
-
if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
|
|
1440
|
-
if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
|
|
1441
|
-
if (options.supportedLngs?.indexOf?.("cimode") < 0) options.supportedLngs = options.supportedLngs.concat(["cimode"]);
|
|
1442
|
-
if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
|
|
1443
|
-
return options;
|
|
1444
|
-
};
|
|
1445
|
-
var noop = () => {};
|
|
1446
|
-
var bindMemberFunctions = (inst) => {
|
|
1447
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(inst)).forEach((mem) => {
|
|
1448
|
-
if (typeof inst[mem] === "function") inst[mem] = inst[mem].bind(inst);
|
|
1449
|
-
});
|
|
1450
|
-
};
|
|
1451
|
-
var instance = class I18n extends EventEmitter {
|
|
1452
|
-
constructor(options = {}, callback) {
|
|
1453
|
-
super();
|
|
1454
|
-
this.options = transformOptions(options);
|
|
1455
|
-
this.services = {};
|
|
1456
|
-
this.logger = baseLogger;
|
|
1457
|
-
this.modules = { external: [] };
|
|
1458
|
-
bindMemberFunctions(this);
|
|
1459
|
-
if (callback && !this.isInitialized && !options.isClone) {
|
|
1460
|
-
if (!this.options.initAsync) {
|
|
1461
|
-
this.init(options, callback);
|
|
1462
|
-
return this;
|
|
1463
|
-
}
|
|
1464
|
-
setTimeout(() => {
|
|
1465
|
-
this.init(options, callback);
|
|
1466
|
-
}, 0);
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
init(options = {}, callback) {
|
|
1470
|
-
this.isInitializing = true;
|
|
1471
|
-
if (typeof options === "function") {
|
|
1472
|
-
callback = options;
|
|
1473
|
-
options = {};
|
|
1474
|
-
}
|
|
1475
|
-
if (options.defaultNS == null && options.ns) {
|
|
1476
|
-
if (isString(options.ns)) options.defaultNS = options.ns;
|
|
1477
|
-
else if (options.ns.indexOf("translation") < 0) options.defaultNS = options.ns[0];
|
|
1478
|
-
}
|
|
1479
|
-
const defOpts = get();
|
|
1480
|
-
this.options = {
|
|
1481
|
-
...defOpts,
|
|
1482
|
-
...this.options,
|
|
1483
|
-
...transformOptions(options)
|
|
1484
|
-
};
|
|
1485
|
-
this.options.interpolation = {
|
|
1486
|
-
...defOpts.interpolation,
|
|
1487
|
-
...this.options.interpolation
|
|
1488
|
-
};
|
|
1489
|
-
if (options.keySeparator !== void 0) this.options.userDefinedKeySeparator = options.keySeparator;
|
|
1490
|
-
if (options.nsSeparator !== void 0) this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
1491
|
-
const createClassOnDemand = (ClassOrObject) => {
|
|
1492
|
-
if (!ClassOrObject) return null;
|
|
1493
|
-
if (typeof ClassOrObject === "function") return new ClassOrObject();
|
|
1494
|
-
return ClassOrObject;
|
|
1495
|
-
};
|
|
1496
|
-
if (!this.options.isClone) {
|
|
1497
|
-
if (this.modules.logger) baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
1498
|
-
else baseLogger.init(null, this.options);
|
|
1499
|
-
let formatter;
|
|
1500
|
-
if (this.modules.formatter) formatter = this.modules.formatter;
|
|
1501
|
-
else formatter = Formatter;
|
|
1502
|
-
const lu = new LanguageUtil(this.options);
|
|
1503
|
-
this.store = new ResourceStore(this.options.resources, this.options);
|
|
1504
|
-
const s = this.services;
|
|
1505
|
-
s.logger = baseLogger;
|
|
1506
|
-
s.resourceStore = this.store;
|
|
1507
|
-
s.languageUtils = lu;
|
|
1508
|
-
s.pluralResolver = new PluralResolver(lu, {
|
|
1509
|
-
prepend: this.options.pluralSeparator,
|
|
1510
|
-
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1511
|
-
});
|
|
1512
|
-
if (this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format) this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
|
|
1513
|
-
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
1514
|
-
s.formatter = createClassOnDemand(formatter);
|
|
1515
|
-
if (s.formatter.init) s.formatter.init(s, this.options);
|
|
1516
|
-
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
1517
|
-
}
|
|
1518
|
-
s.interpolator = new Interpolator(this.options);
|
|
1519
|
-
s.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) };
|
|
1520
|
-
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
1521
|
-
s.backendConnector.on("*", (event, ...args) => {
|
|
1522
|
-
this.emit(event, ...args);
|
|
1523
|
-
});
|
|
1524
|
-
if (this.modules.languageDetector) {
|
|
1525
|
-
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
1526
|
-
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
|
1527
|
-
}
|
|
1528
|
-
if (this.modules.i18nFormat) {
|
|
1529
|
-
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
1530
|
-
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
|
1531
|
-
}
|
|
1532
|
-
this.translator = new Translator(this.services, this.options);
|
|
1533
|
-
this.translator.on("*", (event, ...args) => {
|
|
1534
|
-
this.emit(event, ...args);
|
|
1535
|
-
});
|
|
1536
|
-
this.modules.external.forEach((m) => {
|
|
1537
|
-
if (m.init) m.init(this);
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
this.format = this.options.interpolation.format;
|
|
1541
|
-
if (!callback) callback = noop;
|
|
1542
|
-
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1543
|
-
const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1544
|
-
if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
|
|
1545
|
-
}
|
|
1546
|
-
if (!this.services.languageDetector && !this.options.lng) this.logger.warn("init: no languageDetector is used and no lng is defined");
|
|
1547
|
-
[
|
|
1548
|
-
"getResource",
|
|
1549
|
-
"hasResourceBundle",
|
|
1550
|
-
"getResourceBundle",
|
|
1551
|
-
"getDataByLanguage"
|
|
1552
|
-
].forEach((fcName) => {
|
|
1553
|
-
this[fcName] = (...args) => this.store[fcName](...args);
|
|
1554
|
-
});
|
|
1555
|
-
[
|
|
1556
|
-
"addResource",
|
|
1557
|
-
"addResources",
|
|
1558
|
-
"addResourceBundle",
|
|
1559
|
-
"removeResourceBundle"
|
|
1560
|
-
].forEach((fcName) => {
|
|
1561
|
-
this[fcName] = (...args) => {
|
|
1562
|
-
this.store[fcName](...args);
|
|
1563
|
-
return this;
|
|
1564
|
-
};
|
|
1565
|
-
});
|
|
1566
|
-
const deferred = defer();
|
|
1567
|
-
const load = () => {
|
|
1568
|
-
const finish = (err, t) => {
|
|
1569
|
-
this.isInitializing = false;
|
|
1570
|
-
if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
|
|
1571
|
-
this.isInitialized = true;
|
|
1572
|
-
if (!this.options.isClone) this.logger.log("initialized", this.options);
|
|
1573
|
-
this.emit("initialized", this.options);
|
|
1574
|
-
deferred.resolve(t);
|
|
1575
|
-
callback(err, t);
|
|
1576
|
-
};
|
|
1577
|
-
if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
|
|
1578
|
-
this.changeLanguage(this.options.lng, finish);
|
|
1579
|
-
};
|
|
1580
|
-
if (this.options.resources || !this.options.initAsync) load();
|
|
1581
|
-
else setTimeout(load, 0);
|
|
1582
|
-
return deferred;
|
|
1583
|
-
}
|
|
1584
|
-
loadResources(language, callback = noop) {
|
|
1585
|
-
let usedCallback = callback;
|
|
1586
|
-
const usedLng = isString(language) ? language : this.language;
|
|
1587
|
-
if (typeof language === "function") usedCallback = language;
|
|
1588
|
-
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
1589
|
-
if (usedLng?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
|
|
1590
|
-
const toLoad = [];
|
|
1591
|
-
const append = (lng) => {
|
|
1592
|
-
if (!lng) return;
|
|
1593
|
-
if (lng === "cimode") return;
|
|
1594
|
-
this.services.languageUtils.toResolveHierarchy(lng).forEach((l) => {
|
|
1595
|
-
if (l === "cimode") return;
|
|
1596
|
-
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
|
1597
|
-
});
|
|
1598
|
-
};
|
|
1599
|
-
if (!usedLng) this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => append(l));
|
|
1600
|
-
else append(usedLng);
|
|
1601
|
-
this.options.preload?.forEach?.((l) => append(l));
|
|
1602
|
-
this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
|
|
1603
|
-
if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
|
|
1604
|
-
usedCallback(e);
|
|
1605
|
-
});
|
|
1606
|
-
} else usedCallback(null);
|
|
1607
|
-
}
|
|
1608
|
-
reloadResources(lngs, ns, callback) {
|
|
1609
|
-
const deferred = defer();
|
|
1610
|
-
if (typeof lngs === "function") {
|
|
1611
|
-
callback = lngs;
|
|
1612
|
-
lngs = void 0;
|
|
1613
|
-
}
|
|
1614
|
-
if (typeof ns === "function") {
|
|
1615
|
-
callback = ns;
|
|
1616
|
-
ns = void 0;
|
|
1617
|
-
}
|
|
1618
|
-
if (!lngs) lngs = this.languages;
|
|
1619
|
-
if (!ns) ns = this.options.ns;
|
|
1620
|
-
if (!callback) callback = noop;
|
|
1621
|
-
this.services.backendConnector.reload(lngs, ns, (err) => {
|
|
1622
|
-
deferred.resolve();
|
|
1623
|
-
callback(err);
|
|
1624
|
-
});
|
|
1625
|
-
return deferred;
|
|
1626
|
-
}
|
|
1627
|
-
use(module) {
|
|
1628
|
-
if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1629
|
-
if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1630
|
-
if (module.type === "backend") this.modules.backend = module;
|
|
1631
|
-
if (module.type === "logger" || module.log && module.warn && module.error) this.modules.logger = module;
|
|
1632
|
-
if (module.type === "languageDetector") this.modules.languageDetector = module;
|
|
1633
|
-
if (module.type === "i18nFormat") this.modules.i18nFormat = module;
|
|
1634
|
-
if (module.type === "postProcessor") postProcessor.addPostProcessor(module);
|
|
1635
|
-
if (module.type === "formatter") this.modules.formatter = module;
|
|
1636
|
-
if (module.type === "3rdParty") this.modules.external.push(module);
|
|
1637
|
-
return this;
|
|
1638
|
-
}
|
|
1639
|
-
setResolvedLanguage(l) {
|
|
1640
|
-
if (!l || !this.languages) return;
|
|
1641
|
-
if (["cimode", "dev"].indexOf(l) > -1) return;
|
|
1642
|
-
for (let li = 0; li < this.languages.length; li++) {
|
|
1643
|
-
const lngInLngs = this.languages[li];
|
|
1644
|
-
if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
|
|
1645
|
-
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
1646
|
-
this.resolvedLanguage = lngInLngs;
|
|
1647
|
-
break;
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
|
|
1651
|
-
this.resolvedLanguage = l;
|
|
1652
|
-
this.languages.unshift(l);
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
changeLanguage(lng, callback) {
|
|
1656
|
-
this.isLanguageChangingTo = lng;
|
|
1657
|
-
const deferred = defer();
|
|
1658
|
-
this.emit("languageChanging", lng);
|
|
1659
|
-
const setLngProps = (l) => {
|
|
1660
|
-
this.language = l;
|
|
1661
|
-
this.languages = this.services.languageUtils.toResolveHierarchy(l);
|
|
1662
|
-
this.resolvedLanguage = void 0;
|
|
1663
|
-
this.setResolvedLanguage(l);
|
|
1664
|
-
};
|
|
1665
|
-
const done = (err, l) => {
|
|
1666
|
-
if (l) {
|
|
1667
|
-
if (this.isLanguageChangingTo === lng) {
|
|
1668
|
-
setLngProps(l);
|
|
1669
|
-
this.translator.changeLanguage(l);
|
|
1670
|
-
this.isLanguageChangingTo = void 0;
|
|
1671
|
-
this.emit("languageChanged", l);
|
|
1672
|
-
this.logger.log("languageChanged", l);
|
|
1673
|
-
}
|
|
1674
|
-
} else this.isLanguageChangingTo = void 0;
|
|
1675
|
-
deferred.resolve((...args) => this.t(...args));
|
|
1676
|
-
if (callback) callback(err, (...args) => this.t(...args));
|
|
1677
|
-
};
|
|
1678
|
-
const setLng = (lngs) => {
|
|
1679
|
-
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
|
1680
|
-
const fl = isString(lngs) ? lngs : lngs && lngs[0];
|
|
1681
|
-
const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
|
|
1682
|
-
if (l) {
|
|
1683
|
-
if (!this.language) setLngProps(l);
|
|
1684
|
-
if (!this.translator.language) this.translator.changeLanguage(l);
|
|
1685
|
-
this.services.languageDetector?.cacheUserLanguage?.(l);
|
|
1686
|
-
}
|
|
1687
|
-
this.loadResources(l, (err) => {
|
|
1688
|
-
done(err, l);
|
|
1689
|
-
});
|
|
1690
|
-
};
|
|
1691
|
-
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) setLng(this.services.languageDetector.detect());
|
|
1692
|
-
else if (!lng && this.services.languageDetector && this.services.languageDetector.async) if (this.services.languageDetector.detect.length === 0) this.services.languageDetector.detect().then(setLng);
|
|
1693
|
-
else this.services.languageDetector.detect(setLng);
|
|
1694
|
-
else setLng(lng);
|
|
1695
|
-
return deferred;
|
|
1696
|
-
}
|
|
1697
|
-
getFixedT(lng, ns, keyPrefix) {
|
|
1698
|
-
const fixedT = (key, opts, ...rest) => {
|
|
1699
|
-
let o;
|
|
1700
|
-
if (typeof opts !== "object") o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
1701
|
-
else o = { ...opts };
|
|
1702
|
-
o.lng = o.lng || fixedT.lng;
|
|
1703
|
-
o.lngs = o.lngs || fixedT.lngs;
|
|
1704
|
-
o.ns = o.ns || fixedT.ns;
|
|
1705
|
-
if (o.keyPrefix !== "") o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
1706
|
-
const keySeparator = this.options.keySeparator || ".";
|
|
1707
|
-
let resultKey;
|
|
1708
|
-
if (o.keyPrefix && Array.isArray(key)) resultKey = key.map((k) => {
|
|
1709
|
-
if (typeof k === "function") k = keysFromSelector(k, {
|
|
1710
|
-
...this.options,
|
|
1711
|
-
...opts
|
|
1712
|
-
});
|
|
1713
|
-
return `${o.keyPrefix}${keySeparator}${k}`;
|
|
1714
|
-
});
|
|
1715
|
-
else {
|
|
1716
|
-
if (typeof key === "function") key = keysFromSelector(key, {
|
|
1717
|
-
...this.options,
|
|
1718
|
-
...opts
|
|
1719
|
-
});
|
|
1720
|
-
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
|
1721
|
-
}
|
|
1722
|
-
return this.t(resultKey, o);
|
|
1723
|
-
};
|
|
1724
|
-
if (isString(lng)) fixedT.lng = lng;
|
|
1725
|
-
else fixedT.lngs = lng;
|
|
1726
|
-
fixedT.ns = ns;
|
|
1727
|
-
fixedT.keyPrefix = keyPrefix;
|
|
1728
|
-
return fixedT;
|
|
1729
|
-
}
|
|
1730
|
-
t(...args) {
|
|
1731
|
-
return this.translator?.translate(...args);
|
|
1732
|
-
}
|
|
1733
|
-
exists(...args) {
|
|
1734
|
-
return this.translator?.exists(...args);
|
|
1735
|
-
}
|
|
1736
|
-
setDefaultNamespace(ns) {
|
|
1737
|
-
this.options.defaultNS = ns;
|
|
1738
|
-
}
|
|
1739
|
-
hasLoadedNamespace(ns, options = {}) {
|
|
1740
|
-
if (!this.isInitialized) {
|
|
1741
|
-
this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
|
|
1742
|
-
return false;
|
|
1743
|
-
}
|
|
1744
|
-
if (!this.languages || !this.languages.length) {
|
|
1745
|
-
this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
|
|
1746
|
-
return false;
|
|
1747
|
-
}
|
|
1748
|
-
const lng = options.lng || this.resolvedLanguage || this.languages[0];
|
|
1749
|
-
const fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
1750
|
-
const lastLng = this.languages[this.languages.length - 1];
|
|
1751
|
-
if (lng.toLowerCase() === "cimode") return true;
|
|
1752
|
-
const loadNotPending = (l, n) => {
|
|
1753
|
-
const loadState = this.services.backendConnector.state[`${l}|${n}`];
|
|
1754
|
-
return loadState === -1 || loadState === 0 || loadState === 2;
|
|
1755
|
-
};
|
|
1756
|
-
if (options.precheck) {
|
|
1757
|
-
const preResult = options.precheck(this, loadNotPending);
|
|
1758
|
-
if (preResult !== void 0) return preResult;
|
|
1759
|
-
}
|
|
1760
|
-
if (this.hasResourceBundle(lng, ns)) return true;
|
|
1761
|
-
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
|
1762
|
-
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
1763
|
-
return false;
|
|
1764
|
-
}
|
|
1765
|
-
loadNamespaces(ns, callback) {
|
|
1766
|
-
const deferred = defer();
|
|
1767
|
-
if (!this.options.ns) {
|
|
1768
|
-
if (callback) callback();
|
|
1769
|
-
return Promise.resolve();
|
|
1770
|
-
}
|
|
1771
|
-
if (isString(ns)) ns = [ns];
|
|
1772
|
-
ns.forEach((n) => {
|
|
1773
|
-
if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
|
|
1774
|
-
});
|
|
1775
|
-
this.loadResources((err) => {
|
|
1776
|
-
deferred.resolve();
|
|
1777
|
-
if (callback) callback(err);
|
|
1778
|
-
});
|
|
1779
|
-
return deferred;
|
|
1780
|
-
}
|
|
1781
|
-
loadLanguages(lngs, callback) {
|
|
1782
|
-
const deferred = defer();
|
|
1783
|
-
if (isString(lngs)) lngs = [lngs];
|
|
1784
|
-
const preloaded = this.options.preload || [];
|
|
1785
|
-
const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
|
|
1786
|
-
if (!newLngs.length) {
|
|
1787
|
-
if (callback) callback();
|
|
1788
|
-
return Promise.resolve();
|
|
1789
|
-
}
|
|
1790
|
-
this.options.preload = preloaded.concat(newLngs);
|
|
1791
|
-
this.loadResources((err) => {
|
|
1792
|
-
deferred.resolve();
|
|
1793
|
-
if (callback) callback(err);
|
|
1794
|
-
});
|
|
1795
|
-
return deferred;
|
|
1796
|
-
}
|
|
1797
|
-
dir(lng) {
|
|
1798
|
-
if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
|
|
1799
|
-
if (!lng) return "rtl";
|
|
1800
|
-
try {
|
|
1801
|
-
const l = new Intl.Locale(lng);
|
|
1802
|
-
if (l && l.getTextInfo) {
|
|
1803
|
-
const ti = l.getTextInfo();
|
|
1804
|
-
if (ti && ti.direction) return ti.direction;
|
|
1805
|
-
}
|
|
1806
|
-
} catch (e) {}
|
|
1807
|
-
const rtlLngs = [
|
|
1808
|
-
"ar",
|
|
1809
|
-
"shu",
|
|
1810
|
-
"sqr",
|
|
1811
|
-
"ssh",
|
|
1812
|
-
"xaa",
|
|
1813
|
-
"yhd",
|
|
1814
|
-
"yud",
|
|
1815
|
-
"aao",
|
|
1816
|
-
"abh",
|
|
1817
|
-
"abv",
|
|
1818
|
-
"acm",
|
|
1819
|
-
"acq",
|
|
1820
|
-
"acw",
|
|
1821
|
-
"acx",
|
|
1822
|
-
"acy",
|
|
1823
|
-
"adf",
|
|
1824
|
-
"ads",
|
|
1825
|
-
"aeb",
|
|
1826
|
-
"aec",
|
|
1827
|
-
"afb",
|
|
1828
|
-
"ajp",
|
|
1829
|
-
"apc",
|
|
1830
|
-
"apd",
|
|
1831
|
-
"arb",
|
|
1832
|
-
"arq",
|
|
1833
|
-
"ars",
|
|
1834
|
-
"ary",
|
|
1835
|
-
"arz",
|
|
1836
|
-
"auz",
|
|
1837
|
-
"avl",
|
|
1838
|
-
"ayh",
|
|
1839
|
-
"ayl",
|
|
1840
|
-
"ayn",
|
|
1841
|
-
"ayp",
|
|
1842
|
-
"bbz",
|
|
1843
|
-
"pga",
|
|
1844
|
-
"he",
|
|
1845
|
-
"iw",
|
|
1846
|
-
"ps",
|
|
1847
|
-
"pbt",
|
|
1848
|
-
"pbu",
|
|
1849
|
-
"pst",
|
|
1850
|
-
"prp",
|
|
1851
|
-
"prd",
|
|
1852
|
-
"ug",
|
|
1853
|
-
"ur",
|
|
1854
|
-
"ydd",
|
|
1855
|
-
"yds",
|
|
1856
|
-
"yih",
|
|
1857
|
-
"ji",
|
|
1858
|
-
"yi",
|
|
1859
|
-
"hbo",
|
|
1860
|
-
"men",
|
|
1861
|
-
"xmn",
|
|
1862
|
-
"fa",
|
|
1863
|
-
"jpr",
|
|
1864
|
-
"peo",
|
|
1865
|
-
"pes",
|
|
1866
|
-
"prs",
|
|
1867
|
-
"dv",
|
|
1868
|
-
"sam",
|
|
1869
|
-
"ckb"
|
|
1870
|
-
];
|
|
1871
|
-
const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
|
|
1872
|
-
if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
|
|
1873
|
-
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1874
|
-
}
|
|
1875
|
-
static createInstance(options = {}, callback) {
|
|
1876
|
-
const instance = new I18n(options, callback);
|
|
1877
|
-
instance.createInstance = I18n.createInstance;
|
|
1878
|
-
return instance;
|
|
1879
|
-
}
|
|
1880
|
-
cloneInstance(options = {}, callback = noop) {
|
|
1881
|
-
const forkResourceStore = options.forkResourceStore;
|
|
1882
|
-
if (forkResourceStore) delete options.forkResourceStore;
|
|
1883
|
-
const mergedOptions = {
|
|
1884
|
-
...this.options,
|
|
1885
|
-
...options,
|
|
1886
|
-
isClone: true
|
|
1887
|
-
};
|
|
1888
|
-
const clone = new I18n(mergedOptions);
|
|
1889
|
-
if (options.debug !== void 0 || options.prefix !== void 0) clone.logger = clone.logger.clone(options);
|
|
1890
|
-
[
|
|
1891
|
-
"store",
|
|
1892
|
-
"services",
|
|
1893
|
-
"language"
|
|
1894
|
-
].forEach((m) => {
|
|
1895
|
-
clone[m] = this[m];
|
|
1896
|
-
});
|
|
1897
|
-
clone.services = { ...this.services };
|
|
1898
|
-
clone.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
|
|
1899
|
-
if (forkResourceStore) {
|
|
1900
|
-
clone.store = new ResourceStore(Object.keys(this.store.data).reduce((prev, l) => {
|
|
1901
|
-
prev[l] = { ...this.store.data[l] };
|
|
1902
|
-
prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
|
|
1903
|
-
acc[n] = { ...prev[l][n] };
|
|
1904
|
-
return acc;
|
|
1905
|
-
}, prev[l]);
|
|
1906
|
-
return prev;
|
|
1907
|
-
}, {}), mergedOptions);
|
|
1908
|
-
clone.services.resourceStore = clone.store;
|
|
1909
|
-
}
|
|
1910
|
-
if (options.interpolation) clone.services.interpolator = new Interpolator(mergedOptions);
|
|
1911
|
-
clone.translator = new Translator(clone.services, mergedOptions);
|
|
1912
|
-
clone.translator.on("*", (event, ...args) => {
|
|
1913
|
-
clone.emit(event, ...args);
|
|
1914
|
-
});
|
|
1915
|
-
clone.init(mergedOptions, callback);
|
|
1916
|
-
clone.translator.options = mergedOptions;
|
|
1917
|
-
clone.translator.backendConnector.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
|
|
1918
|
-
return clone;
|
|
1919
|
-
}
|
|
1920
|
-
toJSON() {
|
|
1921
|
-
return {
|
|
1922
|
-
options: this.options,
|
|
1923
|
-
store: this.store,
|
|
1924
|
-
language: this.language,
|
|
1925
|
-
languages: this.languages,
|
|
1926
|
-
resolvedLanguage: this.resolvedLanguage
|
|
1927
|
-
};
|
|
1928
|
-
}
|
|
1929
|
-
}.createInstance();
|
|
1930
|
-
instance.createInstance;
|
|
1931
|
-
instance.dir;
|
|
1932
|
-
instance.init;
|
|
1933
|
-
instance.loadResources;
|
|
1934
|
-
instance.reloadResources;
|
|
1935
|
-
instance.use;
|
|
1936
|
-
instance.changeLanguage;
|
|
1937
|
-
instance.getFixedT;
|
|
1938
|
-
instance.t;
|
|
1939
|
-
instance.exists;
|
|
1940
|
-
instance.setDefaultNamespace;
|
|
1941
|
-
instance.hasLoadedNamespace;
|
|
1942
|
-
instance.loadNamespaces;
|
|
1943
|
-
instance.loadLanguages;
|
|
1944
|
-
//#endregion
|
|
1945
|
-
//#region src/i18n/bundledTranslationLoaders.ts
|
|
1946
|
-
var bundledTranslationLoaders = {
|
|
1947
|
-
"en": () => import("./en-CJ6l68pH.js"),
|
|
1948
|
-
"en-DG": () => import("./en-DG-Cvwm0nfj.js"),
|
|
1949
|
-
"es": () => import("./es-rayGAvsH.js"),
|
|
1950
|
-
"es-ES": () => import("./es-ES-B8h3jMgN.js"),
|
|
1951
|
-
"sr": () => import("./sr-D0lglPAd.js"),
|
|
1952
|
-
"sr-Latn": () => import("./sr-Latn-Dy2rgSEv.js"),
|
|
1953
|
-
"fr": () => import("./fr-DtdqfaF8.js"),
|
|
1954
|
-
"pt-BR": () => import("./pt-BR-BkLAWIbx.js"),
|
|
1955
|
-
"pt": () => import("./pt-EmaaUJGm.js"),
|
|
1956
|
-
"bn": () => import("./bn-BfE2MHPG.js"),
|
|
1957
|
-
"zh": () => import("./zh-Ct8GKGhw.js"),
|
|
1958
|
-
"hi": () => import("./hi-DIbkmie6.js"),
|
|
1959
|
-
"id": () => import("./id-C5eOEjgu.js"),
|
|
1960
|
-
"ms": () => import("./ms-D_FFGDor.js"),
|
|
1961
|
-
"tr": () => import("./tr-C1MJnwIJ.js"),
|
|
1962
|
-
"vi": () => import("./vi-DRfsxu1a.js"),
|
|
1963
|
-
"ht": () => import("./ht-DgaboG3c.js"),
|
|
1964
|
-
"it": () => import("./it-CQGuLrxZ.js"),
|
|
1965
|
-
"de": () => import("./de-B0IRPjwJ.js"),
|
|
1966
|
-
"nl": () => import("./nl-DGyLucC1.js"),
|
|
1967
|
-
"tl-PH": () => import("./tl-PH-BJJNA9rs.js"),
|
|
1968
|
-
"pl": () => import("./pl-nEtI_VZQ.js"),
|
|
1969
|
-
"hu": () => import("./hu-Lz2qVC3S.js"),
|
|
1970
|
-
"ro": () => import("./ro-BKmZhZl1.js"),
|
|
1971
|
-
"hmn": () => import("./hmn-CscGik4W.js"),
|
|
1972
|
-
"so": () => import("./so-D3T7YyfC.js"),
|
|
1973
|
-
"ca": () => import("./ca-yJUG5zqw.js"),
|
|
1974
|
-
"af-ZA": () => import("./af-ZA-BbU0OdlG.js"),
|
|
1975
|
-
"ar": () => import("./ar-Ba-wMBXP.js"),
|
|
1976
|
-
"ar-EG": () => import("./ar-EG-C9FVwsEB.js"),
|
|
1977
|
-
"ar-AE": () => import("./ar-AE-Bdk7NfI2.js"),
|
|
1978
|
-
"zh-CN": () => import("./zh-CN-DMfj1_Nh.js"),
|
|
1979
|
-
"zh-TW": () => import("./zh-TW-8wkrOHM8.js"),
|
|
1980
|
-
"zh-HANT": () => import("./zh-HANT-NZFdeKuE.js"),
|
|
1981
|
-
"cs-CZ": () => import("./cs-CZ-B9jWzmE_.js"),
|
|
1982
|
-
"da-DK": () => import("./da-DK-C0l5MGWM.js"),
|
|
1983
|
-
"fi-FI": () => import("./fi-FI-CcFDkeiE.js"),
|
|
1984
|
-
"fr-CA": () => import("./fr-CA-CeL7RQc-.js"),
|
|
1985
|
-
"el-GR": () => import("./el-GR-BZEKLkvc.js"),
|
|
1986
|
-
"he": () => import("./he-CPeNHo0I.js"),
|
|
1987
|
-
"ja": () => import("./ja-CBD-jOkP.js"),
|
|
1988
|
-
"ja-JP": () => import("./ja-JP-Dgbzh2aL.js"),
|
|
1989
|
-
"ko-KP": () => import("./ko-KP-BSjl3hdX.js"),
|
|
1990
|
-
"nb-NO": () => import("./nb-NO-oEMuavpl.js"),
|
|
1991
|
-
"fa-IR": () => import("./fa-IR-DfrzWcH0.js"),
|
|
1992
|
-
"pt-PT": () => import("./pt-PT-Py_4_Z05.js"),
|
|
1993
|
-
"ru-RU": () => import("./ru-RU-BdhCs3uF.js"),
|
|
1994
|
-
"sr-YU": () => import("./sr-YU-UEhyvXZ-.js"),
|
|
1995
|
-
"es-419": () => import("./es-419-DlCbbvcc.js"),
|
|
1996
|
-
"es-MX": () => import("./es-MX-DA__jQOC.js"),
|
|
1997
|
-
"sv-SE": () => import("./sv-SE-VsDd4VP5.js"),
|
|
1998
|
-
"th-TH": () => import("./th-TH-BU_NqN97.js"),
|
|
1999
|
-
"uk-UA": () => import("./uk-UA-3o9Xbam-.js"),
|
|
2000
|
-
"am": () => import("./am-BuvQtV50.js"),
|
|
2001
|
-
"az": () => import("./az-DHRJfgCV.js"),
|
|
2002
|
-
"bs": () => import("./bs-Ck9dCVYh.js"),
|
|
2003
|
-
"my": () => import("./my-D1JKF20F.js"),
|
|
2004
|
-
"ceb": () => import("./ceb-oov4R9JM.js"),
|
|
2005
|
-
"cs": () => import("./cs-ovOFxGB0.js"),
|
|
2006
|
-
"et": () => import("./et-DvX7tm-R.js"),
|
|
2007
|
-
"ka": () => import("./ka-CcCqDmzw.js"),
|
|
2008
|
-
"el": () => import("./el-Do7wYurZ.js"),
|
|
2009
|
-
"jv": () => import("./jv-C-E67yDR.js"),
|
|
2010
|
-
"kk": () => import("./kk-B_5WgCfa.js"),
|
|
2011
|
-
"km": () => import("./km-CucJh4em.js"),
|
|
2012
|
-
"ko": () => import("./ko-BEd2Jz4C.js"),
|
|
2013
|
-
"ky": () => import("./ky-Bb9MfmYr.js"),
|
|
2014
|
-
"lo": () => import("./lo-CD_Ehkf5.js"),
|
|
2015
|
-
"lv": () => import("./lv-CPuPO_jU.js"),
|
|
2016
|
-
"lt": () => import("./lt-DHkwvJ8e.js"),
|
|
2017
|
-
"mk": () => import("./mk-DO85nJp4.js"),
|
|
2018
|
-
"mn": () => import("./mn-D5fhne6X.js"),
|
|
2019
|
-
"ne": () => import("./ne-Ds3QEMQ4.js"),
|
|
2020
|
-
"ru": () => import("./ru-BYQKvZtn.js"),
|
|
2021
|
-
"sk": () => import("./sk-CZipa19k.js"),
|
|
2022
|
-
"sl": () => import("./sl-_sx3gvEv.js"),
|
|
2023
|
-
"sw": () => import("./sw-D2VfTj6a.js"),
|
|
2024
|
-
"tl": () => import("./tl-GXkKKnzb.js"),
|
|
2025
|
-
"th": () => import("./th-BzmKSnbD.js"),
|
|
2026
|
-
"uk": () => import("./uk-DFL26I5l.js"),
|
|
2027
|
-
"ur": () => import("./ur-DXJAfyQA.js"),
|
|
2028
|
-
"uz": () => import("./uz-BXvj8vlH.js"),
|
|
2029
|
-
"hr": () => import("./hr-DWUsAZnf.js")
|
|
2030
|
-
};
|
|
2031
|
-
//#endregion
|
|
2032
|
-
//#region src/i18n/bundledTranslationsBackend.ts
|
|
2033
|
-
function asError(error) {
|
|
2034
|
-
return error instanceof Error ? error : /* @__PURE__ */ new Error("Could not load bundled translations");
|
|
2035
|
-
}
|
|
2036
|
-
var bundledTranslationsBackend = {
|
|
2037
|
-
type: "backend",
|
|
2038
|
-
init() {},
|
|
2039
|
-
read(language, _namespace, callback) {
|
|
2040
|
-
const load = bundledTranslationLoaders[language];
|
|
2041
|
-
if (!load) {
|
|
2042
|
-
callback(/* @__PURE__ */ new Error(`Unsupported bundled language: ${language}`), false);
|
|
2043
|
-
return;
|
|
2044
|
-
}
|
|
2045
|
-
load().then(({ default: translations }) => callback(null, translations), (error) => callback(asError(error), false));
|
|
2046
|
-
}
|
|
2047
|
-
};
|
|
2048
|
-
var supportedLanguages = [
|
|
2049
|
-
"en",
|
|
2050
|
-
"en-DG",
|
|
2051
|
-
"es",
|
|
2052
|
-
"es-ES",
|
|
2053
|
-
"sr",
|
|
2054
|
-
"sr-Latn",
|
|
2055
|
-
"fr",
|
|
2056
|
-
"pt-BR",
|
|
2057
|
-
"pt",
|
|
2058
|
-
"bn",
|
|
2059
|
-
"zh",
|
|
2060
|
-
"hi",
|
|
2061
|
-
"id",
|
|
2062
|
-
"ms",
|
|
2063
|
-
"tr",
|
|
2064
|
-
"vi",
|
|
2065
|
-
"ht",
|
|
2066
|
-
"it",
|
|
2067
|
-
"de",
|
|
2068
|
-
"nl",
|
|
2069
|
-
"tl-PH",
|
|
2070
|
-
"pl",
|
|
2071
|
-
"hu",
|
|
2072
|
-
"ro",
|
|
2073
|
-
"hmn",
|
|
2074
|
-
"so",
|
|
2075
|
-
"ca",
|
|
2076
|
-
"af-ZA",
|
|
2077
|
-
"ar",
|
|
2078
|
-
"ar-EG",
|
|
2079
|
-
"ar-AE",
|
|
2080
|
-
"zh-CN",
|
|
2081
|
-
"zh-TW",
|
|
2082
|
-
"zh-HANT",
|
|
2083
|
-
"cs-CZ",
|
|
2084
|
-
"da-DK",
|
|
2085
|
-
"fi-FI",
|
|
2086
|
-
"fr-CA",
|
|
2087
|
-
"el-GR",
|
|
2088
|
-
"he",
|
|
2089
|
-
"ja",
|
|
2090
|
-
"ja-JP",
|
|
2091
|
-
"ko-KP",
|
|
2092
|
-
"nb-NO",
|
|
2093
|
-
"fa-IR",
|
|
2094
|
-
"pt-PT",
|
|
2095
|
-
"ru-RU",
|
|
2096
|
-
"sr-YU",
|
|
2097
|
-
"es-419",
|
|
2098
|
-
"es-MX",
|
|
2099
|
-
"sv-SE",
|
|
2100
|
-
"th-TH",
|
|
2101
|
-
"uk-UA",
|
|
2102
|
-
"am",
|
|
2103
|
-
"az",
|
|
2104
|
-
"bs",
|
|
2105
|
-
"my",
|
|
2106
|
-
"ceb",
|
|
2107
|
-
"cs",
|
|
2108
|
-
"et",
|
|
2109
|
-
"ka",
|
|
2110
|
-
"el",
|
|
2111
|
-
"jv",
|
|
2112
|
-
"kk",
|
|
2113
|
-
"km",
|
|
2114
|
-
"ko",
|
|
2115
|
-
"ky",
|
|
2116
|
-
"lo",
|
|
2117
|
-
"lv",
|
|
2118
|
-
"lt",
|
|
2119
|
-
"mk",
|
|
2120
|
-
"mn",
|
|
2121
|
-
"ne",
|
|
2122
|
-
"ru",
|
|
2123
|
-
"sk",
|
|
2124
|
-
"sl",
|
|
2125
|
-
"sw",
|
|
2126
|
-
"tl",
|
|
2127
|
-
"th",
|
|
2128
|
-
"uk",
|
|
2129
|
-
"ur",
|
|
2130
|
-
"uz",
|
|
2131
|
-
"hr"
|
|
2132
|
-
];
|
|
2133
|
-
var languageMetadata = {
|
|
2134
|
-
en: { emoji: "🇺🇸" },
|
|
2135
|
-
"en-DG": { emoji: "🇬🇧" },
|
|
2136
|
-
es: { emoji: "🇪🇸" },
|
|
2137
|
-
"es-ES": { emoji: "🇪🇸" },
|
|
2138
|
-
sr: { emoji: "🇷🇸" },
|
|
2139
|
-
"sr-Latn": { emoji: "🇷🇸" },
|
|
2140
|
-
fr: { emoji: "🇫🇷" },
|
|
2141
|
-
"pt-BR": { emoji: "🇧🇷" },
|
|
2142
|
-
pt: { emoji: "🇵🇹" },
|
|
2143
|
-
bn: { emoji: "🇧🇩" },
|
|
2144
|
-
zh: { emoji: "🇨🇳" },
|
|
2145
|
-
hi: { emoji: "🇮🇳" },
|
|
2146
|
-
id: { emoji: "🇮🇩" },
|
|
2147
|
-
ms: { emoji: "🇲🇾" },
|
|
2148
|
-
tr: { emoji: "🇹🇷" },
|
|
2149
|
-
vi: { emoji: "🇻🇳" },
|
|
2150
|
-
ht: { emoji: "🇭🇹" },
|
|
2151
|
-
it: { emoji: "🇮🇹" },
|
|
2152
|
-
de: { emoji: "🇩🇪" },
|
|
2153
|
-
nl: { emoji: "🇳🇱" },
|
|
2154
|
-
"tl-PH": { emoji: "🇵🇭" },
|
|
2155
|
-
pl: { emoji: "🇵🇱" },
|
|
2156
|
-
hu: { emoji: "🇭🇺" },
|
|
2157
|
-
ro: { emoji: "🇷🇴" },
|
|
2158
|
-
hmn: { emoji: "🌐" },
|
|
2159
|
-
so: { emoji: "🇸🇴" },
|
|
2160
|
-
ca: { emoji: "🇪🇸" },
|
|
2161
|
-
"af-ZA": { emoji: "🇿🇦" },
|
|
2162
|
-
ar: { emoji: "🇸🇦" },
|
|
2163
|
-
"ar-EG": { emoji: "🇪🇬" },
|
|
2164
|
-
"ar-AE": { emoji: "🇦🇪" },
|
|
2165
|
-
"zh-CN": { emoji: "🇨🇳" },
|
|
2166
|
-
"zh-TW": { emoji: "🇹🇼" },
|
|
2167
|
-
"zh-HANT": { emoji: "🇹🇼" },
|
|
2168
|
-
"cs-CZ": { emoji: "🇨🇿" },
|
|
2169
|
-
"da-DK": { emoji: "🇩🇰" },
|
|
2170
|
-
"fi-FI": { emoji: "🇫🇮" },
|
|
2171
|
-
"fr-CA": { emoji: "🇨🇦" },
|
|
2172
|
-
"el-GR": { emoji: "🇬🇷" },
|
|
2173
|
-
he: { emoji: "🇮🇱" },
|
|
2174
|
-
ja: { emoji: "🇯🇵" },
|
|
2175
|
-
"ja-JP": { emoji: "🇯🇵" },
|
|
2176
|
-
"ko-KP": { emoji: "🇰🇵" },
|
|
2177
|
-
"nb-NO": { emoji: "🇳🇴" },
|
|
2178
|
-
"fa-IR": { emoji: "🇮🇷" },
|
|
2179
|
-
"pt-PT": { emoji: "🇵🇹" },
|
|
2180
|
-
"ru-RU": { emoji: "🇷🇺" },
|
|
2181
|
-
"sr-YU": { emoji: "🇷🇸" },
|
|
2182
|
-
"es-419": { emoji: "🌎" },
|
|
2183
|
-
"es-MX": { emoji: "🇲🇽" },
|
|
2184
|
-
"sv-SE": { emoji: "🇸🇪" },
|
|
2185
|
-
"th-TH": { emoji: "🇹🇭" },
|
|
2186
|
-
"uk-UA": { emoji: "🇺🇦" },
|
|
2187
|
-
am: { emoji: "🇪🇹" },
|
|
2188
|
-
az: { emoji: "🇦🇿" },
|
|
2189
|
-
bs: { emoji: "🇧🇦" },
|
|
2190
|
-
my: { emoji: "🇲🇲" },
|
|
2191
|
-
ceb: { emoji: "🇵🇭" },
|
|
2192
|
-
cs: { emoji: "🇨🇿" },
|
|
2193
|
-
et: { emoji: "🇪🇪" },
|
|
2194
|
-
ka: { emoji: "🇬🇪" },
|
|
2195
|
-
el: { emoji: "🇬🇷" },
|
|
2196
|
-
jv: { emoji: "🇮🇩" },
|
|
2197
|
-
kk: { emoji: "🇰🇿" },
|
|
2198
|
-
km: { emoji: "🇰🇭" },
|
|
2199
|
-
ko: { emoji: "🇰🇷" },
|
|
2200
|
-
ky: { emoji: "🇰🇬" },
|
|
2201
|
-
lo: { emoji: "🇱🇦" },
|
|
2202
|
-
lv: { emoji: "🇱🇻" },
|
|
2203
|
-
lt: { emoji: "🇱🇹" },
|
|
2204
|
-
mk: { emoji: "🇲🇰" },
|
|
2205
|
-
mn: { emoji: "🇲🇳" },
|
|
2206
|
-
ne: { emoji: "🇳🇵" },
|
|
2207
|
-
ru: { emoji: "🇷🇺" },
|
|
2208
|
-
sk: { emoji: "🇸🇰" },
|
|
2209
|
-
sl: { emoji: "🇸🇮" },
|
|
2210
|
-
sw: { emoji: "🇹🇿" },
|
|
2211
|
-
tl: { emoji: "🇵🇭" },
|
|
2212
|
-
th: { emoji: "🇹🇭" },
|
|
2213
|
-
uk: { emoji: "🇺🇦" },
|
|
2214
|
-
ur: { emoji: "🇵🇰" },
|
|
2215
|
-
uz: { emoji: "🇺🇿" },
|
|
2216
|
-
hr: { emoji: "🇭🇷" }
|
|
2217
|
-
};
|
|
2218
|
-
function getLanguageEmoji(language) {
|
|
2219
|
-
const directMatch = languageMetadata[language];
|
|
2220
|
-
if (directMatch) return directMatch.emoji;
|
|
2221
|
-
return languageMetadata[language.split("-")[0] || language]?.emoji ?? "🌐";
|
|
2222
|
-
}
|
|
2223
|
-
//#endregion
|
|
2224
|
-
//#region src/i18n/lazyHttpBackend.ts
|
|
2225
|
-
var _LazyHttpBackend;
|
|
2226
|
-
/**
|
|
2227
|
-
* Loads i18next-http-backend on the first read, so sessions that use the
|
|
2228
|
-
* bundled catalogs do not download it. i18next creates one instance of this
|
|
2229
|
-
* class for each i18n instance.
|
|
2230
|
-
*/
|
|
2231
|
-
var LazyHttpBackend = class {
|
|
2232
|
-
constructor() {
|
|
2233
|
-
this.type = "backend";
|
|
2234
|
-
}
|
|
2235
|
-
init(services, backendOptions, i18nextOptions) {
|
|
2236
|
-
this.initArgs = [
|
|
2237
|
-
services,
|
|
2238
|
-
backendOptions,
|
|
2239
|
-
i18nextOptions
|
|
2240
|
-
];
|
|
2241
|
-
}
|
|
2242
|
-
read(language, namespace, callback) {
|
|
2243
|
-
this.backend ??= import("./esm-15CISqPe.js").then(({ default: RealHttpBackend }) => {
|
|
2244
|
-
const backend = new RealHttpBackend();
|
|
2245
|
-
backend.init(...this.initArgs);
|
|
2246
|
-
return backend;
|
|
2247
|
-
});
|
|
2248
|
-
this.backend.then((backend) => {
|
|
2249
|
-
try {
|
|
2250
|
-
backend.read(language, namespace, callback);
|
|
2251
|
-
} catch (error) {
|
|
2252
|
-
callback(error, false);
|
|
2253
|
-
}
|
|
2254
|
-
}, (error) => {
|
|
2255
|
-
this.backend = void 0;
|
|
2256
|
-
callback(error, false);
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
};
|
|
2260
|
-
_LazyHttpBackend = LazyHttpBackend;
|
|
2261
|
-
_LazyHttpBackend.type = "backend";
|
|
2262
|
-
//#endregion
|
|
2263
|
-
//#region src/i18n/setup.ts
|
|
2264
|
-
var LANGUAGE_STORAGE_KEY = "incode:i18n:language";
|
|
2265
|
-
var camelToStartCase = (text) => {
|
|
2266
|
-
const result = text.replace(/([A-Z])/g, " $1");
|
|
2267
|
-
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
2268
|
-
};
|
|
2269
|
-
var keyToStartCase = (key, defaultValue) => {
|
|
2270
|
-
if (defaultValue) return defaultValue;
|
|
2271
|
-
const splitKey = key.split(".");
|
|
2272
|
-
const missingKey = splitKey[splitKey.length - 1];
|
|
2273
|
-
return camelToStartCase(missingKey || "missing key");
|
|
2274
|
-
};
|
|
2275
|
-
function readNavigatorLanguage() {
|
|
2276
|
-
if (typeof navigator === "undefined") return "en";
|
|
2277
|
-
const languageFromBrowser = navigator.language;
|
|
2278
|
-
if (!languageFromBrowser) return null;
|
|
2279
|
-
if (supportedLanguages.includes(languageFromBrowser)) return languageFromBrowser;
|
|
2280
|
-
return languageFromBrowser.split("-")[0];
|
|
2281
|
-
}
|
|
2282
|
-
function readHtmlLanguage() {
|
|
2283
|
-
if (typeof document === "undefined") return null;
|
|
2284
|
-
return document.documentElement?.getAttribute("lang") ?? null;
|
|
2285
|
-
}
|
|
2286
|
-
function createLanguageDetector(skipInitialLanguageCache) {
|
|
2287
|
-
let skipNextCache = skipInitialLanguageCache;
|
|
2288
|
-
return {
|
|
2289
|
-
type: "languageDetector",
|
|
2290
|
-
detect: () => [
|
|
2291
|
-
readQueryLanguage(),
|
|
2292
|
-
readStoredLanguage(),
|
|
2293
|
-
readStorageLanguage(() => sessionStorage),
|
|
2294
|
-
readNavigatorLanguage(),
|
|
2295
|
-
readHtmlLanguage()
|
|
2296
|
-
].filter((language) => !!language),
|
|
2297
|
-
cacheUserLanguage(language) {
|
|
2298
|
-
if (skipNextCache) {
|
|
2299
|
-
skipNextCache = false;
|
|
2300
|
-
return;
|
|
2301
|
-
}
|
|
2302
|
-
if (language === "cimode") return;
|
|
2303
|
-
try {
|
|
2304
|
-
localStorage.setItem(LANGUAGE_STORAGE_KEY, language);
|
|
2305
|
-
} catch {}
|
|
2306
|
-
}
|
|
2307
|
-
};
|
|
2308
|
-
}
|
|
2309
|
-
function applyOverrides(i18nInstance, translations) {
|
|
2310
|
-
for (const [langCode, value] of Object.entries(translations)) if (value) i18nInstance.addResourceBundle(langCode, "default", value, true, true);
|
|
2311
|
-
}
|
|
2312
|
-
function readStorageLanguage(getStorage) {
|
|
2313
|
-
try {
|
|
2314
|
-
return getStorage().getItem(LANGUAGE_STORAGE_KEY);
|
|
2315
|
-
} catch {
|
|
2316
|
-
return null;
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
function readStoredLanguage() {
|
|
2320
|
-
return readStorageLanguage(() => localStorage);
|
|
2321
|
-
}
|
|
2322
|
-
function readQueryLanguage() {
|
|
2323
|
-
if (typeof window === "undefined") return null;
|
|
2324
|
-
return new URLSearchParams(window.location.search).get("lang") || null;
|
|
2325
|
-
}
|
|
2326
|
-
function createI18n(options = {}) {
|
|
2327
|
-
const { lang, loadPath, skipRemoteLoad, translations } = options;
|
|
2328
|
-
const i18nInstance = instance.createInstance();
|
|
2329
|
-
const queryLang = readQueryLanguage();
|
|
2330
|
-
const languageDetector = createLanguageDetector(queryLang !== null);
|
|
2331
|
-
const storedLang = readStoredLanguage();
|
|
2332
|
-
const resolvedLoadPath = loadPath ?? void 0;
|
|
2333
|
-
const remoteLoadEnabled = skipRemoteLoad !== true && resolvedLoadPath !== void 0;
|
|
2334
|
-
if (remoteLoadEnabled) i18nInstance.use(LazyHttpBackend);
|
|
2335
|
-
else i18nInstance.use(bundledTranslationsBackend);
|
|
2336
|
-
i18nInstance.use(languageDetector).init({
|
|
2337
|
-
lng: queryLang ?? storedLang ?? lang,
|
|
2338
|
-
fallbackLng: "en",
|
|
2339
|
-
load: remoteLoadEnabled ? "all" : "currentOnly",
|
|
2340
|
-
supportedLngs: supportedLanguages,
|
|
2341
|
-
ns: ["default"],
|
|
2342
|
-
defaultNS: "default",
|
|
2343
|
-
partialBundledLanguages: true,
|
|
2344
|
-
keySeparator: ".",
|
|
2345
|
-
interpolation: { escapeValue: false },
|
|
2346
|
-
backend: remoteLoadEnabled ? { loadPath: resolvedLoadPath } : void 0,
|
|
2347
|
-
initImmediate: false,
|
|
2348
|
-
parseMissingKeyHandler: keyToStartCase
|
|
2349
|
-
});
|
|
2350
|
-
if (translations) {
|
|
2351
|
-
applyOverrides(i18nInstance, translations);
|
|
2352
|
-
i18nInstance.on("loaded", () => {
|
|
2353
|
-
applyOverrides(i18nInstance, translations);
|
|
2354
|
-
});
|
|
2355
|
-
}
|
|
2356
|
-
return i18nInstance;
|
|
2357
|
-
}
|
|
2358
|
-
//#endregion
|
|
2359
|
-
//#region src/i18n/instance.ts
|
|
2360
|
-
var TRANSLATION_EVENTS = [
|
|
2361
|
-
"languageChanged",
|
|
2362
|
-
"initialized",
|
|
2363
|
-
"loaded"
|
|
2364
|
-
];
|
|
2365
|
-
var i18nInstance = null;
|
|
2366
|
-
var version = 0;
|
|
2367
|
-
var listeners$1 = /* @__PURE__ */ new Set();
|
|
2368
|
-
function notify() {
|
|
2369
|
-
version += 1;
|
|
2370
|
-
for (const listener of listeners$1) listener();
|
|
2371
|
-
}
|
|
2372
|
-
function bindTranslationEvents(instance) {
|
|
2373
|
-
for (const event of TRANSLATION_EVENTS) instance.on(event, notify);
|
|
2374
|
-
}
|
|
2375
|
-
function unbindTranslationEvents(instance) {
|
|
2376
|
-
for (const event of TRANSLATION_EVENTS) instance.off(event, notify);
|
|
2377
|
-
}
|
|
2378
|
-
function setI18nInstance(instance) {
|
|
2379
|
-
if (i18nInstance === instance) return;
|
|
2380
|
-
if (i18nInstance) unbindTranslationEvents(i18nInstance);
|
|
2381
|
-
i18nInstance = instance;
|
|
2382
|
-
bindTranslationEvents(instance);
|
|
2383
|
-
notify();
|
|
2384
|
-
}
|
|
2385
|
-
function hasI18nInstance() {
|
|
2386
|
-
return i18nInstance !== null;
|
|
2387
|
-
}
|
|
2388
|
-
function getI18nInstance() {
|
|
2389
|
-
if (!i18nInstance) {
|
|
2390
|
-
i18nInstance = createI18n();
|
|
2391
|
-
bindTranslationEvents(i18nInstance);
|
|
2392
|
-
}
|
|
2393
|
-
return i18nInstance;
|
|
2394
|
-
}
|
|
2395
|
-
function getI18nVersion() {
|
|
2396
|
-
return version;
|
|
2397
|
-
}
|
|
2398
|
-
function subscribeToI18n(listener) {
|
|
2399
|
-
listeners$1.add(listener);
|
|
2400
|
-
return () => {
|
|
2401
|
-
listeners$1.delete(listener);
|
|
2402
|
-
};
|
|
2403
|
-
}
|
|
2404
|
-
//#endregion
|
|
2405
|
-
//#region src/shared/icons/arrowIcon.tsx
|
|
2406
|
-
var ArrowIcon = ({ class: className }) => /* @__PURE__ */ u("svg", {
|
|
2407
|
-
width: "13",
|
|
2408
|
-
height: "14",
|
|
2409
|
-
viewBox: "0 0 13 14",
|
|
2410
|
-
fill: "none",
|
|
2411
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2412
|
-
"aria-hidden": "true",
|
|
2413
|
-
class: className,
|
|
2414
|
-
children: /* @__PURE__ */ u("path", {
|
|
2415
|
-
d: "M0 8.08V5.92h9.198l-4.5-4.05L6.228.34 12.6 6.28v1.422L6.228 13.66l-1.53-1.53 4.5-4.05z",
|
|
2416
|
-
fill: "currentColor"
|
|
2417
|
-
})
|
|
2418
|
-
});
|
|
2419
|
-
//#endregion
|
|
2420
|
-
//#region src/i18n/useTranslation.ts
|
|
2421
|
-
function useTranslation() {
|
|
2422
|
-
const i18nInstance = getI18nInstance();
|
|
2423
|
-
const [, forceUpdate] = d(0);
|
|
2424
|
-
const [ready, setReady] = d(i18nInstance.isInitialized);
|
|
2425
|
-
y(() => {
|
|
2426
|
-
const handleLanguageChanged = () => {
|
|
2427
|
-
forceUpdate((n) => n + 1);
|
|
2428
|
-
};
|
|
2429
|
-
const handleInitialized = () => {
|
|
2430
|
-
setReady(true);
|
|
2431
|
-
forceUpdate((n) => n + 1);
|
|
2432
|
-
};
|
|
2433
|
-
i18nInstance.on("languageChanged", handleLanguageChanged);
|
|
2434
|
-
i18nInstance.on("initialized", handleInitialized);
|
|
2435
|
-
i18nInstance.on("loaded", handleLanguageChanged);
|
|
2436
|
-
return () => {
|
|
2437
|
-
i18nInstance.off("languageChanged", handleLanguageChanged);
|
|
2438
|
-
i18nInstance.off("initialized", handleInitialized);
|
|
2439
|
-
i18nInstance.off("loaded", handleLanguageChanged);
|
|
2440
|
-
};
|
|
2441
|
-
}, [i18nInstance]);
|
|
2442
|
-
return {
|
|
2443
|
-
t: T(() => i18nInstance.t.bind(i18nInstance), [i18nInstance]),
|
|
2444
|
-
ready,
|
|
2445
|
-
i18n: i18nInstance
|
|
2446
|
-
};
|
|
2447
|
-
}
|
|
2448
|
-
//#endregion
|
|
2449
|
-
//#region src/i18n/Trans.tsx
|
|
2450
|
-
var Trans = ({ i18nKey, boldClass = "IncodeTransBold", arrowClass = "IncodeTransArrow", components, defaultValue }) => {
|
|
2451
|
-
const { t } = useTranslation();
|
|
2452
|
-
const text = defaultValue ? t(i18nKey, { defaultValue }) : t(i18nKey);
|
|
2453
|
-
const builtInPattern = "<strong>|<\\/strong>|<br\\s*\\/?>|<arrow\\s*\\/>";
|
|
2454
|
-
const componentPattern = components ? Object.keys(components).map((name) => `<${name}>|<\\/${name}>`).join("|") : "";
|
|
2455
|
-
const fullPattern = componentPattern ? `${builtInPattern}|${componentPattern}` : builtInPattern;
|
|
2456
|
-
const parts = text.split(new RegExp(`(${fullPattern})`, "g"));
|
|
2457
|
-
let isBold = false;
|
|
2458
|
-
let activeComponent = null;
|
|
2459
|
-
return /* @__PURE__ */ u(k, { children: parts.map((part, index) => {
|
|
2460
|
-
if (part === "<strong>") {
|
|
2461
|
-
isBold = true;
|
|
2462
|
-
return null;
|
|
2463
|
-
}
|
|
2464
|
-
if (part === "</strong>") {
|
|
2465
|
-
isBold = false;
|
|
2466
|
-
return null;
|
|
2467
|
-
}
|
|
2468
|
-
if (/^<br\s*\/?>$/.test(part)) return /* @__PURE__ */ u("br", {}, index);
|
|
2469
|
-
if (/^<arrow\s*\/>$/.test(part)) return /* @__PURE__ */ u(ArrowIcon, { class: arrowClass }, index);
|
|
2470
|
-
if (components) {
|
|
2471
|
-
const openMatch = part.match(/^<(\w+)>$/);
|
|
2472
|
-
if (openMatch && components[openMatch[1]]) {
|
|
2473
|
-
activeComponent = openMatch[1];
|
|
2474
|
-
return null;
|
|
2475
|
-
}
|
|
2476
|
-
const closeMatch = part.match(/^<\/(\w+)>$/);
|
|
2477
|
-
if (closeMatch && components[closeMatch[1]]) {
|
|
2478
|
-
activeComponent = null;
|
|
2479
|
-
return null;
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
2482
|
-
if (!part) return null;
|
|
2483
|
-
if (activeComponent && components) return K(components[activeComponent], { key: index }, part);
|
|
2484
|
-
return isBold ? /* @__PURE__ */ u("span", {
|
|
2485
|
-
class: boldClass,
|
|
2486
|
-
children: part
|
|
2487
|
-
}, index) : /* @__PURE__ */ u(k, { children: part }, index);
|
|
2488
|
-
}) });
|
|
2489
|
-
};
|
|
2490
|
-
//#endregion
|
|
2491
|
-
//#region src/i18n/fallbackTranslations.ts
|
|
2492
|
-
/**
|
|
2493
|
-
* Last-resort English copy for keys a screen may read before the translation
|
|
2494
|
-
* bundle loads (see `useTranslationWithFallback`). One fallback per key,
|
|
2495
|
-
* defined once.
|
|
2496
|
-
*/
|
|
2497
|
-
var I18N_LOCAL = {
|
|
2498
|
-
"unsupportedBrowser.title": "Unsupported browser",
|
|
2499
|
-
"unsupportedBrowser.betterExperience": "For a better experience, open this link in",
|
|
2500
|
-
"unsupportedBrowser.or": "or",
|
|
2501
|
-
"unsupportedBrowser.copyLink": "Copy link",
|
|
2502
|
-
"unsupportedBrowser.continueAnyways": "Continue anyway",
|
|
2503
|
-
"unsupportedBrowser.linkCopied": "Link copied"
|
|
2504
|
-
};
|
|
2505
|
-
//#endregion
|
|
2506
|
-
//#region src/i18n/useTranslationWithFallback.ts
|
|
2507
|
-
/**
|
|
2508
|
-
* `useTranslation()`, but a bare `t(key)` picks up its `I18N_LOCAL` fallback
|
|
2509
|
-
* automatically. Any explicit second argument is forwarded untouched. Use
|
|
2510
|
-
* this only on screens that can render before the bundle loads — see
|
|
2511
|
-
* `BrowserNotSupported`.
|
|
2512
|
-
*/
|
|
2513
|
-
function useTranslationWithFallback() {
|
|
2514
|
-
const { t, ready, i18n } = useTranslation();
|
|
2515
|
-
C(subscribeToI18n, getI18nVersion);
|
|
2516
|
-
return {
|
|
2517
|
-
t: q((key, defaultValueOrOptions, options) => {
|
|
2518
|
-
if (typeof defaultValueOrOptions === "string") return options === void 0 ? t(key, defaultValueOrOptions) : t(key, defaultValueOrOptions, options);
|
|
2519
|
-
if (defaultValueOrOptions !== void 0) return t(key, defaultValueOrOptions);
|
|
2520
|
-
if (typeof key !== "string") return t(key);
|
|
2521
|
-
const fallback = I18N_LOCAL[key];
|
|
2522
|
-
return fallback ? t(key, { defaultValue: fallback }) : t(key);
|
|
2523
|
-
}, [t]),
|
|
2524
|
-
ready,
|
|
2525
|
-
i18n
|
|
2526
|
-
};
|
|
2527
|
-
}
|
|
2528
|
-
//#endregion
|
|
2529
|
-
//#region src/shared/uiConfig/uiConfig.ts
|
|
2530
|
-
/** Tier 1: set by the host via `setup({ uiConfig })` / `setUiConfig`. Wins. */
|
|
2531
|
-
var hostUiConfig = {};
|
|
2532
|
-
/** Tier 2: derived from the tenant's dashboard theme. Fills the gaps. */
|
|
2533
|
-
var themeUiConfig = {};
|
|
2534
|
-
/**
|
|
2535
|
-
* Cached composition of the two tiers. `useSyncExternalStore` requires
|
|
2536
|
-
* `getSnapshot` to return a referentially stable value — composing on every
|
|
2537
|
-
* call would hand Preact a new object each time and loop forever — so the
|
|
2538
|
-
* merge happens once per write instead.
|
|
2539
|
-
*/
|
|
2540
|
-
var snapshot = {};
|
|
2541
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
2542
|
-
function withoutUndefined(value) {
|
|
2543
|
-
const defined = {};
|
|
2544
|
-
for (const key of Object.keys(value)) if (value[key] !== void 0) defined[key] = value[key];
|
|
2545
|
-
return defined;
|
|
2546
|
-
}
|
|
2547
|
-
/**
|
|
2548
|
-
* Host fields win over theme fields; a host field left `undefined` counts as
|
|
2549
|
-
* "not specified" and lets the theme through, rather than blanking it.
|
|
2550
|
-
*/
|
|
2551
|
-
function publish() {
|
|
2552
|
-
snapshot = {
|
|
2553
|
-
...themeUiConfig,
|
|
2554
|
-
...withoutUndefined(hostUiConfig)
|
|
2555
|
-
};
|
|
2556
|
-
for (const listener of listeners) listener();
|
|
2557
|
-
}
|
|
2558
|
-
function subscribe(listener) {
|
|
2559
|
-
listeners.add(listener);
|
|
2560
|
-
return () => {
|
|
2561
|
-
listeners.delete(listener);
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2564
|
-
function getSnapshot() {
|
|
2565
|
-
return snapshot;
|
|
2566
|
-
}
|
|
2567
|
-
/**
|
|
2568
|
-
* Sets global UI configuration defaults for `@incodetech/ui`.
|
|
2569
|
-
*
|
|
2570
|
-
* Replaces (does not merge with) the previous host-supplied config, so omitting
|
|
2571
|
-
* a field clears it. The dashboard theme is held separately and is unaffected.
|
|
2572
|
-
*/
|
|
2573
|
-
function setUiConfig(next) {
|
|
2574
|
-
hostUiConfig = next;
|
|
2575
|
-
publish();
|
|
2576
|
-
}
|
|
2577
|
-
/**
|
|
2578
|
-
* Internal: publishes the branding fields derived from the tenant's dashboard
|
|
2579
|
-
* theme. Not exported from the package — hosts use {@link setUiConfig}.
|
|
2580
|
-
*/
|
|
2581
|
-
function setThemeUiConfig(next) {
|
|
2582
|
-
themeUiConfig = next;
|
|
2583
|
-
publish();
|
|
2584
|
-
}
|
|
2585
|
-
function useUiConfig() {
|
|
2586
|
-
return C(subscribe, getSnapshot);
|
|
2587
|
-
}
|
|
2588
|
-
//#endregion
|
|
2589
|
-
export { Trans as a, setI18nInstance as c, getLanguageEmoji as d, supportedLanguages as f, useTranslationWithFallback as i, createI18n as l, setUiConfig as n, useTranslation as o, useUiConfig as r, hasI18nInstance as s, setThemeUiConfig as t, readStoredLanguage as u };
|