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-06-30 19:06:50 -07:00
committed by GitHub
co-authored by coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> evanpelle
parent c8fa802d1e
commit 91adf1fa8b
4 changed files with 33 additions and 9 deletions
+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>
`