-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from JosephGasiorekUSDS/jgasiorek-ffs-913
FFS-913: Upgrade i18n infra
- Loading branch information
Showing
32 changed files
with
126 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import i18n from 'i18next' | ||
import { initReactI18next } from 'react-i18next' | ||
import fs from 'fs/promises' | ||
|
||
async function getRes() { | ||
const data = await fs.readFile('./app/i18n/locales/en/translation.json') | ||
return JSON.parse(data) | ||
} | ||
|
||
const res = await getRes() | ||
console.log(res) | ||
|
||
await i18n | ||
.use(initReactI18next) | ||
.init({ | ||
lng: 'en', | ||
fallbackLng: 'en', | ||
debug: true, | ||
interpolation: { | ||
escapeValue: false, | ||
}, | ||
react: { | ||
useSuspense: false, | ||
wait: true | ||
}, | ||
ns: ['translationsNS'], | ||
defaultNS: 'translationsNS', | ||
resources: { en: { translationsNS: res }} | ||
}); | ||
|
||
export default i18n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { I18nextProvider } from "react-i18next"; | ||
import { Provider } from "react-redux"; | ||
import i18nTesting from '@/app/I18nTesting' | ||
import { EnhancedStore } from '@reduxjs/toolkit' | ||
import { makeStore } from "@/lib/store"; | ||
|
||
interface Props { | ||
store?: EnhancedStore | ||
children: React.ReactNode | ||
} | ||
|
||
export default function TestWrapper({ children, store }: Props) { | ||
store = store || makeStore() | ||
return ( | ||
<Provider store={store}> | ||
<I18nextProvider i18n={i18nTesting}> | ||
{children} | ||
</I18nextProvider> | ||
</Provider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use client' | ||
import '@/app/i18n' | ||
|
||
export default function I18nComponent() { | ||
return (<></>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import i18n from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import LanguageDetector from 'i18next-browser-languagedetector'; | ||
import resourcesToBackend from 'i18next-resources-to-backend' | ||
|
||
i18n | ||
.use(LanguageDetector) | ||
.use(initReactI18next) | ||
.use(resourcesToBackend((language, namespace) => import(`./i18n/locales/${language}/${namespace}.json`))) | ||
.init({ | ||
debug: process.env.NODE_ENV !== "production" , | ||
fallbackLng: 'en' | ||
}); | ||
|
||
export default i18n; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.