Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

40 lignes
1.0 KiB

  1. "use client";
  2. import * as React from "react";
  3. import { ThemeProvider, createTheme } from "@mui/material/styles";
  4. import CssBaseline from "@mui/material/CssBaseline";
  5. import NextAppDirEmotionCacheProvider from "./EmotionCache";
  6. import theme from "./devias-material-kit";
  7. import { zhHK, enUS } from "@mui/material/locale";
  8. const getLocalizationFromLang = (lang: string) => {
  9. switch (lang) {
  10. case "zh":
  11. return zhHK;
  12. default:
  13. return enUS;
  14. }
  15. };
  16. // Copied from https://github.com/mui/material-ui/blob/master/examples/material-ui-nextjs-ts/src/components/ThemeRegistry/ThemeRegistry.tsx
  17. export default function ThemeRegistry({
  18. children,
  19. lang,
  20. }: {
  21. children: React.ReactNode;
  22. lang: string;
  23. }) {
  24. const themeWithLocale = React.useMemo(
  25. () => createTheme(theme, getLocalizationFromLang(lang)),
  26. [lang],
  27. );
  28. return (
  29. <NextAppDirEmotionCacheProvider options={{ key: "mui" }}>
  30. <ThemeProvider theme={themeWithLocale}>
  31. <CssBaseline />
  32. {children}
  33. </ThemeProvider>
  34. </NextAppDirEmotionCacheProvider>
  35. );
  36. }