fix(admin-ui): Load translations from path (#5064)
* fix(admin-ui): Load translations from path * Create big-oranges-battle.md * fix: resolve public folder path in dev --------- Co-authored-by: Kasper <kasper@medusajs.com>
This commit is contained in:
1 parent
53ffd614b5
commit
c722440c30
5 files changed
+18
-1
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/admin-ui": patch
|
||||||
|
"@medusajs/admin": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(admin-ui): Load translations from path
|
||||||
@@ -59,6 +59,7 @@ export type WebpackConfigArgs = {
|
|||||||
env: "development" | "production"
|
env: "development" | "production"
|
||||||
options?: AdminOptions
|
options?: AdminOptions
|
||||||
template?: string
|
template?: string
|
||||||
|
publicFolder?: string
|
||||||
reporting?: BuildReporting
|
reporting?: BuildReporting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export function getWebpackConfig({
|
|||||||
env,
|
env,
|
||||||
options,
|
options,
|
||||||
template,
|
template,
|
||||||
|
publicFolder,
|
||||||
reporting = "fancy",
|
reporting = "fancy",
|
||||||
}: WebpackConfigArgs): Configuration {
|
}: WebpackConfigArgs): Configuration {
|
||||||
const isProd = env === "production"
|
const isProd = env === "production"
|
||||||
@@ -181,7 +182,7 @@ export function getWebpackConfig({
|
|||||||
new CopyPlugin({
|
new CopyPlugin({
|
||||||
patterns: [
|
patterns: [
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, "..", "ui", "public"),
|
from: publicFolder || path.resolve(__dirname, "..", "ui", "public"),
|
||||||
to: path.resolve(dest, "public"),
|
to: path.resolve(dest, "public"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -14,12 +14,20 @@ export const supportedLanguages = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const backendUrl = window.location.origin
|
||||||
|
const adminPath = process.env.ADMIN_PATH ? `${process.env.ADMIN_PATH}` : ""
|
||||||
|
|
||||||
|
const pathToLoadFrom = `${backendUrl}${adminPath}locales/{{lng}}/{{ns}}.json`
|
||||||
|
|
||||||
void i18n
|
void i18n
|
||||||
.use(Backend)
|
.use(Backend)
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
// https://www.i18next.com/overview/configuration-options
|
// https://www.i18next.com/overview/configuration-options
|
||||||
.init({
|
.init({
|
||||||
|
backend: {
|
||||||
|
loadPath: pathToLoadFrom
|
||||||
|
},
|
||||||
supportedLngs: supportedLanguages.map((l) => l.locale),
|
supportedLngs: supportedLanguages.map((l) => l.locale),
|
||||||
fallbackLng: "en",
|
fallbackLng: "en",
|
||||||
returnNull: false,
|
returnNull: false,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const getDevServerConfig = () => {
|
|||||||
path: "/",
|
path: "/",
|
||||||
},
|
},
|
||||||
template: path.resolve(__dirname, "ui", "index.html"),
|
template: path.resolve(__dirname, "ui", "index.html"),
|
||||||
|
publicFolder: path.resolve(__dirname, "ui", "public"),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (analyzeBundle) {
|
if (analyzeBundle) {
|
||||||
|
|||||||
Reference in new issue
Block a user