mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-13 13:28:14 +00:00
When the language is changed the game will complety reload (same as F5). (#1438)
Also now only the current language type image is loaded. If it doesnt exist for a language it will load the english one as a fallback Tested with all lanugages
This commit is contained in:
parent
6059f0ee33
commit
8a6f87cfea
@ -206,23 +206,19 @@ export class LoadingScene extends SceneBase {
|
|||||||
this.loadAtlas("items", "");
|
this.loadAtlas("items", "");
|
||||||
this.loadAtlas("types", "");
|
this.loadAtlas("types", "");
|
||||||
|
|
||||||
(i18next.options.supportedLngs as Array<any>).forEach(lang => {
|
// Get current lang and load the types atlas for it. English will only load types while all other languages will load types and types_<lang>
|
||||||
switch (lang) {
|
const lang = i18next.language;
|
||||||
case "pt":
|
if (lang !== "en") {
|
||||||
lang = "pt_BR";
|
|
||||||
break;
|
|
||||||
case "zh":
|
|
||||||
lang = "zh_CN";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Utils.verifyLang(lang)) {
|
if (Utils.verifyLang(lang)) {
|
||||||
if (lang === "zh_CN") {
|
|
||||||
// Load also the traditional Chinese since it doesn't have a separate language code in supportedLngs
|
|
||||||
this.loadAtlas("types_zh_TW", "");
|
|
||||||
}
|
|
||||||
this.loadAtlas(`types_${lang}`, "");
|
this.loadAtlas(`types_${lang}`, "");
|
||||||
|
} else {
|
||||||
|
// Fallback to English
|
||||||
|
this.loadAtlas("types", "");
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
this.loadAtlas("types", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.loadAtlas("statuses", "");
|
this.loadAtlas("statuses", "");
|
||||||
this.loadAtlas("categories", "");
|
this.loadAtlas("categories", "");
|
||||||
|
@ -186,7 +186,8 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
|
|||||||
i18next.changeLanguage(locale);
|
i18next.changeLanguage(locale);
|
||||||
localStorage.setItem("prLang", locale);
|
localStorage.setItem("prLang", locale);
|
||||||
cancelHandler();
|
cancelHandler();
|
||||||
scene.reset(true, false, true);
|
// Reload the whole game to apply the new locale since also some constants are translated
|
||||||
|
window.location.reload();
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error changing locale:", error);
|
console.error("Error changing locale:", error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user