Skip to content

Commit

Permalink
Merge branch 'develop' into docs/fix-railway-env
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser authored Sep 15, 2023
2 parents 3926877 + c722440 commit 0a63878
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/big-oranges-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/admin-ui": patch
"@medusajs/admin": patch
---

fix(admin-ui): Load translations from path
1 change: 1 addition & 0 deletions packages/admin-ui/src/node/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type WebpackConfigArgs = {
env: "development" | "production"
options?: AdminOptions
template?: string
publicFolder?: string
reporting?: BuildReporting
}

Expand Down
3 changes: 2 additions & 1 deletion packages/admin-ui/src/node/webpack/get-webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function getWebpackConfig({
env,
options,
template,
publicFolder,
reporting = "fancy",
}: WebpackConfigArgs): Configuration {
const isProd = env === "production"
Expand Down Expand Up @@ -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"),
},
],
Expand Down
8 changes: 8 additions & 0 deletions packages/admin-ui/ui/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/admin-ui/webpack.config.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const getDevServerConfig = () => {
path: "/",
},
template: path.resolve(__dirname, "ui", "index.html"),
publicFolder: path.resolve(__dirname, "ui", "public"),
})

if (analyzeBundle) {
Expand Down

0 comments on commit 0a63878

Please sign in to comment.