Skip to content

Commit

Permalink
fix(dashboard): Prevent language ptBR from breaking dashboard (medusa…
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperkristensen authored Dec 4, 2024
1 parent e8f4f7e commit a5c8cc9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-lamps-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---

fix(dashboard): Prevent language ptBR from breaking dashboard
2 changes: 1 addition & 1 deletion packages/admin/dashboard/src/i18n/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import fr from "./fr.json"
import it from "./it.json"
import pl from "./pl.json"
import ptBR from "./ptBR.json"
import tr from "./tr.json"
import th from "./th.json"
import tr from "./tr.json"

export default {
de: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { languages } from "../../i18n/languages"

type I18nProviderProps = PropsWithChildren

const formatLocaleCode = (code: string) => {
return code.replace(/([a-z])([A-Z])/g, "$1-$2")
}

export const I18nProvider = ({ children }: I18nProviderProps) => {
const { i18n } = useTranslation()

const locale =
languages.find((lan) => lan.code === i18n.language)?.code ||
languages[0].code

return <Provider locale={locale}>{children}</Provider>
return <Provider locale={formatLocaleCode(locale)}>{children}</Provider>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next"
import * as zod from "zod"

import { UserDTO } from "@medusajs/types"
import { HttpTypes } from "@medusajs/types"
import { Form } from "../../../../../components/common/form"
import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
import { useUpdateUser } from "../../../../../hooks/api/users"
import { languages } from "../../../../../i18n/languages"

type EditProfileProps = {
user: Partial<Omit<UserDTO, "password_hash">>
user: HttpTypes.AdminUser
// usageInsights: boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const ProfileEdit = () => {
return (
<RouteDrawer>
<RouteDrawer.Header className="capitalize">
<Heading>{t("profile.edit.header")}</Heading>
<RouteDrawer.Title asChild>
<Heading>{t("profile.edit.header")}</Heading>
</RouteDrawer.Title>
</RouteDrawer.Header>
{!isLoading && user && (
<EditProfileForm user={user} usageInsights={false} />
)}
{!isLoading && user && <EditProfileForm user={user} />}
</RouteDrawer>
)
}

0 comments on commit a5c8cc9

Please sign in to comment.