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:
Oli Juhl
2023-09-15 13:19:24 +02:00
committed by GitHub
co-authored by Kasper
parent 53ffd614b5
commit c722440c30
5 changed files with 18 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"@medusajs/admin-ui": patch
"@medusajs/admin": patch
---
fix(admin-ui): Load translations from path
+1
View File
@@ -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"),
},
],
+8
View File
@@ -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,
+1
View File
@@ -18,6 +18,7 @@ const getDevServerConfig = () => {
path: "/",
},
template: path.resolve(__dirname, "ui", "index.html"),
publicFolder: path.resolve(__dirname, "ui", "public"),
})
if (analyzeBundle) {