From c6e8f2f99844ff455b4e4b85bc5b36a336ba4254 Mon Sep 17 00:00:00 2001 From: Aotumuri Date: Sun, 25 May 2025 09:13:59 +0900 Subject: [PATCH] mls4error (#869) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description: I will implement MLS support for the error messages. ![スクリーンショット 2025-05-25 8 32 29](https://github.com/user-attachments/assets/90ceabe0-e12f-49e4-897a-a452f0949df3) ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --- resources/lang/en.json | 8 ++++++++ resources/lang/ja.json | 8 ++++++++ src/client/ClientGameRunner.ts | 16 ++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index 1a762dfb5..856598aff 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -413,5 +413,13 @@ "stop_trade": "Stop trading", "yes": "Yes", "no": "No" + }, + "error_modal": { + "crashed": "Game crashed!", + "paste_discord": "Please paste the following in your bug report in Discord:", + "copy_clipboard": "Copy to clipboard", + "copied": "Copied!", + "failed_copy": "Failed to copy", + "desync_notice": "You are desynced from other players. What you see might differ from other players." } } diff --git a/resources/lang/ja.json b/resources/lang/ja.json index dd5f9293d..7f1f93d7f 100644 --- a/resources/lang/ja.json +++ b/resources/lang/ja.json @@ -392,5 +392,13 @@ "stop_trade": "貿易を停止", "yes": "はい", "no": "いいえ" + }, + "error_modal": { + "crashed": "ゲームがクラッシュしました!", + "paste_discord": "以下の情報をDiscordのバグ報告に貼り付けてください:", + "copy_clipboard": "クリップボードにコピー", + "copied": "コピーしました!", + "failed_copy": "コピーに失敗しました", + "desync_notice": "あなたは他のプレイヤーと同期していません。画面に表示される内容が他のプレイヤーと異なる可能性があります。" } } diff --git a/src/client/ClientGameRunner.ts b/src/client/ClientGameRunner.ts index cc97289d2..6c2b5fcff 100644 --- a/src/client/ClientGameRunner.ts +++ b/src/client/ClientGameRunner.ts @@ -1,3 +1,4 @@ +import { translateText } from "../client/Utils"; import { consolex, initRemoteSender } from "../core/Consolex"; import { EventBus } from "../core/EventBus"; import { @@ -308,7 +309,7 @@ export class ClientGameRunner { this.lobby.gameStartInfo.gameID, this.lobby.clientID, true, - "You are desynced from other players. What you see might differ from other players.", + translateText("error_modal.desync_notice"), ); } if (message.type === "turn") { @@ -497,7 +498,7 @@ function showErrorModal( gameID: GameID, clientID: ClientID, closable = false, - heading = "Game crashed!", + heading = translateText("error_modal.crashed"), ) { const errorText = `Error: ${errMsg}\nStack: ${stack}`; @@ -506,22 +507,25 @@ function showErrorModal( } const modal = document.createElement("div"); + modal.id = "error-modal"; - const content = `${heading}\n game id: ${gameID}, client id: ${clientID}\nPlease paste the following in your bug report in Discord:\n${errorText}`; + const content = `${translateText(heading)}\n game id: ${gameID}, client id: ${clientID}\n${translateText("error_modal.paste_discord")}\n${errorText}`; // Create elements const pre = document.createElement("pre"); pre.textContent = content; const button = document.createElement("button"); - button.textContent = "Copy to clipboard"; + button.textContent = translateText("error_modal.copy_clipboard"); button.className = "copy-btn"; button.addEventListener("click", () => { navigator.clipboard .writeText(content) - .then(() => (button.textContent = "Copied!")) - .catch(() => (button.textContent = "Failed to copy")); + .then(() => (button.textContent = translateText("error_modal.copied"))) + .catch( + () => (button.textContent = translateText("error_modal.failed_copy")), + ); }); const closeButton = document.createElement("button");