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:
VariableVince
2026-05-06 22:52:34 +02:00
parent 06b35c5ead
commit 035257fd99
2 changed files with 18 additions and 16 deletions
+1 -1
View File
@@ -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
View File
@@ -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}`;
}
}