mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:10:42 +00:00
Display raw error.reason if we (on purpose or from oversight) have no translation for it, like "ClientJoinMessageSchema", "WS_ERR_UNEXPECTED_RSV_1" or cosmetics.reason.
Fix translation key name for "forbidden" in en.json
This commit is contained in:
@@ -1224,7 +1224,7 @@
|
||||
"account_banned": "Account Banned",
|
||||
"cannot_join_game": "Cannot join game",
|
||||
"connection_refused": "Connection refused",
|
||||
"flare_forbidden": "Forbidden",
|
||||
"forbidden": "Forbidden",
|
||||
"game_not_found": "Game not found",
|
||||
"lobby_full": "Lobby full",
|
||||
"turnstile_invalid": "Unauthorized: invalid token",
|
||||
|
||||
+17
-15
@@ -380,24 +380,26 @@ export class Transport {
|
||||
);
|
||||
if (event.code === 1002) {
|
||||
const connRefusedKey = `worker_error.connection_refused`;
|
||||
let alertMsg = translateText(connRefusedKey);
|
||||
const errorKey = `worker_error.${event.reason}`;
|
||||
alertMsg += `: ${translateText(errorKey)}`;
|
||||
|
||||
// Add tips if turnstile token invalid
|
||||
if (event.reason === "turnstile_invalid") {
|
||||
alertMsg += `\n\n${translateText("worker_error.turnstile_fix_tips")}`;
|
||||
}
|
||||
let alertMsg = `${translateText(connRefusedKey)}: `;
|
||||
let translatedError = translateText(errorKey);
|
||||
|
||||
// Append English error if it differs, for screenshots posted by users
|
||||
const englishMsg = getEnglishText(errorKey);
|
||||
if (!alertMsg.includes(englishMsg)) {
|
||||
const englishConnRefusedMsg = getEnglishText(connRefusedKey);
|
||||
alertMsg += `\n\n--- English ---\n${englishConnRefusedMsg}: `;
|
||||
if (englishMsg !== errorKey) {
|
||||
alertMsg += `${englishMsg}`;
|
||||
} else if (englishMsg === errorKey) {
|
||||
alertMsg += `${event.reason}`;
|
||||
if (translatedError === errorKey) {
|
||||
// No translation key in error.reason or no translation or default English found
|
||||
alertMsg += `${event.reason}`;
|
||||
} else {
|
||||
alertMsg += translatedError;
|
||||
|
||||
// Add tips if token invalid
|
||||
if (event.reason === "turnstile_invalid") {
|
||||
alertMsg += `\n${translateText("worker_error.turnstile_fix_tips")}`;
|
||||
}
|
||||
|
||||
// Append English translation if it differs
|
||||
const englishMsg = getEnglishText(errorKey);
|
||||
if (englishMsg !== errorKey && !alertMsg.includes(englishMsg)) {
|
||||
alertMsg += `\n\n--- English ---\n${getEnglishText(connRefusedKey)}: ${englishMsg}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user