diff --git a/__mocks__/react-native-localize.ts b/__mocks__/react-native-localize.ts index 86b83294cd8..6c3d1d5307c 100644 --- a/__mocks__/react-native-localize.ts +++ b/__mocks__/react-native-localize.ts @@ -1,26 +1,18 @@ -import { NativeModules } from 'react-native' - -NativeModules.RNLocalize = { - initialConstants: { - locales: [ - { - languageCode: 'en', - countryCode: 'US', - languageTag: 'en-US', - isRTL: false, - }, - ], - currencies: ['MXN', 'USD'], - country: 'US', - }, -} - module.exports = { - ...jest.requireActual('react-native-localize'), getNumberFormatSettings: jest.fn(() => ({ decimalSeparator: '.', groupingSeparator: ',', })), getTimeZone: jest.fn(() => 'America/New_York'), - findBestAvailableLanguage: jest.fn(() => ({ languageTag: 'en-US', isRTL: true })), + findBestLanguageTag: jest.fn(() => ({ languageTag: 'en-US', isRTL: true })), + getCountry: jest.fn(() => 'US'), + getCurrencies: jest.fn(() => ['MXN', 'USD']), + getLocales: jest.fn(() => [ + { + languageCode: 'en', + countryCode: 'US', + languageTag: 'en-US', + isRTL: false, + }, + ]), } diff --git a/ios/Podfile.lock b/ios/Podfile.lock index fded9cebe6e..6c87e194d4d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -713,7 +713,7 @@ PODS: - TOCropViewController - RNKeychain (8.1.3): - React-Core - - RNLocalize (2.2.6): + - RNLocalize (3.1.0): - React-Core - RNPermissions (4.1.5): - React-Core @@ -1249,7 +1249,7 @@ SPEC CHECKSUMS: RNGestureHandler: 69d0a928253547ef857a7be4f453220b9c472e07 RNImageCropPicker: e7ab6fb43d2fc3e84651e786ef4a080d63b0ed3d RNKeychain: f1b48665a4646f61191eb048c4c05c58d9a7596f - RNLocalize: d4b8af4e442d4bcca54e68fc687a2129b4d71a81 + RNLocalize: e8694475db034bf601e17bd3dfa8986565e769eb RNPermissions: da2a4ded375aa8292d85ed93676e102c203d4717 RNPersonaInquiry2: 3ab52078e891a5d2fa39bf7cc9119ca27f0337fd RNReactNativeHapticFeedback: ec56a5f81c3941206fd85625fa669ffc7b4545f9 diff --git a/package.json b/package.json index 7f3976f60d5..534316cb2c3 100644 --- a/package.json +++ b/package.json @@ -165,7 +165,7 @@ "react-native-keychain": "^8.1.3", "react-native-launch-arguments": "^4.0.2", "react-native-linear-gradient": "^2.8.3", - "react-native-localize": "^2.2.6", + "react-native-localize": "^3.1.0", "react-native-modal": "^13.0.1", "react-native-permissions": "^4.1.5", "react-native-persona": "^2.2.23", diff --git a/src/app/AppInitGate.test.tsx b/src/app/AppInitGate.test.tsx index 3ff16ee342d..d5fad9550bf 100644 --- a/src/app/AppInitGate.test.tsx +++ b/src/app/AppInitGate.test.tsx @@ -81,7 +81,7 @@ describe('AppInitGate', () => { it('should update the language if none was set', async () => { jest - .spyOn(RNLocalize, 'findBestAvailableLanguage') + .spyOn(RNLocalize, 'findBestLanguageTag') .mockReturnValue({ languageTag: 'de-DE', isRTL: true }) const { getByText, store } = renderAppInitGate(null) diff --git a/src/app/AppInitGate.tsx b/src/app/AppInitGate.tsx index b77fb6f00df..8317567e823 100644 --- a/src/app/AppInitGate.tsx +++ b/src/app/AppInitGate.tsx @@ -2,7 +2,7 @@ import locales from 'locales' import React, { useEffect } from 'react' import { useAsync } from 'react-async-hook' import { Dimensions } from 'react-native' -import { findBestAvailableLanguage } from 'react-native-localize' +import { findBestLanguageTag } from 'react-native-localize' import { AppEvents } from 'src/analytics/Events' import ValoraAnalytics from 'src/analytics/ValoraAnalytics' import { appMounted, appUnmounted } from 'src/app/actions' @@ -28,9 +28,7 @@ const AppInitGate = ({ appStartedMillis, reactLoadTime, children }: Props) => { const dispatch = useDispatch() const language = useSelector(currentLanguageSelector) - const bestLanguage = !isE2EEnv - ? findBestAvailableLanguage(Object.keys(locales))?.languageTag - : 'en-US' + const bestLanguage = !isE2EEnv ? findBestLanguageTag(Object.keys(locales))?.languageTag : 'en-US' useEffect(() => { return () => { diff --git a/src/app/saga.test.ts b/src/app/saga.test.ts index 4c6c6e1444c..ab3e398a6b2 100644 --- a/src/app/saga.test.ts +++ b/src/app/saga.test.ts @@ -731,7 +731,7 @@ describe('appInit', () => { it('should initialise with the best language', async () => { jest - .spyOn(RNLocalize, 'findBestAvailableLanguage') + .spyOn(RNLocalize, 'findBestLanguageTag') .mockReturnValue({ languageTag: 'de-DE', isRTL: true }) await expectSaga(appInit) @@ -745,7 +745,7 @@ describe('appInit', () => { }) it('should initialise with the app fallback language', async () => { - jest.spyOn(RNLocalize, 'findBestAvailableLanguage').mockReturnValue(undefined) + jest.spyOn(RNLocalize, 'findBestLanguageTag').mockReturnValue(undefined) await expectSaga(appInit) .provide([[select(currentLanguageSelector), null], ...defaultProviders]) diff --git a/src/app/saga.ts b/src/app/saga.ts index 1e40fe1cabc..feb1d43827b 100644 --- a/src/app/saga.ts +++ b/src/app/saga.ts @@ -6,7 +6,7 @@ import { AppState, Platform } from 'react-native' import DeviceInfo from 'react-native-device-info' import InAppReview from 'react-native-in-app-review' import * as Keychain from 'react-native-keychain' -import { findBestAvailableLanguage } from 'react-native-localize' +import { findBestLanguageTag } from 'react-native-localize' import { eventChannel } from 'redux-saga' import { e164NumberSelector } from 'src/account/selectors' import { AppEvents, InviteEvents } from 'src/analytics/Events' @@ -121,7 +121,7 @@ export function* appInit() { const allowOtaTranslations = yield* select(allowOtaTranslationsSelector) const otaTranslationsAppVersion = yield* select(otaTranslationsAppVersionSelector) const language = yield* select(currentLanguageSelector) - const bestLanguage = findBestAvailableLanguage(Object.keys(locales))?.languageTag + const bestLanguage = findBestLanguageTag(Object.keys(locales))?.languageTag yield* all([ call(initializeSentry), diff --git a/yarn.lock b/yarn.lock index 132e91753a7..9ef3e56bf58 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15264,10 +15264,10 @@ react-native-linear-gradient@^2.8.3: resolved "https://registry.yarnpkg.com/react-native-linear-gradient/-/react-native-linear-gradient-2.8.3.tgz#9a116649f86d74747304ee13db325e20b21e564f" integrity sha512-KflAXZcEg54PXkLyflaSZQ3PJp4uC4whM7nT/Uot9m0e/qxFV3p6uor1983D1YOBJbJN7rrWdqIjq0T42jOJyA== -react-native-localize@^2.2.6: - version "2.2.6" - resolved "https://registry.yarnpkg.com/react-native-localize/-/react-native-localize-2.2.6.tgz#484f8c700bc629f230066e819265f80f6dd3ef58" - integrity sha512-EZETlC1ZlW/4g6xfsNCwAkAw5BDL2A6zk/08JjFR/GRGxYuKRD7iP1hHn1+h6DEu+xROjPpoNeXfMER2vkTVIQ== +react-native-localize@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/react-native-localize/-/react-native-localize-3.1.0.tgz#1b322c05af21fd3d78d44e9b747d872ab5155b10" + integrity sha512-A7Rrxl8vuAr5FAqtMFrM5ELLdmszohK6FoHL6qlgxx4HScyOnadoZksbvKHbn+zV5nE8kud2Z4kJM10cN120Zg== react-native-modal@^13.0.1: version "13.0.1"