File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,15 @@ let languages: string[] = [];
44const strings : Record < string , any > = { } ;
55let currentLang : string = "en" ;
66
7- export async function loadLanguages ( langs : string [ ] ) {
7+ export async function loadLanguages ( langs : string [ ] , startLang : string ) {
88 languages = langs ;
99 for ( const code of languages ) {
1010 const response = await fetch ( `/locales/${ code } .json` , {
1111 cache : "no-cache" ,
1212 } ) ;
1313 strings [ code ] = await response . json ( ) ;
1414 }
15+ currentLang = startLang ;
1516}
1617
1718export async function switchLanguage ( node : any ) {
Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ import Game from "./Game";
22import { loadLanguages } from "./i18n" ;
33
44( async ( ) => {
5- await loadLanguages ( [ "en" ] ) ;
5+ const urlParams = new URLSearchParams ( window . location . search ) ;
6+ await loadLanguages ( [ "en" ] , urlParams . get ( "lang" ) || "en" ) ;
67 // load "fake" language for testing translations
7- // await loadLanguages(["en", "fake"]);
8+ // await loadLanguages(["en", "fake"], urlParams.get("lang") || "en" );
89 const game = new Game ( ) ;
910 await game . start ( ) ;
1011} ) ( ) ;
You can’t perform that action at this time.
0 commit comments