feat(admin-*,dashboard): add dashboard i18n extensions (#13763)
* virtual i18n module
* changeset
* fallback ns
fallback to the default "translation" ns if the key isnt found. Allows to use a single "useTranslation("customNs")" hook for both custom and medusa-provided keys
* simplify merges
* optional for backward compat
* fix HMR
* fix generated deepMerge
* test
This commit is contained in:
@@ -3,12 +3,16 @@ import LanguageDetector from "i18next-browser-languagedetector"
|
||||
import { initReactI18next } from "react-i18next"
|
||||
|
||||
import { defaultI18nOptions } from "../../../i18n/config"
|
||||
import { useExtension } from "../../../providers/extension-provider"
|
||||
|
||||
export const I18n = () => {
|
||||
const { getI18nResources } = useExtension()
|
||||
|
||||
if (i18n.isInitialized) {
|
||||
return null
|
||||
}
|
||||
|
||||
const resources = getI18nResources()
|
||||
i18n
|
||||
.use(
|
||||
new LanguageDetector(null, {
|
||||
@@ -17,7 +21,11 @@ export const I18n = () => {
|
||||
})
|
||||
)
|
||||
.use(initReactI18next)
|
||||
.init(defaultI18nOptions)
|
||||
.init({
|
||||
...defaultI18nOptions,
|
||||
resources,
|
||||
supportedLngs: Object.keys(resources),
|
||||
})
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user