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 <evanpelle@gmail.com>
This commit is contained in:
Tomasz
2025-07-01 04:06:50 +02:00
committed by GitHub
parent c8fa802d1e
commit 91adf1fa8b
4 changed files with 33 additions and 9 deletions
+15 -1
View File
@@ -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",
+10 -2
View File
@@ -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`
<aside
@@ -79,9 +87,9 @@ export class GameLeftSidebar extends LitElement implements Layer {
class="flex items-center w-full h-8 lg:h-10 text-white py-1 lg:p-2"
@contextmenu=${(e: Event) => e.preventDefault()}
>
Your team:
${translateText("help_modal.ui_your_team")}
<span style="color: ${this.playerColor.toRgbString()}">
${this.playerTeam} &#10687;
${this.getTranslatedPlayerTeamLabel()} &#10687;
</span>
</div>
`
+3 -1
View File
@@ -187,7 +187,9 @@ export class Leaderboard extends LitElement implements Layer {
this.updateLeaderboard();
}}
>
${this.showTopFive ? "Show All" : "Show Top 5"}
${this.showTopFive
? translateText("leaderboard.show_all")
: translateText("leaderboard.show_top_5")}
</button>
<div
+5 -5
View File
@@ -3,7 +3,7 @@ import { customElement, property } from "lit/decorators.js";
import { EventBus } from "../../../core/EventBus";
import { GameMode } from "../../../core/game/Game";
import { GameView, PlayerView } from "../../../core/game/GameView";
import { renderNumber } from "../../Utils";
import { renderNumber, translateText } from "../../Utils";
import { Layer } from "./Layer";
interface TeamEntry {
@@ -113,22 +113,22 @@ export class TeamStats extends LitElement implements Layer {
<div
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 cursor-pointer"
>
Team
${translateText("leaderboard.team")}
</div>
<div
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 cursor-pointer"
>
Owned
${translateText("leaderboard.owned")}
</div>
<div
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 cursor-pointer"
>
Gold
${translateText("leaderboard.gold")}
</div>
<div
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 cursor-pointer"
>
Troops
${translateText("leaderboard.troops")}
</div>
</div>
${this.teams.map(