From ff17d321c7d6e4ad80f9c6852dedf8cc4750f79b Mon Sep 17 00:00:00 2001 From: VariableVince <24507472+VariableVince@users.noreply.github.com> Date: Wed, 23 Jul 2025 20:44:57 +0200 Subject: [PATCH] Fix: display actual Alliance extension message instead of translation key (#1532) ## Description: On Alliance extension, the key "events_display.alliance_renewed" is displayed in the Event Panel. Reported in https://discord.com/channels/1284581928254701718/1397197460085932184 Since displayMessage doesn't expect or do translations, just puts out hardcoded English messages so far, it doesn't do anything with the recieved key and just puts it in the Event Panel as is. This PR fixes it as a follow-up of #1359. With this, it also introduces a base which can be used to translate hardcoded messages coming from other Executions. That is out of the scope of this PR. PRs #1532 and #1536 both fix issues with Alliance Renewal in v24. If possible approve 1532 (this one) first and then 1536 not too far after if github can indeed merge them. BEFORE: alliancerenewbefore AFTER: (tested locally with Nations by not checking their answer; they normally don't answer to alliance renewal request which is another issue) After fix ## 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 have read and accepted the CLA aggreement (only required once). ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33 --- src/client/graphics/layers/EventsDisplay.ts | 9 ++++++++- .../execution/alliance/AllianceExtensionExecution.ts | 4 ++++ src/core/game/Game.ts | 1 + src/core/game/GameImpl.ts | 2 ++ src/core/game/GameUpdates.ts | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/client/graphics/layers/EventsDisplay.ts b/src/client/graphics/layers/EventsDisplay.ts index 98b806fdf..92bff376c 100644 --- a/src/client/graphics/layers/EventsDisplay.ts +++ b/src/client/graphics/layers/EventsDisplay.ts @@ -351,8 +351,15 @@ export class EventsDisplay extends LitElement implements Layer { } } + let description: string = event.message; + if (event.params !== undefined) { + if (event.message.startsWith("events_display.")) { + description = translateText(event.message, event.params); + } + } + this.addEvent({ - description: event.message, + description: description, createdAt: this.game.ticks(), highlight: true, type: event.messageType, diff --git a/src/core/execution/alliance/AllianceExtensionExecution.ts b/src/core/execution/alliance/AllianceExtensionExecution.ts index e0cb14d4d..2469d9038 100644 --- a/src/core/execution/alliance/AllianceExtensionExecution.ts +++ b/src/core/execution/alliance/AllianceExtensionExecution.ts @@ -46,11 +46,15 @@ export class AllianceExtensionExecution implements Execution { "events_display.alliance_renewed", MessageType.ALLIANCE_ACCEPTED, this.from.id(), + undefined, + { name: to.displayName() }, ); mg.displayMessage( "events_display.alliance_renewed", MessageType.ALLIANCE_ACCEPTED, this.toID, + undefined, + { name: this.from.displayName() }, ); } } diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 7af496501..32328bd44 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -667,6 +667,7 @@ export interface Game extends GameMap { type: MessageType, playerID: PlayerID | null, goldAmount?: bigint, + params?: Record, ): void; displayIncomingUnit( unitID: number, diff --git a/src/core/game/GameImpl.ts b/src/core/game/GameImpl.ts index 1208cc4a7..1cb78faf8 100644 --- a/src/core/game/GameImpl.ts +++ b/src/core/game/GameImpl.ts @@ -675,6 +675,7 @@ export class GameImpl implements Game { type: MessageType, playerID: PlayerID | null, goldAmount?: bigint, + params?: Record, ): void { let id: number | null = null; if (playerID !== null) { @@ -686,6 +687,7 @@ export class GameImpl implements Game { message: message, playerID: id, goldAmount: goldAmount, + params: params, }); } diff --git a/src/core/game/GameUpdates.ts b/src/core/game/GameUpdates.ts index 97cfa2531..02f9ffbd6 100644 --- a/src/core/game/GameUpdates.ts +++ b/src/core/game/GameUpdates.ts @@ -216,6 +216,7 @@ export interface DisplayMessageUpdate { messageType: MessageType; goldAmount?: bigint; playerID: number | null; + params?: Record; } export type DisplayChatMessageUpdate = {