@@ -3,6 +3,7 @@ import type { Config, Playground } from "livecodes";
33import LiveCodesPlayground from "livecodes/react" ;
44import { luaTestRunner , type Language } from "lib/playground/livecodes" ;
55import { useDarkTheme } from "hooks/darkTheme" ;
6+ import { useRouter } from "next/router" ;
67
78export default function LiveCodes ( {
89 language,
@@ -15,6 +16,14 @@ export default function LiveCodes({
1516} ) {
1617 const [ playground , setPlayground ] = useState < Playground | undefined > ( ) ;
1718 const [ darkTheme ] = useDarkTheme ( ) ;
19+ const { locale } = useRouter ( ) ;
20+
21+ const getLanguageFromLocale = ( locale_ : string | undefined ) =>
22+ ! locale_
23+ ? "en"
24+ : locale_ === "zh_Hans"
25+ ? "zh-CN"
26+ : ( locale_ . split ( "_" ) [ 0 ] as Config [ "appLanguage" ] ) ;
1827
1928 const onReady = ( sdk : Playground ) => {
2029 setPlayground ( sdk ) ;
@@ -31,6 +40,7 @@ export default function LiveCodes({
3140 } , [ playground , darkTheme ] ) ;
3241
3342 const baseConfig : Partial < Config > = {
43+ appLanguage : getLanguageFromLocale ( locale ) ,
3444 autoupdate : true ,
3545 languages : [ language === "jupyter" ? "python-wasm" : language ] ,
3646 script : {
@@ -42,6 +52,7 @@ export default function LiveCodes({
4252 active : "console" ,
4353 status : "full" ,
4454 } ,
55+ themeColor : "hsl(205, 17%, 50%)" , // the original theme color is "#3a4852" which is "hsl(205, 17%, 27%)"
4556 } ;
4657
4758 const getJSTSConfig = (
@@ -223,7 +234,7 @@ ${test.replace(pattern, "\n")}`.trimStart();
223234
224235 return (
225236 < LiveCodesPlayground
226- appUrl = "https://v34 .livecodes.io/"
237+ appUrl = "https://v39 .livecodes.io/"
227238 loading = "eager"
228239 config = { config }
229240 style = { { borderRadius : "0" , resize : "none" } }
0 commit comments