File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import { ServiceWorkerMLCEngine } from "@mlc-ai/web-llm";
1818import MlcIcon from "../icons/mlc.svg" ;
1919import LoadingIcon from "../icons/three-dots.svg" ;
2020
21- import Locale from "../locales" ;
21+ import Locale , { changeLang , AllLangs , Lang } from "../locales" ;
2222import { getCSSVar , useMobileScreen } from "../utils" ;
2323import { DEFAULT_MODELS , Path , SlotID } from "../constant" ;
2424import { ErrorBoundary } from "./error" ;
Original file line number Diff line number Diff line change @@ -104,6 +104,16 @@ function getLanguage() {
104104}
105105
106106export function getLang ( ) : Lang {
107+ if ( typeof window !== "undefined" ) {
108+ const params = new URLSearchParams ( window . location . search ) ;
109+ if (
110+ params . get ( "lang" ) &&
111+ AllLangs . includes ( params . get ( "lang" ) ! . toLowerCase ( ) as Lang )
112+ ) {
113+ return params . get ( "lang" ) as Lang ;
114+ }
115+ }
116+
107117 const savedLang = getItem ( LANG_KEY ) ;
108118
109119 if ( AllLangs . includes ( ( savedLang ?? "" ) as Lang ) ) {
You can’t perform that action at this time.
0 commit comments