From 3f1ecadc626625472029e89f927690574557ad32 Mon Sep 17 00:00:00 2001 From: Tim R Date: Tue, 2 Jul 2024 15:54:08 -0500 Subject: [PATCH 1/5] Move react-i18next and i18next to peer/dev-Dependencies and update --- packages/components/package.json | 6 ++++-- yarn.lock | 28 +++++++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 0d813ea3..e1e1303b 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -42,14 +42,14 @@ "@department-of-veterans-affairs/mobile-assets": "0.12.0", "@department-of-veterans-affairs/mobile-tokens": "0.13.0", "@os-team/i18next-react-native-language-detector": "^1.0.31", - "i18next": "^23.8.2", - "react-i18next": "^14.0.5", "react-native-svg": "15.2.0", "styled-components": "^6.1.8" }, "peerDependencies": { "@department-of-veterans-affairs/mobile-assets": "*", + "i18next": ">=23.0.0", "react": "^18.2.0", + "react-i18next": ">=14.0.0", "react-native": ">=0.71.7", "react-native-gesture-handler": "^2.12.0" }, @@ -94,12 +94,14 @@ "expo-splash-screen": "~0.27.4", "expo-status-bar": "~1.12.1", "gh-pages": "^6.1.1", + "i18next": "^23.11.5", "jest": "^29.7.0", "jest-expo": "~51.0.1", "jest-styled-components": "^7.2.0", "metro-react-native-babel-preset": "^0.77.0", "react": "^18.2.0", "react-dom": "18.2.0", + "react-i18next": "^14.1.2", "react-native": "0.74.1", "react-native-gesture-handler": "~2.16.1", "react-native-reanimated": "3.10.1", diff --git a/yarn.lock b/yarn.lock index c421346b..cbcad137 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1941,11 +1941,11 @@ __metadata: linkType: hard "@babel/runtime@npm:^7.23.2, @babel/runtime@npm:^7.23.9": - version: 7.23.9 - resolution: "@babel/runtime@npm:7.23.9" + version: 7.24.7 + resolution: "@babel/runtime@npm:7.24.7" dependencies: regenerator-runtime: "npm:^0.14.0" - checksum: e71205fdd7082b2656512cc98e647d9ea7e222e4fe5c36e9e5adc026446fcc3ba7b3cdff8b0b694a0b78bb85db83e7b1e3d4c56ef90726682b74f13249cf952d + checksum: b6fa3ec61a53402f3c1d75f4d808f48b35e0dfae0ec8e2bb5c6fc79fb95935da75766e0ca534d0f1c84871f6ae0d2ebdd950727cfadb745a2cdbef13faef5513 languageName: node linkType: hard @@ -2179,14 +2179,14 @@ __metadata: expo-splash-screen: "npm:~0.27.4" expo-status-bar: "npm:~1.12.1" gh-pages: "npm:^6.1.1" - i18next: "npm:^23.8.2" + i18next: "npm:^23.11.5" jest: "npm:^29.7.0" jest-expo: "npm:~51.0.1" jest-styled-components: "npm:^7.2.0" metro-react-native-babel-preset: "npm:^0.77.0" react: "npm:^18.2.0" react-dom: "npm:18.2.0" - react-i18next: "npm:^14.0.5" + react-i18next: "npm:^14.1.2" react-native: "npm:0.74.1" react-native-gesture-handler: "npm:~2.16.1" react-native-reanimated: "npm:3.10.1" @@ -2203,7 +2203,9 @@ __metadata: typescript: "npm:^5.3.3" peerDependencies: "@department-of-veterans-affairs/mobile-assets": "*" + i18next: ">=23.0.0" react: ^18.2.0 + react-i18next: ">=14.0.0" react-native: ">=0.71.7" react-native-gesture-handler: ^2.12.0 languageName: unknown @@ -12753,12 +12755,12 @@ __metadata: languageName: node linkType: hard -"i18next@npm:^23.8.2": - version: 23.8.2 - resolution: "i18next@npm:23.8.2" +"i18next@npm:^23.11.5": + version: 23.11.5 + resolution: "i18next@npm:23.11.5" dependencies: "@babel/runtime": "npm:^7.23.2" - checksum: c16ccee81bc1e096fec8d10000de42f10137f7cd27b295eca22492cb174b364ebca72327b2e6be066c4308c79bf72c8585d1c7cde2aedf556e3f423af60cd66c + checksum: b0bec64250a3e529d4c51e2fc511406a85c5dde3d005d3aabe919551ca31dfc0a8f5490bf6e44649822e895a1fa91a58092d112367669cd11b2eb89e6ba90d1a languageName: node linkType: hard @@ -17408,9 +17410,9 @@ __metadata: languageName: node linkType: hard -"react-i18next@npm:^14.0.5": - version: 14.0.5 - resolution: "react-i18next@npm:14.0.5" +"react-i18next@npm:^14.1.2": + version: 14.1.2 + resolution: "react-i18next@npm:14.1.2" dependencies: "@babel/runtime": "npm:^7.23.9" html-parse-stringify: "npm:^3.0.1" @@ -17422,7 +17424,7 @@ __metadata: optional: true react-native: optional: true - checksum: 60e3bedc6889689cfb96005b134da79d50097d3ff088284b35f213820aacedbdad1ff32e97b8447db70834c16d472ded829675e05c2a099baea9fd96b3a5b72f + checksum: cb8a83b3696639f083dc9f770d9d9e0681c0fe56f6b5fe24cd6facce08d363c37bd3440078e9d63abacabd7037b783e6b4e4d0c935de9c8dda7820bd4ef7e329 languageName: node linkType: hard From 865fce6c9fbaa80800cdd665aa3366599e0e3d2e Mon Sep 17 00:00:00 2001 From: VA Automation Bot Date: Tue, 2 Jul 2024 20:57:45 +0000 Subject: [PATCH 2/5] Version bump: components-v0.20.2-alpha.0 --- packages/components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/package.json b/packages/components/package.json index e1e1303b..fcf77ec9 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@department-of-veterans-affairs/mobile-component-library", - "version": "0.20.1", + "version": "0.20.2-alpha.0", "description": "VA Design System Mobile Component Library", "main": "src/index.tsx", "scripts": { From a69b437ba34aafa6dcdd6834ec8bec21af430d49 Mon Sep 17 00:00:00 2001 From: VA Automation Bot Date: Tue, 2 Jul 2024 22:35:10 +0000 Subject: [PATCH 3/5] Version bump: components-v0.20.2-alpha.1 --- packages/components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/package.json b/packages/components/package.json index fcf77ec9..4e66b5e7 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@department-of-veterans-affairs/mobile-component-library", - "version": "0.20.2-alpha.0", + "version": "0.20.2-alpha.1", "description": "VA Design System Mobile Component Library", "main": "src/index.tsx", "scripts": { From 0bc92c2a608356c72d1e2c0657eaabbe2bb6144d Mon Sep 17 00:00:00 2001 From: Tim R Date: Wed, 3 Jul 2024 14:59:22 -0500 Subject: [PATCH 4/5] Fix for double initializing i18n and update `react-i18next` + `i18next` to latest --- packages/components/package.json | 6 ++---- packages/components/src/utils/translation/i18n.ts | 13 ++++++++----- yarn.lock | 2 -- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/components/package.json b/packages/components/package.json index 4e66b5e7..fc666ff5 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -42,14 +42,14 @@ "@department-of-veterans-affairs/mobile-assets": "0.12.0", "@department-of-veterans-affairs/mobile-tokens": "0.13.0", "@os-team/i18next-react-native-language-detector": "^1.0.31", + "i18next": "^23.11.5", + "react-i18next": "^14.1.2", "react-native-svg": "15.2.0", "styled-components": "^6.1.8" }, "peerDependencies": { "@department-of-veterans-affairs/mobile-assets": "*", - "i18next": ">=23.0.0", "react": "^18.2.0", - "react-i18next": ">=14.0.0", "react-native": ">=0.71.7", "react-native-gesture-handler": "^2.12.0" }, @@ -94,14 +94,12 @@ "expo-splash-screen": "~0.27.4", "expo-status-bar": "~1.12.1", "gh-pages": "^6.1.1", - "i18next": "^23.11.5", "jest": "^29.7.0", "jest-expo": "~51.0.1", "jest-styled-components": "^7.2.0", "metro-react-native-babel-preset": "^0.77.0", "react": "^18.2.0", "react-dom": "18.2.0", - "react-i18next": "^14.1.2", "react-native": "0.74.1", "react-native-gesture-handler": "~2.16.1", "react-native-reanimated": "3.10.1", diff --git a/packages/components/src/utils/translation/i18n.ts b/packages/components/src/utils/translation/i18n.ts index 9a3bdc5b..f8615066 100644 --- a/packages/components/src/utils/translation/i18n.ts +++ b/packages/components/src/utils/translation/i18n.ts @@ -15,10 +15,11 @@ if (process.env.STORYBOOK_WEB !== 'true') { i18n.use(RNLanguageDetector) } - -i18n - .use(initReactI18next) - .init({ +// If i18n is already initialized (in app), add our translations to the common namespace +if (i18n.isInitializing || i18n.isInitialized) { + i18n.addResourceBundle('en', 'common', resources.en.translation) +} else { + i18n.use(initReactI18next).init({ resources, keySeparator: false, fallbackLng: 'en', @@ -32,4 +33,6 @@ i18n useSuspense: true, }, }) -export default i18n +} + +export default i18n \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index cbcad137..519c950d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2203,9 +2203,7 @@ __metadata: typescript: "npm:^5.3.3" peerDependencies: "@department-of-veterans-affairs/mobile-assets": "*" - i18next: ">=23.0.0" react: ^18.2.0 - react-i18next: ">=14.0.0" react-native: ">=0.71.7" react-native-gesture-handler: ^2.12.0 languageName: unknown From cd9899b0c7bdb6bc88ae4de5075568b1efd6d0e3 Mon Sep 17 00:00:00 2001 From: Tim R Date: Wed, 3 Jul 2024 15:04:43 -0500 Subject: [PATCH 5/5] Formatting --- packages/components/src/utils/translation/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/src/utils/translation/i18n.ts b/packages/components/src/utils/translation/i18n.ts index f8615066..9c13a363 100644 --- a/packages/components/src/utils/translation/i18n.ts +++ b/packages/components/src/utils/translation/i18n.ts @@ -35,4 +35,4 @@ if (i18n.isInitializing || i18n.isInitialized) { }) } -export default i18n \ No newline at end of file +export default i18n