From 035257fd9917c65816b707f2b42cc527012822a5 Mon Sep 17 00:00:00 2001 From: VariableVince <24507472+VariableVince@users.noreply.github.com> Date: Wed, 6 May 2026 22:52:34 +0200 Subject: [PATCH] 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 --- resources/lang/en.json | 2 +- src/client/Transport.ts | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index c220444ce..95d9cec35 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -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", diff --git a/src/client/Transport.ts b/src/client/Transport.ts index 2eb9851e8..8d73be15c 100644 --- a/src/client/Transport.ts +++ b/src/client/Transport.ts @@ -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}`; } }