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 21:16:43 +02:00
committed by GitHub
parent 012e30801e
commit 226984cf0f
25 changed files with 314 additions and 9 deletions

View File

@@ -49,7 +49,7 @@ export function generateModule(code: string) {
}
}
export const VALID_FILE_EXTENSIONS = [".tsx", ".jsx", ".js"]
export const VALID_FILE_EXTENSIONS = [".tsx", ".jsx", ".js", ".ts"]
/**
* Crawls a directory and returns all files that match the criteria.
@@ -176,7 +176,7 @@ export function generateHash(content: string) {
return crypto.createHash("md5").update(content).digest("hex")
}
const ADMIN_SUBDIRECTORIES = ["routes", "custom-fields", "widgets"] as const
const ADMIN_SUBDIRECTORIES = ["routes", "custom-fields", "widgets", "i18n"] as const
export type AdminSubdirectory = (typeof ADMIN_SUBDIRECTORIES)[number]