mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-27 18:34:16 +00:00
Translate displayMessage events via events_display keys (#2847)
If this PR fixes an issue, link it below. If not, delete these two lines. Resolves #1225 ## Description: Replace all raw displayMessage strings with events_display.* keys + params and add the new English translations in resources/ lang/en.json so EventsDisplay can translate them. ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: aotumuri --------- Co-authored-by: Ryan <7389646+ryanbarlow97@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
+14
-1
@@ -711,7 +711,20 @@
|
||||
"wants_to_renew_alliance": "{name} wants to renew your alliance",
|
||||
"ignore": "Ignore",
|
||||
"unit_voluntarily_deleted": "Unit voluntarily deleted",
|
||||
"betrayal_debuff_ends": "{time} seconds left until betrayal debuff ends"
|
||||
"betrayal_debuff_ends": "{time} seconds left until betrayal debuff ends",
|
||||
"attack_cancelled_retreat": "Attack cancelled, {troops} soldiers killed during retreat",
|
||||
"received_gold_from_captured_ship": "Received {gold} gold from ship captured from {name}",
|
||||
"received_gold_from_trade": "Received {gold} gold from trade with {name}",
|
||||
"missile_intercepted": "Missile intercepted {unit}",
|
||||
"mirv_warheads_intercepted": "{count, plural, one {{count} MIRV warhead intercepted} other {{count} MIRV warheads intercepted}}",
|
||||
"sent_troops_to_player": "Sent {troops} troops to {name}",
|
||||
"received_troops_from_player": "Received {troops} troops from {name}",
|
||||
"sent_gold_to_player": "Sent {gold} gold to {name}",
|
||||
"received_gold_from_player": "Received {gold} gold from {name}",
|
||||
"unit_captured_by_enemy": "Your {unit} was captured by {name}",
|
||||
"captured_enemy_unit": "Captured {unit} from {name}",
|
||||
"unit_destroyed": "Your {unit} was destroyed",
|
||||
"no_boats_available": "No boats available, max {max}"
|
||||
},
|
||||
"unit_info_modal": {
|
||||
"structure_info": "Structure Info",
|
||||
|
||||
@@ -189,9 +189,11 @@ export class AttackExecution implements Execution {
|
||||
const deaths = this.attack.troops() * (malusPercent / 100);
|
||||
if (deaths) {
|
||||
this.mg.displayMessage(
|
||||
`Attack cancelled, ${renderTroops(deaths)} soldiers killed during retreat.`,
|
||||
"events_display.attack_cancelled_retreat",
|
||||
MessageType.ATTACK_CANCELLED,
|
||||
this._owner.id(),
|
||||
undefined,
|
||||
{ troops: renderTroops(deaths) },
|
||||
);
|
||||
}
|
||||
if (this.removeTroops === false && this.sourceTile === null) {
|
||||
|
||||
@@ -272,9 +272,11 @@ export class SAMLauncherExecution implements Execution {
|
||||
|
||||
// Message
|
||||
this.mg.displayMessage(
|
||||
`${mirvWarheadTargets.length} MIRV warheads intercepted`,
|
||||
"events_display.mirv_warheads_intercepted",
|
||||
MessageType.SAM_HIT,
|
||||
samOwner.id(),
|
||||
undefined,
|
||||
{ count: mirvWarheadTargets.length },
|
||||
);
|
||||
|
||||
mirvWarheadTargets.forEach(({ unit: u }) => {
|
||||
|
||||
@@ -61,9 +61,11 @@ export class SAMMissileExecution implements Execution {
|
||||
);
|
||||
if (result === true) {
|
||||
this.mg.displayMessage(
|
||||
`Missile intercepted ${this.target.type()}`,
|
||||
"events_display.missile_intercepted",
|
||||
MessageType.SAM_HIT,
|
||||
this._owner.id(),
|
||||
undefined,
|
||||
{ unit: this.target.type() },
|
||||
);
|
||||
this.active = false;
|
||||
this.target.delete(true, this._owner);
|
||||
|
||||
@@ -142,10 +142,14 @@ export class TradeShipExecution implements Execution {
|
||||
if (this.wasCaptured) {
|
||||
this.tradeShip!.owner().addGold(gold, this._dstPort.tile());
|
||||
this.mg.displayMessage(
|
||||
`Received ${renderNumber(gold)} gold from ship captured from ${this.origOwner.displayName()}`,
|
||||
"events_display.received_gold_from_captured_ship",
|
||||
MessageType.CAPTURED_ENEMY_UNIT,
|
||||
this.tradeShip!.owner().id(),
|
||||
gold,
|
||||
{
|
||||
gold: renderNumber(gold),
|
||||
name: this.origOwner.displayName(),
|
||||
},
|
||||
);
|
||||
// Record stats
|
||||
this.mg
|
||||
@@ -155,16 +159,24 @@ export class TradeShipExecution implements Execution {
|
||||
this.srcPort.owner().addGold(gold);
|
||||
this._dstPort.owner().addGold(gold, this._dstPort.tile());
|
||||
this.mg.displayMessage(
|
||||
`Received ${renderNumber(gold)} gold from trade with ${this.srcPort.owner().displayName()}`,
|
||||
"events_display.received_gold_from_trade",
|
||||
MessageType.RECEIVED_GOLD_FROM_TRADE,
|
||||
this._dstPort.owner().id(),
|
||||
gold,
|
||||
{
|
||||
gold: renderNumber(gold),
|
||||
name: this.srcPort.owner().displayName(),
|
||||
},
|
||||
);
|
||||
this.mg.displayMessage(
|
||||
`Received ${renderNumber(gold)} gold from trade with ${this._dstPort.owner().displayName()}`,
|
||||
"events_display.received_gold_from_trade",
|
||||
MessageType.RECEIVED_GOLD_FROM_TRADE,
|
||||
this.srcPort.owner().id(),
|
||||
gold,
|
||||
{
|
||||
gold: renderNumber(gold),
|
||||
name: this._dstPort.owner().displayName(),
|
||||
},
|
||||
);
|
||||
// Record stats
|
||||
this.mg
|
||||
|
||||
@@ -77,9 +77,11 @@ export class TransportShipExecution implements Execution {
|
||||
mg.config().boatMaxNumber()
|
||||
) {
|
||||
mg.displayMessage(
|
||||
`No boats available, max ${mg.config().boatMaxNumber()}`,
|
||||
"events_display.no_boats_available",
|
||||
MessageType.ATTACK_FAILED,
|
||||
this.attacker.id(),
|
||||
undefined,
|
||||
{ max: mg.config().boatMaxNumber() },
|
||||
);
|
||||
this.active = false;
|
||||
return;
|
||||
@@ -270,9 +272,11 @@ export class TransportShipExecution implements Execution {
|
||||
.boatArriveTroops(this.attacker, this.target, survivors);
|
||||
if (deaths) {
|
||||
this.mg.displayMessage(
|
||||
`Attack cancelled, ${renderTroops(deaths)} soldiers killed during retreat.`,
|
||||
"events_display.attack_cancelled_retreat",
|
||||
MessageType.ATTACK_CANCELLED,
|
||||
this.attacker.id(),
|
||||
undefined,
|
||||
{ troops: renderTroops(deaths) },
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -665,14 +665,18 @@ export class PlayerImpl implements Player {
|
||||
|
||||
this.sentDonations.push(new Donation(recipient, this.mg.ticks()));
|
||||
this.mg.displayMessage(
|
||||
`Sent ${renderTroops(troops)} troops to ${recipient.name()}`,
|
||||
"events_display.sent_troops_to_player",
|
||||
MessageType.SENT_TROOPS_TO_PLAYER,
|
||||
this.id(),
|
||||
undefined,
|
||||
{ troops: renderTroops(troops), name: recipient.name() },
|
||||
);
|
||||
this.mg.displayMessage(
|
||||
`Received ${renderTroops(troops)} troops from ${this.name()}`,
|
||||
"events_display.received_troops_from_player",
|
||||
MessageType.RECEIVED_TROOPS_FROM_PLAYER,
|
||||
recipient.id(),
|
||||
undefined,
|
||||
{ troops: renderTroops(troops), name: this.name() },
|
||||
);
|
||||
return true;
|
||||
}
|
||||
@@ -685,15 +689,18 @@ export class PlayerImpl implements Player {
|
||||
|
||||
this.sentDonations.push(new Donation(recipient, this.mg.ticks()));
|
||||
this.mg.displayMessage(
|
||||
`Sent ${renderNumber(gold)} gold to ${recipient.name()}`,
|
||||
"events_display.sent_gold_to_player",
|
||||
MessageType.SENT_GOLD_TO_PLAYER,
|
||||
this.id(),
|
||||
undefined,
|
||||
{ gold: renderNumber(gold), name: recipient.name() },
|
||||
);
|
||||
this.mg.displayMessage(
|
||||
`Received ${renderNumber(gold)} gold from ${this.name()}`,
|
||||
"events_display.received_gold_from_player",
|
||||
MessageType.RECEIVED_GOLD_FROM_PLAYER,
|
||||
recipient.id(),
|
||||
gold,
|
||||
{ gold: renderNumber(gold), name: this.name() },
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -206,14 +206,18 @@ export class UnitImpl implements Unit {
|
||||
this._owner._units.push(this);
|
||||
this.mg.addUpdate(this.toUpdate());
|
||||
this.mg.displayMessage(
|
||||
`Your ${this.type()} was captured by ${newOwner.displayName()}`,
|
||||
"events_display.unit_captured_by_enemy",
|
||||
MessageType.UNIT_CAPTURED_BY_ENEMY,
|
||||
this._lastOwner.id(),
|
||||
undefined,
|
||||
{ unit: this.type(), name: newOwner.displayName() },
|
||||
);
|
||||
this.mg.displayMessage(
|
||||
`Captured ${this.type()} from ${this._lastOwner.displayName()}`,
|
||||
"events_display.captured_enemy_unit",
|
||||
MessageType.CAPTURED_ENEMY_UNIT,
|
||||
newOwner.id(),
|
||||
undefined,
|
||||
{ unit: this.type(), name: this._lastOwner.displayName() },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -304,9 +308,11 @@ export class UnitImpl implements Unit {
|
||||
}
|
||||
|
||||
this.mg.displayMessage(
|
||||
`Your ${this._type} was destroyed`,
|
||||
"events_display.unit_destroyed",
|
||||
MessageType.UNIT_DESTROYED,
|
||||
this.owner().id(),
|
||||
undefined,
|
||||
{ unit: this._type },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user