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");