mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-21 08:26:49 +00:00
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:
co-authored by
coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
evanpelle
parent
c8fa802d1e
commit
91adf1fa8b
@@ -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} ⦿
|
||||
${this.getTranslatedPlayerTeamLabel()} ⦿
|
||||
</span>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user