Changeset View
Standalone View
binaries/data/mods/public/gui/common/functions_utility.js
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | function stringifiedTeamListToPlayerData(stringifiedTeamList) | ||||
return playerData; | return playerData; | ||||
} | } | ||||
function translateMapTitle(mapTitle) | function translateMapTitle(mapTitle) | ||||
{ | { | ||||
return mapTitle == "random" ? translateWithContext("map selection", "Random") : translate(mapTitle); | return mapTitle == "random" ? translateWithContext("map selection", "Random") : translate(mapTitle); | ||||
} | } | ||||
/** | function chatTimestampToString(time) | ||||
* Convert time in milliseconds to [hh:]mm:ss string representation. | |||||
* @param time Time period in milliseconds (integer) | |||||
* @return String representing time period | |||||
*/ | |||||
function timeToString(time) | |||||
{ | { | ||||
return Engine.FormatMillisecondsIntoDateStringGMT(time, time < 1000 * 60 * 60 ? | // Translation: Time prefix as shown in the chat in the lobby, game setup, and session. | ||||
translate("mm:ss") : translate("HH:mm:ss")); | return sprintf(escapeText(translate("[%(time)s]")), { "time": timeOfDayToString(time) }); | ||||
} | } | ||||
elexis: I would prefer to kill this file due to a lack of definition which files it should contain.
How… | |||||
function removeDupes(array) | function removeDupes(array) | ||||
{ | { | ||||
// loop backwards to make splice operations cheaper | // loop backwards to make splice operations cheaper | ||||
let i = array.length; | let i = array.length; | ||||
Not Done Inline ActionsThis function is currently used in three cases:
I don't know if people on transifex would want to use two different strings (elapsed, countdown) if they knew about the string mechanics to begin with. But the name timeToString indiciates to the programmer that he can always use this when passing a time. Perhaps a elapsedTimeString and a countdownTimeString with the context countdown format and elapsed time format might make cleaner code and transifex material? elexis: This function is currently used in three cases:
1) matchtime elapsed (replay, savegame, lobby… | |||||
Not Done Inline ActionsYes, we should be clearer here that this is a duration rather than a time like "one o'clock". I guess it's possible that in different places we'd want to show the duration differently. For example in the replay menu maybe we only want to show hours:minutes rather than seconds too. But I'm happy with the current one-size-fits-all approach. temple: Yes, we should be clearer here that this is a duration rather than a time like "one o'clock". | |||||
Not Done Inline ActionsOk to keep it. elexis: Ok to keep it. | |||||
while (i--) | while (i--) | ||||
if (array.indexOf(array[i]) != i) | if (array.indexOf(array[i]) != i) | ||||
array.splice(i, 1); | array.splice(i, 1); | ||||
} | } | ||||
function singleplayerName() | function singleplayerName() | ||||
{ | { | ||||
Not Done Inline ActionsWould be nice if it could become [%(time)s] so that the translation folks don't have to take care of escaping it (and don't need to understand why there are those backslashes to begin with). But that will need an escapeText call to compensate and warn(escapeText(escapeText("[asd]"))); shows \\\[asd], so we'd have to ensure that either nothing calling this function adds another escapeText, or add the escapeText in every caller. Or leave as is. Pick your poison. elexis: Would be nice if it could become `[%(time)s]` so that the translation folks don't have to take… | |||||
return Engine.ConfigDB_GetValue("user", "playername.singleplayer") || Engine.GetSystemUsername(); | return Engine.ConfigDB_GetValue("user", "playername.singleplayer") || Engine.GetSystemUsername(); | ||||
} | } | ||||
function multiplayerName() | function multiplayerName() | ||||
Not Done Inline Actions"chat timestamp" elexis: "chat timestamp" | |||||
Not Done Inline ActionsYeah, I guess I don't need to say "format" in all of these. temple: Yeah, I guess I don't need to say "format" in all of these. | |||||
Not Done Inline Actions(when you enable it in the options page). were unneeded elexis: `(when you enable it in the options page). ` were unneeded | |||||
{ | { | ||||
return Engine.ConfigDB_GetValue("user", "playername.multiplayer") || Engine.GetSystemUsername(); | return Engine.ConfigDB_GetValue("user", "playername.multiplayer") || Engine.GetSystemUsername(); | ||||
} | } | ||||
function tryAutoComplete(text, autoCompleteList) | function tryAutoComplete(text, autoCompleteList) | ||||
{ | { | ||||
if (!text.length) | if (!text.length) | ||||
return text; | return text; | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |
I would prefer to kill this file due to a lack of definition which files it should contain.
How about moving it to gui/common/l10n.js as well?
(There are some other random translation functions, perhaps they should be moved there eventually too)