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:
@@ -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"
|
||||
options?: AdminOptions
|
||||
template?: string
|
||||
publicFolder?: string
|
||||
reporting?: BuildReporting
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ export function getWebpackConfig({
|
||||
env,
|
||||
options,
|
||||
template,
|
||||
publicFolder,
|
||||
reporting = "fancy",
|
||||
}: WebpackConfigArgs): Configuration {
|
||||
const isProd = env === "production"
|
||||
@@ -181,7 +182,7 @@ export function getWebpackConfig({
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.resolve(__dirname, "..", "ui", "public"),
|
||||
from: publicFolder || path.resolve(__dirname, "..", "ui", "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
|
||||
.use(Backend)
|
||||
.use(LanguageDetector)
|
||||
.use(initReactI18next)
|
||||
// https://www.i18next.com/overview/configuration-options
|
||||
.init({
|
||||
backend: {
|
||||
loadPath: pathToLoadFrom
|
||||
},
|
||||
supportedLngs: supportedLanguages.map((l) => l.locale),
|
||||
fallbackLng: "en",
|
||||
returnNull: false,
|
||||
|
||||
@@ -18,6 +18,7 @@ const getDevServerConfig = () => {
|
||||
path: "/",
|
||||
},
|
||||
template: path.resolve(__dirname, "ui", "index.html"),
|
||||
publicFolder: path.resolve(__dirname, "ui", "public"),
|
||||
})
|
||||
|
||||
if (analyzeBundle) {
|
||||
|
||||
Reference in New Issue
Block a user