diff --git a/components/playgroundEditor/LiveCodes.tsx b/components/playgroundEditor/LiveCodes.tsx index 493922a8..5ab6d757 100644 --- a/components/playgroundEditor/LiveCodes.tsx +++ b/components/playgroundEditor/LiveCodes.tsx @@ -3,6 +3,7 @@ import type { Config, Playground } from "livecodes"; import LiveCodesPlayground from "livecodes/react"; import { luaTestRunner, type Language } from "lib/playground/livecodes"; import { useDarkTheme } from "hooks/darkTheme"; +import { useRouter } from "next/router"; export default function LiveCodes({ language, @@ -15,6 +16,14 @@ export default function LiveCodes({ }) { const [playground, setPlayground] = useState(); const [darkTheme] = useDarkTheme(); + const { locale } = useRouter(); + + const getLanguageFromLocale = (locale_: string | undefined) => + !locale_ + ? "en" + : locale_ === "zh_Hans" + ? "zh-CN" + : (locale_.split("_")[0] as Config["appLanguage"]); const onReady = (sdk: Playground) => { setPlayground(sdk); @@ -31,6 +40,7 @@ export default function LiveCodes({ }, [playground, darkTheme]); const baseConfig: Partial = { + appLanguage: getLanguageFromLocale(locale), autoupdate: true, languages: [language === "jupyter" ? "python-wasm" : language], script: { @@ -42,6 +52,7 @@ export default function LiveCodes({ active: "console", status: "full", }, + themeColor: "hsl(205, 17%, 50%)", // the original theme color is "#3a4852" which is "hsl(205, 17%, 27%)" }; const getJSTSConfig = ( @@ -223,7 +234,7 @@ ${test.replace(pattern, "\n")}`.trimStart(); return (