mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-13 05:15:17 +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("types", "");
|
||||
|
||||
(i18next.options.supportedLngs as Array<any>).forEach(lang => {
|
||||
switch (lang) {
|
||||
case "pt":
|
||||
lang = "pt_BR";
|
||||
break;
|
||||
case "zh":
|
||||
lang = "zh_CN";
|
||||
break;
|
||||
}
|
||||
// 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>
|
||||
const lang = i18next.language;
|
||||
if (lang !== "en") {
|
||||
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}`, "");
|
||||
} else {
|
||||
// Fallback to English
|
||||
this.loadAtlas("types", "");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.loadAtlas("types", "");
|
||||
}
|
||||
|
||||
|
||||
this.loadAtlas("statuses", "");
|
||||
this.loadAtlas("categories", "");
|
||||
|
@ -186,7 +186,8 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
|
||||
i18next.changeLanguage(locale);
|
||||
localStorage.setItem("prLang", locale);
|
||||
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;
|
||||
} catch (error) {
|
||||
console.error("Error changing locale:", error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user