Changing theme works for compatibility with mui localization
This commit is contained in:
20
gui/rpk-gui/src/components/I18nTheme.tsx
Normal file
20
gui/rpk-gui/src/components/I18nTheme.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import React, { PropsWithChildren } from "react";
|
||||
import { useTranslation } from "@refinedev/core";
|
||||
import { useTheme } from "@mui/material";
|
||||
import * as locales from '@mui/material/locale';
|
||||
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
||||
|
||||
type SupportedLocales = keyof typeof locales;
|
||||
|
||||
export const I18nTheme: React.FC<PropsWithChildren> = ({ children }: PropsWithChildren) => {
|
||||
const { getLocale } = useTranslation();
|
||||
const theme = useTheme()
|
||||
|
||||
const themeWithLocale = createTheme(theme, locales[getLocale() as SupportedLocales])
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={themeWithLocale}>
|
||||
{ children }
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user