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:
Leonardo Benini
2025-10-23 15:16:43 -04:00
committed by GitHub
parent 012e30801e
commit 226984cf0f
25 changed files with 314 additions and 9 deletions
@@ -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
}