1 import i18n from "i18next"
2 import LanguageDetector from "i18next-browser-languagedetector"
3 import { initReactI18next } from "react-i18next"
4
5 import { defaultI18nOptions } from "../../../i18n/config"
6 import { useExtension } from "../../../providers/extension-provider"
7
8 export const I18n = () => {
9 const { getI18nResources } = useExtension()
10
11 if (i18n.isInitialized) {
12 return null
13 }
14
15 const resources = getI18nResources()
16 i18n
17 .use(
18 new LanguageDetector(null, {
19 lookupCookie: "lng",
20 lookupLocalStorage: "lng",
21 })
22 )
23 .use(initReactI18next)
24 .init({
25 ...defaultI18nOptions,
26 resources,
27 supportedLngs: Object.keys(resources),
28 })
29
30 return null
31 }
32
33 export { i18n }