@@ -3,6 +3,7 @@ import type { Config, Playground } from "livecodes";
3
3
import LiveCodesPlayground from "livecodes/react" ;
4
4
import { luaTestRunner , type Language } from "lib/playground/livecodes" ;
5
5
import { useDarkTheme } from "hooks/darkTheme" ;
6
+ import { useRouter } from "next/router" ;
6
7
7
8
export default function LiveCodes ( {
8
9
language,
@@ -15,6 +16,14 @@ export default function LiveCodes({
15
16
} ) {
16
17
const [ playground , setPlayground ] = useState < Playground | undefined > ( ) ;
17
18
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" ] ) ;
18
27
19
28
const onReady = ( sdk : Playground ) => {
20
29
setPlayground ( sdk ) ;
@@ -31,6 +40,7 @@ export default function LiveCodes({
31
40
} , [ playground , darkTheme ] ) ;
32
41
33
42
const baseConfig : Partial < Config > = {
43
+ appLanguage : getLanguageFromLocale ( locale ) ,
34
44
autoupdate : true ,
35
45
languages : [ language === "jupyter" ? "python-wasm" : language ] ,
36
46
script : {
@@ -224,7 +234,7 @@ ${test.replace(pattern, "\n")}`.trimStart();
224
234
225
235
return (
226
236
< LiveCodesPlayground
227
- appUrl = "https://v37 .livecodes.io/"
237
+ appUrl = "https://v38 .livecodes.io/"
228
238
loading = "eager"
229
239
config = { config }
230
240
style = { { borderRadius : "0" , resize : "none" } }
0 commit comments