From 91adf1fa8b2cc63d09c0d6c55264250a5b443c37 Mon Sep 17 00:00:00 2001 From: Tomasz <58752526+TomaszOleszko@users.noreply.github.com> Date: Tue, 1 Jul 2025 04:06:50 +0200 Subject: [PATCH] Add localization support for leaderboard and team-related UI elements (#1308) ## Description: As in the title ## Please complete the following: - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [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 ## Please put your Discord username so you can be contacted if a bug or regression is found: pierogi69 --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: evanpelle --- resources/lang/en.json | 16 +++++++++++++++- src/client/graphics/layers/GameLeftSidebar.ts | 12 ++++++++++-- src/client/graphics/layers/Leaderboard.ts | 4 +++- src/client/graphics/layers/TeamStats.ts | 10 +++++----- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index fab3cead6..9191490b4 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -43,6 +43,7 @@ "action_reset_gfx": "Reset graphics", "ui_section": "Game UI", "ui_leaderboard": "Leaderboard", + "ui_your_team": "Your team:", "ui_leaderboard_desc": "Shows the top players of the game and their names, % owned land, gold and troops. Using Show All shows all players in the game. If you don't want to see the leaderboard, click Hide.", "ui_control": "Control panel", "ui_control_desc": "The control panel contains the following elements:", @@ -203,6 +204,16 @@ "waiting": "Waiting for players...", "start": "Start Game" }, + "team_colors": { + "red": "Red", + "blue": "Blue", + "teal": "Teal", + "purple": "Purple", + "yellow": "Yellow", + "orange": "Orange", + "green": "Green", + "bot": "Bot" + }, "game_starting_modal": { "title": "Game is Starting...", "desc": "Preparing for the lobby to start. Please wait." @@ -392,9 +403,12 @@ "hide": "Hide", "rank": "Rank", "player": "Player", + "team": "Team", "owned": "Owned", "gold": "Gold", - "troops": "Troops" + "troops": "Troops", + "show_top_5": "Show Top 5", + "show_all": "Show All" }, "player_info_overlay": { "type": "Type", diff --git a/src/client/graphics/layers/GameLeftSidebar.ts b/src/client/graphics/layers/GameLeftSidebar.ts index 2f4bb2f6f..fc38ca1a4 100644 --- a/src/client/graphics/layers/GameLeftSidebar.ts +++ b/src/client/graphics/layers/GameLeftSidebar.ts @@ -3,6 +3,7 @@ import { html, LitElement } from "lit"; import { customElement, state } from "lit/decorators.js"; import { GameMode } from "../../../core/game/Game"; import { GameView } from "../../../core/game/GameView"; +import { translateText } from "../../Utils"; import "../icons/LeaderboardRegularIcon"; import "../icons/LeaderboardSolidIcon"; import "../icons/TeamRegularIcon"; @@ -66,6 +67,13 @@ export class GameLeftSidebar extends LitElement implements Layer { return this.game?.config().gameConfig().gameMode === GameMode.Team; } + private getTranslatedPlayerTeamLabel(): string { + if (!this.playerTeam) return ""; + const translationKey = `team_colors.${this.playerTeam.toLowerCase()}`; + const translated = translateText(translationKey); + return translated === translationKey ? this.playerTeam : translated; + } + render() { return html`