mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-16 14:55:22 +01:00
[i18n] Replace hardcoded messages for Data import (#6795)
* localize confirm import message * localize error messages
This commit is contained in:
parent
c945a1b3f9
commit
4522e9e593
@ -1446,71 +1446,58 @@ export class GameData {
|
|||||||
globalScene.ui.showText(error, null, () => globalScene.ui.showText("", 0), fixedInt(1500));
|
globalScene.ui.showText(error, null, () => globalScene.ui.showText("", 0), fixedInt(1500));
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return globalScene.ui.showText(
|
return displayError(i18next.t("menuUiHandler:importCorrupt", { dataName }));
|
||||||
`Your ${dataName} data could not be loaded. It may be corrupted.`,
|
|
||||||
null,
|
|
||||||
() => globalScene.ui.showText("", 0),
|
|
||||||
fixedInt(1500),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
globalScene.ui.showText(
|
globalScene.ui.showText(i18next.t("menuUiHandler:confirmImport", { dataName }), null, () => {
|
||||||
`Your ${dataName} data will be overridden and the page will reload. Proceed?`,
|
globalScene.ui.setOverlayMode(
|
||||||
null,
|
UiMode.CONFIRM,
|
||||||
() => {
|
() => {
|
||||||
globalScene.ui.setOverlayMode(
|
localStorage.setItem(dataKey, encrypt(dataStr, bypassLogin));
|
||||||
UiMode.CONFIRM,
|
|
||||||
() => {
|
|
||||||
localStorage.setItem(dataKey, encrypt(dataStr, bypassLogin));
|
|
||||||
|
|
||||||
if (!bypassLogin && dataType < GameDataType.SETTINGS) {
|
if (!bypassLogin && dataType < GameDataType.SETTINGS) {
|
||||||
updateUserInfo().then(success => {
|
updateUserInfo().then(success => {
|
||||||
if (!success[0]) {
|
if (!success[0]) {
|
||||||
return displayError(
|
return displayError(i18next.t("menuUiHandler:importNoServer", { dataName }));
|
||||||
`Could not contact the server. Your ${dataName} data could not be imported.`,
|
}
|
||||||
);
|
const { trainerId, secretId } = this;
|
||||||
|
let updatePromise: Promise<string | null>;
|
||||||
|
if (dataType === GameDataType.SESSION) {
|
||||||
|
updatePromise = pokerogueApi.savedata.session.update(
|
||||||
|
{
|
||||||
|
slot: slotId,
|
||||||
|
trainerId,
|
||||||
|
secretId,
|
||||||
|
clientSessionId,
|
||||||
|
},
|
||||||
|
dataStr,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
updatePromise = pokerogueApi.savedata.system.update(
|
||||||
|
{ trainerId, secretId, clientSessionId },
|
||||||
|
dataStr,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
updatePromise.then(error => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
return displayError(i18next.t("menuUiHandler:importError", { dataName }));
|
||||||
}
|
}
|
||||||
const { trainerId, secretId } = this;
|
window.location.reload();
|
||||||
let updatePromise: Promise<string | null>;
|
|
||||||
if (dataType === GameDataType.SESSION) {
|
|
||||||
updatePromise = pokerogueApi.savedata.session.update(
|
|
||||||
{
|
|
||||||
slot: slotId,
|
|
||||||
trainerId,
|
|
||||||
secretId,
|
|
||||||
clientSessionId,
|
|
||||||
},
|
|
||||||
dataStr,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
updatePromise = pokerogueApi.savedata.system.update(
|
|
||||||
{ trainerId, secretId, clientSessionId },
|
|
||||||
dataStr,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
updatePromise.then(error => {
|
|
||||||
if (error) {
|
|
||||||
console.error(error);
|
|
||||||
return displayError(
|
|
||||||
`An error occurred while updating ${dataName} data. Please contact the administrator.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
window.location.reload();
|
} else {
|
||||||
}
|
window.location.reload();
|
||||||
},
|
}
|
||||||
() => {
|
},
|
||||||
globalScene.ui.revertMode();
|
() => {
|
||||||
globalScene.ui.showText("", 0);
|
globalScene.ui.revertMode();
|
||||||
},
|
globalScene.ui.showText("", 0);
|
||||||
false,
|
},
|
||||||
-98,
|
false,
|
||||||
);
|
-98,
|
||||||
},
|
);
|
||||||
);
|
});
|
||||||
};
|
};
|
||||||
})((e.target as any).files[0]);
|
})((e.target as any).files[0]);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user