fix(dashboard): Prevent language ptBR from breaking dashboard (#10422)

This commit is contained in:
Kasper Fabricius Kristensen
2024-12-04 10:44:04 +01:00
committed by GitHub
parent e8f4f7ea2b
commit a5c8cc992c
5 changed files with 17 additions and 8 deletions

View File

@@ -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: {

View File

@@ -5,6 +5,10 @@ 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()
@@ -12,5 +16,5 @@ export const I18nProvider = ({ children }: I18nProviderProps) => {
languages.find((lan) => lan.code === i18n.language)?.code ||
languages[0].code
return <Provider locale={locale}>{children}</Provider>
return <Provider locale={formatLocaleCode(locale)}>{children}</Provider>
}

View File

@@ -4,7 +4,7 @@ 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"
@@ -12,7 +12,7 @@ import { useUpdateUser } from "../../../../../hooks/api/users"
import { languages } from "../../../../../i18n/languages"
type EditProfileProps = {
user: Partial<Omit<UserDTO, "password_hash">>
user: HttpTypes.AdminUser
// usageInsights: boolean
}

View File

@@ -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>
)
}