From 9401f204360dc3070dbe82ad447b3c0183769b4b Mon Sep 17 00:00:00 2001 From: its-sii Date: Mon, 9 Jun 2025 18:34:58 -0400 Subject: [PATCH] Adding unit info modal translation support. (#1122) ## Description: Adding translation support for unit info modal. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [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 Regression test to make sure UI is still displaying as expected ![image](https://github.com/user-attachments/assets/bad18084-a4bb-479c-a3dd-74c9c541fdb0) ## Please put your Discord username so you can be contacted if a bug or regression is found: sii --- resources/lang/en.json | 7 +++++++ src/client/graphics/layers/UnitInfoModal.ts | 14 +++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index 34d9b0d4b..030f08916 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -406,6 +406,13 @@ "retreating": "retreating", "boat": "Boat" }, + "unit_info_modal": { + "structure_info": "Structure Info", + "unit_type_unknown": "Unknown", + "close": "Close", + "cooldown": "Cooldown", + "type": "Type" + }, "relation": { "hostile": "Hostile", "distrustful": "Distrustful", diff --git a/src/client/graphics/layers/UnitInfoModal.ts b/src/client/graphics/layers/UnitInfoModal.ts index 131f9c028..0066aa309 100644 --- a/src/client/graphics/layers/UnitInfoModal.ts +++ b/src/client/graphics/layers/UnitInfoModal.ts @@ -1,5 +1,6 @@ import { LitElement, css, html } from "lit"; import { customElement, property } from "lit/decorators.js"; +import { translateText } from "../../../client/Utils"; import { UnitType } from "../../../core/game/Game"; import { GameView, UnitView } from "../../../core/game/GameView"; import { Layer } from "./Layer"; @@ -133,14 +134,17 @@ export class UnitInfoModal extends LitElement implements Layer { .x}px; top: ${this.y}px; position: absolute;" >
- Structure Info + ${translateText("unit_info_modal.structure_info")}
- Type: ${this.unit.type?.() ?? "Unknown"} + ${translateText("unit_info_modal.type")}: + ${translateText(+"unit_type." + this.unit.type?.().toLowerCase()) ?? + translateText("unit_info_modal.unit_type_unknown")}
${secondsLeft > 0 ? html`
- Cooldown: ${secondsLeft}s + ${translateText("unit_info_modal.cooldown")} + ${secondsLeft}s
` : ""}
@@ -152,10 +156,10 @@ export class UnitInfoModal extends LitElement implements Layer { } }} class="close-button" - title="Close" + title="${translateText("unit_info_modal.close")}" style="width: 100px; height: 32px;" > - CLOSE + ${translateText("unit_info_modal.close")}