feat: add i18n detector
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
6ed0a3bf3a
commit
7eb8a322c7
|
|
@ -95,6 +95,7 @@
|
|||
"hast-util-to-jsx-runtime": "2.3.0",
|
||||
"hast-util-to-text": "4.0.2",
|
||||
"i18next": "^23.15.1",
|
||||
"i18next-browser-languagedetector": "8.0.0",
|
||||
"idb-keyval": "6.2.1",
|
||||
"immer": "10.1.1",
|
||||
"jotai": "2.9.3",
|
||||
|
|
|
|||
|
|
@ -209,6 +209,9 @@ importers:
|
|||
i18next:
|
||||
specifier: ^23.15.1
|
||||
version: 23.15.1
|
||||
i18next-browser-languagedetector:
|
||||
specifier: 8.0.0
|
||||
version: 8.0.0
|
||||
idb-keyval:
|
||||
specifier: 6.2.1
|
||||
version: 6.2.1
|
||||
|
|
@ -5349,6 +5352,9 @@ packages:
|
|||
humps@2.0.1:
|
||||
resolution: {integrity: sha512-E0eIbrFWUhwfXJmsbdjRQFQPrl5pTEoKlz163j1mTqqUnU9PgR4AgB8AIITzuB3vLBdxZXyZ9TDIrwB2OASz4g==}
|
||||
|
||||
i18next-browser-languagedetector@8.0.0:
|
||||
resolution: {integrity: sha512-zhXdJXTTCoG39QsrOCiOabnWj2jecouOqbchu3EfhtSHxIB5Uugnm9JaizenOy39h7ne3+fLikIjeW88+rgszw==}
|
||||
|
||||
i18next@23.15.1:
|
||||
resolution: {integrity: sha512-wB4abZ3uK7EWodYisHl/asf8UYEhrI/vj/8aoSsrj/ZDxj4/UXPOa1KvFt1Fq5hkUHquNqwFlDprmjZ8iySgYA==}
|
||||
|
||||
|
|
@ -14403,6 +14409,10 @@ snapshots:
|
|||
|
||||
humps@2.0.1: {}
|
||||
|
||||
i18next-browser-languagedetector@8.0.0:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.25.4
|
||||
|
||||
i18next@23.15.1:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.25.4
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { EventBus } from "@renderer/lib/event-bus"
|
||||
import dayjs from "dayjs"
|
||||
import i18next from "i18next"
|
||||
import LanguageDetector from "i18next-browser-languagedetector"
|
||||
import { atom } from "jotai"
|
||||
import { initReactI18next } from "react-i18next"
|
||||
|
||||
|
|
@ -14,13 +15,17 @@ export const defaultNS = "app"
|
|||
export const fallbackLanguage = "en"
|
||||
export const initI18n = async () => {
|
||||
const i18next = jotaiStore.get(i18nAtom)
|
||||
await i18next.use(initReactI18next).init({
|
||||
lng: "en",
|
||||
fallbackLng: fallbackLanguage,
|
||||
defaultNS,
|
||||
debug: import.meta.env.DEV,
|
||||
resources: defaultResources,
|
||||
})
|
||||
await i18next
|
||||
.use(initReactI18next)
|
||||
.use(LanguageDetector)
|
||||
.init({
|
||||
lng: "en",
|
||||
|
||||
fallbackLng: fallbackLanguage,
|
||||
defaultNS,
|
||||
debug: import.meta.env.DEV,
|
||||
resources: defaultResources,
|
||||
})
|
||||
|
||||
dayjs.locale("en")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue