Differential D1613 Diff 10239 binaries/data/mods/public/gui/session/chat/ChatMessageFormatSimulation.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/chat/ChatMessageFormatSimulation.js
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
parse(msg) | parse(msg) | ||||
{ | { | ||||
if (!msg.message.pluralMessage) | if (!msg.message.pluralMessage) | ||||
return sprintf(translate(msg.message), { | return sprintf(translate(msg.message), { | ||||
"player": colorizePlayernameByID(msg.players[0]) | "player": colorizePlayernameByID(msg.players[0]) | ||||
}); | }); | ||||
let mPlayers = msg.players.map(playerID => colorizePlayernameByID(playerID)); | let players = msg.players.map(playerID => colorizePlayernameByID(playerID)); | ||||
let lastPlayer = mPlayers.pop(); | let playerCount = msg.players.length; | ||||
if (playerCount == 1) { | |||||
return sprintf(translatePlural(msg.message.message, msg.message.pluralMessage, msg.message.pluralCount), { | let playerList = players[0]; | ||||
} else if (playerCount == 2) { | |||||
bb: `}` and `{` on a new line | |||||
let playerList = sprintf( | |||||
translate("%(firstPlayer) and %(lastPlayer)"), | |||||
{ | |||||
"firstPlayer": players[0], | |||||
"lastPlayer": players[1] | |||||
} | |||||
); | |||||
} else { | |||||
let lastPlayer = players.pop(); | |||||
// Translation: This comma is used for separating first to penultimate elements in an enumeration. | // Translation: This comma is used for separating first to penultimate elements in an enumeration. | ||||
"players": mPlayers.join(translate(", ")), | let firstPlayers = players.join(translate(", ")); | ||||
let playerList = sprintf( | |||||
translate("%(firstPlayers), and %(lastPlayer)"), | |||||
{ | |||||
"firstPlayers": firstPlayers, | |||||
"lastPlayer": lastPlayer | "lastPlayer": lastPlayer | ||||
} | |||||
); | |||||
} | |||||
return sprintf(translatePlural(msg.message.message, msg.message.pluralMessage, msg.message.pluralCount), { | |||||
"players": playerList | |||||
}); | }); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Optionally show all tributes sent in observer mode and tributes sent between allied players. | * Optionally show all tributes sent in observer mode and tributes sent between allied players. | ||||
* Otherwise, only show tributes sent directly to us, and tributes that we send. | * Otherwise, only show tributes sent directly to us, and tributes that we send. | ||||
*/ | */ | ||||
Show All 22 Lines |
Wildfire Games · Phabricator
} and { on a new line