From 78e933a9680e2e7e9708e4a0b814eff8740b4628 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:29:07 +0100 Subject: [PATCH 1/4] add broadcast to translation --- Mods/vcmi/Content/config/english.json | 37 ++++++++ Mods/vcmi/Content/config/german.json | 2 + server/CGameHandler.cpp | 6 +- server/CVCMIServer.cpp | 2 +- server/processors/PlayerMessageProcessor.cpp | 90 +++++++++++++------- server/processors/TurnOrderProcessor.cpp | 6 +- 6 files changed, 105 insertions(+), 38 deletions(-) diff --git a/Mods/vcmi/Content/config/english.json b/Mods/vcmi/Content/config/english.json index 4224afae0..cf17811bc 100644 --- a/Mods/vcmi/Content/config/english.json +++ b/Mods/vcmi/Content/config/english.json @@ -120,6 +120,43 @@ "vcmi.lobby.deleteFile" : "Do you want to delete following file?", "vcmi.lobby.deleteFolder" : "Do you want to delete following folder?", "vcmi.lobby.deleteMode" : "Switch to delete mode and back", + + "vcmi.broadcast.command" : "Use '!help' to list available commands", + "vcmi.broadcast.simturn.end" : "Simultaneous turns have ended", + "vcmi.broadcast.simturn.endbetween" : "Simultaneous turns between players %s and %s have ended", + "vcmi.broadcast.serverproblem" : "Server encountered a problem", + "vcmi.broadcast.gameterminated" : "game was terminated", + "vcmi.broadcast.gamesavedas" : "game saved as", + "vcmi.broadcast.nocheater" : "No cheaters registered!", + "vcmi.broadcast.playercheater" : "Player %s is cheater!", + "vcmi.broadcast.statisticfile" : "Statistic files can be found in %s directory", + "vcmi.broadcast.help.commands" : "Available commands to host:", + "vcmi.broadcast.help.exit" : "'!exit' - immediately ends current game", + "vcmi.broadcast.help.kick" : "'!kick ' - kick specified player from the game", + "vcmi.broadcast.help.save" : "'!save ' - save game under specified filename", + "vcmi.broadcast.help.statistic" : "'!statistic' - save game statistics as csv file", + "vcmi.broadcast.help.commandsall" : "Available commands to all players:", + "vcmi.broadcast.help.help" : "'!help' - display this help", + "vcmi.broadcast.help.cheaters" : "'!cheaters' - list players that entered cheat command during game", + "vcmi.broadcast.help.vote" : "'!vote' - allows to change some game settings if all players vote for it", + "vcmi.broadcast.vote.allow" : "'!vote simturns allow X' - allow simultaneous turns for specified number of days, or until contact", + "vcmi.broadcast.vote.force" : "'!vote simturns force X' - force simultaneous turns for specified number of days, blocking player contacts", + "vcmi.broadcast.vote.abort" : "'!vote simturns abort' - abort simultaneous turns once this turn ends", + "vcmi.broadcast.vote.timer" : "'!vote timer prolong X' - prolong base timer for all players by specified number of seconds", + "vcmi.broadcast.vote.noactive" : "No active voting!", + "vcmi.broadcast.vote.yes" : "yes", + "vcmi.broadcast.vote.no" : "no", + "vcmi.broadcast.vote.notrecognized" : "Voting command not recognized!", + "vcmi.broadcast.vote.success.untilcontacts" : "Voting successful. Simultaneous turns will run for %s more days, or until contact", + "vcmi.broadcast.vote.success.contactsblocked" : "Voting successful. Simultaneous turns will run for %s more days. Contacts are blocked", + "vcmi.broadcast.vote.success.nextday" : "Voting successful. Simultaneous turns will end on next day", + "vcmi.broadcast.vote.success.timer" : "Voting successful. Timer for all players has been prolonger for %s seconds", + "vcmi.broadcast.vote.aborted" : "Player voted against change. Voting aborted", + "vcmi.broadcast.vote.start.untilcontacts" : "Started voting to allow simultaneous turns for %s more days", + "vcmi.broadcast.vote.start.contactsblocked" : "Started voting to force simultaneous turns for %s more days", + "vcmi.broadcast.vote.start.nextday" : "Started voting to end simultaneous turns starting from next day", + "vcmi.broadcast.vote.start.timer" : "Started voting to prolong timer for all players by %s seconds", + "vcmi.broadcast.vote.hint" : "Type '!vote yes' to agree to this change or '!vote no' to vote against it", "vcmi.lobby.login.title" : "VCMI Online Lobby", "vcmi.lobby.login.username" : "Username:", diff --git a/Mods/vcmi/Content/config/german.json b/Mods/vcmi/Content/config/german.json index ff12badc0..48c974d92 100644 --- a/Mods/vcmi/Content/config/german.json +++ b/Mods/vcmi/Content/config/german.json @@ -120,6 +120,8 @@ "vcmi.lobby.deleteFile" : "Möchtet Ihr folgende Datei löschen?", "vcmi.lobby.deleteFolder" : "Möchtet Ihr folgenden Ordner löschen?", "vcmi.lobby.deleteMode" : "In den Löschmodus wechseln und zurück", + + "vcmi.broadcast.command" : "Benutze '!help' um alle verfügbaren Befehle aufzulisten", "vcmi.lobby.login.title" : "VCMI Online Lobby", "vcmi.lobby.login.username" : "Benutzername:", diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index b91fcd324..311d655f8 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -3264,7 +3264,11 @@ bool CGameHandler::queryReply(QueryID qid, std::optional answer, Player bool CGameHandler::complain(const std::string &problem) { #ifndef ENABLE_GOLDMASTER - playerMessages->broadcastSystemMessage("Server encountered a problem: " + problem); + MetaString str; + str.appendTextID("vcmi.broadcast.serverproblem"); + str.appendRawString(": "); + str.appendRawString(problem); + playerMessages->broadcastSystemMessage(str); #endif logGlobal->error(problem); return true; diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 53b6879d8..2b0a27730 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -1016,7 +1016,7 @@ void CVCMIServer::multiplayerWelcomeMessage() if(humanPlayer < 2) // Singleplayer return; - gh->playerMessages->broadcastSystemMessage("Use '!help' to list available commands"); + gh->playerMessages->broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.command")); for (const auto & pi : si->playerInfos) if(!pi.second.handicap.startBonus.empty() || pi.second.handicap.percentIncome != 100 || pi.second.handicap.percentGrowth != 100) diff --git a/server/processors/PlayerMessageProcessor.cpp b/server/processors/PlayerMessageProcessor.cpp index 38b4409d0..14fd0e472 100644 --- a/server/processors/PlayerMessageProcessor.cpp +++ b/server/processors/PlayerMessageProcessor.cpp @@ -70,7 +70,7 @@ void PlayerMessageProcessor::commandExit(PlayerColor player, const std::vectorgameLobby()->setState(EServerState::SHUTDOWN); } @@ -115,7 +115,11 @@ void PlayerMessageProcessor::commandSave(PlayerColor player, const std::vectorsave("Saves/" + words[1]); - broadcastSystemMessage("game saved as " + words[1]); + MetaString str; + str.appendTextID("vcmi.broadcast.gamesavedas"); + str.appendRawString(" "); + str.appendRawString(words[1]); + broadcastSystemMessage(str); } } @@ -126,13 +130,15 @@ void PlayerMessageProcessor::commandCheaters(PlayerColor player, const std::vect { if(player.second.cheated) { - broadcastSystemMessage("Player " + player.first.toString() + " is cheater!"); + auto str = MetaString::createFromTextID("vcmi.broadcast.playercheater"); + str.replaceName(player.first); + broadcastSystemMessage(str); playersCheated++; } } if(!playersCheated) - broadcastSystemMessage("No cheaters registered!"); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.nocheater")); } void PlayerMessageProcessor::commandStatistic(PlayerColor player, const std::vector & words) @@ -143,49 +149,51 @@ void PlayerMessageProcessor::commandStatistic(PlayerColor player, const std::vec std::string path = gameHandler->gameState()->statistic.writeCsv(); - broadcastSystemMessage("Statistic files can be found in " + path + " directory\n"); + auto str = MetaString::createFromTextID("vcmi.broadcast.statisticfile"); + str.replaceRawString(path); + broadcastSystemMessage(str); } void PlayerMessageProcessor::commandHelp(PlayerColor player, const std::vector & words) { - broadcastSystemMessage("Available commands to host:"); - broadcastSystemMessage("'!exit' - immediately ends current game"); - broadcastSystemMessage("'!kick ' - kick specified player from the game"); - broadcastSystemMessage("'!save ' - save game under specified filename"); - broadcastSystemMessage("'!statistic' - save game statistics as csv file"); - broadcastSystemMessage("Available commands to all players:"); - broadcastSystemMessage("'!help' - display this help"); - broadcastSystemMessage("'!cheaters' - list players that entered cheat command during game"); - broadcastSystemMessage("'!vote' - allows to change some game settings if all players vote for it"); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.commands")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.exit")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.kick")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.save")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.statistic")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.commandsall")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.help")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.cheaters")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.help.vote")); } void PlayerMessageProcessor::commandVote(PlayerColor player, const std::vector & words) { if(words.size() < 2) { - broadcastSystemMessage("'!vote simturns allow X' - allow simultaneous turns for specified number of days, or until contact"); - broadcastSystemMessage("'!vote simturns force X' - force simultaneous turns for specified number of days, blocking player contacts"); - broadcastSystemMessage("'!vote simturns abort' - abort simultaneous turns once this turn ends"); - broadcastSystemMessage("'!vote timer prolong X' - prolong base timer for all players by specified number of seconds"); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.vote.allow")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.vote.force")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.vote.abort")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.vote.timer")); return; } - if(words[1] == "yes" || words[1] == "no") + if(words[1] == "yes" || words[1] == "no" || words[1] == MetaString::createFromTextID("vcmi.broadcast.vote.yes").toString() || words[1] == MetaString::createFromTextID("vcmi.broadcast.vote.no").toString()) { if(currentVote == ECurrentChatVote::NONE) { - broadcastSystemMessage("No active voting!"); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.vote.noactive")); return; } - if(words[1] == "yes") + if(words[1] == "yes" || words[1] == MetaString::createFromTextID("vcmi.broadcast.vote.yes").toString()) { awaitingPlayers.erase(player); if(awaitingPlayers.empty()) finishVoting(); return; } - if(words[1] == "no") + if(words[1] == "no" || words[1] == MetaString::createFromTextID("vcmi.broadcast.vote.no").toString()) { abortVoting(); return; @@ -240,28 +248,36 @@ void PlayerMessageProcessor::commandVote(PlayerColor player, const std::vectorturnOrder->setMaxSimturnsDuration(currentVoteParameter); break; case ECurrentChatVote::SIMTURNS_FORCE: - broadcastSystemMessage("Voting successful. Simultaneous turns will run for " + std::to_string(currentVoteParameter) + " more days. Contacts are blocked"); + msg.appendTextID("vcmi.broadcast.vote.success.contactsblocked"); + msg.replaceRawString(std::to_string(currentVoteParameter)); + broadcastSystemMessage(msg); gameHandler->turnOrder->setMinSimturnsDuration(currentVoteParameter); break; case ECurrentChatVote::SIMTURNS_ABORT: - broadcastSystemMessage("Voting successful. Simultaneous turns will end on next day"); + msg.appendTextID("vcmi.broadcast.vote.success.nextday"); + broadcastSystemMessage(msg); gameHandler->turnOrder->setMinSimturnsDuration(0); gameHandler->turnOrder->setMaxSimturnsDuration(0); break; case ECurrentChatVote::TIMER_PROLONG: - broadcastSystemMessage("Voting successful. Timer for all players has been prolonger for " + std::to_string(currentVoteParameter) + " seconds"); + msg.appendTextID("vcmi.broadcast.vote.success.timer"); + msg.replaceRawString(std::to_string(currentVoteParameter)); + broadcastSystemMessage(msg); gameHandler->turnTimerHandler->prolongTimers(currentVoteParameter * 1000); break; } @@ -272,7 +288,7 @@ void PlayerMessageProcessor::finishVoting() void PlayerMessageProcessor::abortVoting() { - broadcastSystemMessage("Player voted against change. Voting aborted"); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.vote.aborted")); currentVote = ECurrentChatVote::NONE; } @@ -281,25 +297,33 @@ void PlayerMessageProcessor::startVoting(PlayerColor initiator, ECurrentChatVote currentVote = what; currentVoteParameter = parameter; + MetaString msg; switch(currentVote) { case ECurrentChatVote::SIMTURNS_ALLOW: - broadcastSystemMessage("Started voting to allow simultaneous turns for " + std::to_string(parameter) + " more days"); + msg.appendTextID("vcmi.broadcast.vote.start.untilcontacts"); + msg.replaceRawString(std::to_string(parameter)); + broadcastSystemMessage(msg); break; case ECurrentChatVote::SIMTURNS_FORCE: - broadcastSystemMessage("Started voting to force simultaneous turns for " + std::to_string(parameter) + " more days"); + msg.appendTextID("vcmi.broadcast.vote.start.contactsblocked"); + msg.replaceRawString(std::to_string(parameter)); + broadcastSystemMessage(msg); break; case ECurrentChatVote::SIMTURNS_ABORT: - broadcastSystemMessage("Started voting to end simultaneous turns starting from next day"); + msg.appendTextID("vcmi.broadcast.vote.start.nextday"); + broadcastSystemMessage(msg); break; case ECurrentChatVote::TIMER_PROLONG: - broadcastSystemMessage("Started voting to prolong timer for all players by " + std::to_string(parameter) + " seconds"); + msg.appendTextID("vcmi.broadcast.vote.start.timer"); + msg.replaceRawString(std::to_string(parameter)); + broadcastSystemMessage(msg); break; default: return; } - broadcastSystemMessage("Type '!vote yes' to agree to this change or '!vote no' to vote against it"); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.vote.hint")); awaitingPlayers.clear(); for(PlayerColor player(0); player < PlayerColor::PLAYER_LIMIT; ++player) diff --git a/server/processors/TurnOrderProcessor.cpp b/server/processors/TurnOrderProcessor.cpp index 0f02ccebf..4d88fbbdc 100644 --- a/server/processors/TurnOrderProcessor.cpp +++ b/server/processors/TurnOrderProcessor.cpp @@ -72,7 +72,7 @@ void TurnOrderProcessor::updateAndNotifyContactStatus() { // Simturns between all players have ended - send single global notification if (!blockedContacts.empty()) - gameHandler->playerMessages->broadcastSystemMessage("Simultaneous turns have ended"); + gameHandler->playerMessages->broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.simturn.end")); } else { @@ -83,11 +83,11 @@ void TurnOrderProcessor::updateAndNotifyContactStatus() continue; MetaString message; - message.appendRawString("Simultaneous turns between players %s and %s have ended"); // FIXME: we should send MetaString itself and localize it on client side + message.appendTextID("vcmi.broadcast.simturn.endbetween"); message.replaceName(contact.a); message.replaceName(contact.b); - gameHandler->playerMessages->broadcastSystemMessage(message.toString()); + gameHandler->playerMessages->broadcastSystemMessage(message); } } From 6af8b62dfdf1cc2c0d49b086b3a1b272f6ba0705 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:48:09 +0100 Subject: [PATCH 2/4] more strings; camelcase --- Mods/vcmi/Content/config/english.json | 35 +++++++++++--------- server/CGameHandler.cpp | 32 ++++++++++-------- server/processors/PlayerMessageProcessor.cpp | 28 ++++++++-------- server/processors/TurnOrderProcessor.cpp | 2 +- 4 files changed, 53 insertions(+), 44 deletions(-) diff --git a/Mods/vcmi/Content/config/english.json b/Mods/vcmi/Content/config/english.json index cf17811bc..f648984bc 100644 --- a/Mods/vcmi/Content/config/english.json +++ b/Mods/vcmi/Content/config/english.json @@ -121,21 +121,22 @@ "vcmi.lobby.deleteFolder" : "Do you want to delete following folder?", "vcmi.lobby.deleteMode" : "Switch to delete mode and back", + "vcmi.broadcast.failedLoadGame" : "Failed to load game", "vcmi.broadcast.command" : "Use '!help' to list available commands", "vcmi.broadcast.simturn.end" : "Simultaneous turns have ended", - "vcmi.broadcast.simturn.endbetween" : "Simultaneous turns between players %s and %s have ended", - "vcmi.broadcast.serverproblem" : "Server encountered a problem", - "vcmi.broadcast.gameterminated" : "game was terminated", - "vcmi.broadcast.gamesavedas" : "game saved as", - "vcmi.broadcast.nocheater" : "No cheaters registered!", - "vcmi.broadcast.playercheater" : "Player %s is cheater!", - "vcmi.broadcast.statisticfile" : "Statistic files can be found in %s directory", + "vcmi.broadcast.simturn.endBetween" : "Simultaneous turns between players %s and %s have ended", + "vcmi.broadcast.serverProblem" : "Server encountered a problem", + "vcmi.broadcast.gameTerminated" : "game was terminated", + "vcmi.broadcast.gameSavedAs" : "game saved as", + "vcmi.broadcast.noCheater" : "No cheaters registered!", + "vcmi.broadcast.playerCheater" : "Player %s is cheater!", + "vcmi.broadcast.statisticFile" : "Statistic files can be found in %s directory", "vcmi.broadcast.help.commands" : "Available commands to host:", "vcmi.broadcast.help.exit" : "'!exit' - immediately ends current game", "vcmi.broadcast.help.kick" : "'!kick ' - kick specified player from the game", "vcmi.broadcast.help.save" : "'!save ' - save game under specified filename", "vcmi.broadcast.help.statistic" : "'!statistic' - save game statistics as csv file", - "vcmi.broadcast.help.commandsall" : "Available commands to all players:", + "vcmi.broadcast.help.commandsAll" : "Available commands to all players:", "vcmi.broadcast.help.help" : "'!help' - display this help", "vcmi.broadcast.help.cheaters" : "'!cheaters' - list players that entered cheat command during game", "vcmi.broadcast.help.vote" : "'!vote' - allows to change some game settings if all players vote for it", @@ -143,18 +144,18 @@ "vcmi.broadcast.vote.force" : "'!vote simturns force X' - force simultaneous turns for specified number of days, blocking player contacts", "vcmi.broadcast.vote.abort" : "'!vote simturns abort' - abort simultaneous turns once this turn ends", "vcmi.broadcast.vote.timer" : "'!vote timer prolong X' - prolong base timer for all players by specified number of seconds", - "vcmi.broadcast.vote.noactive" : "No active voting!", + "vcmi.broadcast.vote.noActive" : "No active voting!", "vcmi.broadcast.vote.yes" : "yes", "vcmi.broadcast.vote.no" : "no", - "vcmi.broadcast.vote.notrecognized" : "Voting command not recognized!", - "vcmi.broadcast.vote.success.untilcontacts" : "Voting successful. Simultaneous turns will run for %s more days, or until contact", - "vcmi.broadcast.vote.success.contactsblocked" : "Voting successful. Simultaneous turns will run for %s more days. Contacts are blocked", - "vcmi.broadcast.vote.success.nextday" : "Voting successful. Simultaneous turns will end on next day", + "vcmi.broadcast.vote.notRecognized" : "Voting command not recognized!", + "vcmi.broadcast.vote.success.untilContacts" : "Voting successful. Simultaneous turns will run for %s more days, or until contact", + "vcmi.broadcast.vote.success.contactsBlocked" : "Voting successful. Simultaneous turns will run for %s more days. Contacts are blocked", + "vcmi.broadcast.vote.success.nextDay" : "Voting successful. Simultaneous turns will end on next day", "vcmi.broadcast.vote.success.timer" : "Voting successful. Timer for all players has been prolonger for %s seconds", "vcmi.broadcast.vote.aborted" : "Player voted against change. Voting aborted", - "vcmi.broadcast.vote.start.untilcontacts" : "Started voting to allow simultaneous turns for %s more days", - "vcmi.broadcast.vote.start.contactsblocked" : "Started voting to force simultaneous turns for %s more days", - "vcmi.broadcast.vote.start.nextday" : "Started voting to end simultaneous turns starting from next day", + "vcmi.broadcast.vote.start.untilContacts" : "Started voting to allow simultaneous turns for %s more days", + "vcmi.broadcast.vote.start.contactsBlocked" : "Started voting to force simultaneous turns for %s more days", + "vcmi.broadcast.vote.start.nextDay" : "Started voting to end simultaneous turns starting from next day", "vcmi.broadcast.vote.start.timer" : "Started voting to prolong timer for all players by %s seconds", "vcmi.broadcast.vote.hint" : "Type '!vote yes' to agree to this change or '!vote no' to vote against it", @@ -226,6 +227,8 @@ "vcmi.server.errors.modsToEnable" : "{Following mods are required}", "vcmi.server.errors.modsToDisable" : "{Following mods must be disabled}", "vcmi.server.errors.unknownEntity" : "Failed to load save! Unknown entity '%s' found in saved game! Save may not be compatible with currently installed version of mods!", + "vcmi.server.errors.wrongIdentified" : "You were identified as player %s while expecting %s", + "vcmi.server.errors.notAllowed" : "You are not allowed to perform this action!", "vcmi.dimensionDoor.seaToLandError" : "It's not possible to teleport from sea to land or vice versa with a Dimension Door.", diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 311d655f8..2c2b60a85 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1473,7 +1473,7 @@ bool CGameHandler::isPlayerOwns(CPackForServer * pack, ObjectInstanceID id) void CGameHandler::throwNotAllowedAction(CPackForServer * pack) { if(pack->c) - playerMessages->sendSystemMessage(pack->c, "You are not allowed to perform this action!"); + playerMessages->sendSystemMessage(pack->c, MetaString::createFromTextID("vcmi.server.errors.notAllowed")); logNetwork->error("Player is not allowed to perform this action!"); throw ExceptionNotAllowedAction(); @@ -1481,12 +1481,13 @@ void CGameHandler::throwNotAllowedAction(CPackForServer * pack) void CGameHandler::wrongPlayerMessage(CPackForServer * pack, PlayerColor expectedplayer) { - std::ostringstream oss; - oss << "You were identified as player " << pack->player << " while expecting " << expectedplayer; - logNetwork->error(oss.str()); + auto str = MetaString::createFromTextID("vcmi.server.errors.wrongIdentified"); + str.appendName(pack->player); + str.appendName(expectedplayer); + logNetwork->error(str.toString()); if(pack->c) - playerMessages->sendSystemMessage(pack->c, oss.str()); + playerMessages->sendSystemMessage(pack->c, str); } void CGameHandler::throwIfWrongOwner(CPackForServer * pack, ObjectInstanceID id) @@ -1569,16 +1570,18 @@ bool CGameHandler::load(const std::string & filename) catch(const ModIncompatibility & e) { logGlobal->error("Failed to load game: %s", e.what()); - std::string errorMsg; + MetaString errorMsg; if(!e.whatMissing().empty()) { - errorMsg += VLC->generaltexth->translate("vcmi.server.errors.modsToEnable") + '\n'; - errorMsg += e.whatMissing(); + errorMsg.appendTextID("vcmi.server.errors.modsToEnable"); + errorMsg.appendRawString("\n"); + errorMsg.appendRawString(e.whatMissing()); } if(!e.whatExcessive().empty()) { - errorMsg += VLC->generaltexth->translate("vcmi.server.errors.modsToDisable") + '\n'; - errorMsg += e.whatExcessive(); + errorMsg.appendTextID("vcmi.server.errors.modsToDisable"); + errorMsg.appendRawString("\n"); + errorMsg.appendRawString(e.whatExcessive()); } lobby->announceMessage(errorMsg); return false; @@ -1589,14 +1592,17 @@ bool CGameHandler::load(const std::string & filename) MetaString errorMsg; errorMsg.appendTextID("vcmi.server.errors.unknownEntity"); errorMsg.replaceRawString(e.identifierName); - lobby->announceMessage(errorMsg.toString());//FIXME: should be localized on client side + lobby->announceMessage(errorMsg); return false; } catch(const std::exception & e) { logGlobal->error("Failed to load game: %s", e.what()); - lobby->announceMessage(std::string("Failed to load game: ") + e.what()); + auto str = MetaString::createFromTextID("vcmi.broadcast.failedLoadGame"); + str.appendRawString(": "); + str.appendRawString(e.what()); + lobby->announceMessage(str); return false; } gs->preInit(VLC, this); @@ -3265,7 +3271,7 @@ bool CGameHandler::complain(const std::string &problem) { #ifndef ENABLE_GOLDMASTER MetaString str; - str.appendTextID("vcmi.broadcast.serverproblem"); + str.appendTextID("vcmi.broadcast.serverProblem"); str.appendRawString(": "); str.appendRawString(problem); playerMessages->broadcastSystemMessage(str); diff --git a/server/processors/PlayerMessageProcessor.cpp b/server/processors/PlayerMessageProcessor.cpp index 14fd0e472..89b034128 100644 --- a/server/processors/PlayerMessageProcessor.cpp +++ b/server/processors/PlayerMessageProcessor.cpp @@ -70,7 +70,7 @@ void PlayerMessageProcessor::commandExit(PlayerColor player, const std::vectorgameLobby()->setState(EServerState::SHUTDOWN); } @@ -116,7 +116,7 @@ void PlayerMessageProcessor::commandSave(PlayerColor player, const std::vectorsave("Saves/" + words[1]); MetaString str; - str.appendTextID("vcmi.broadcast.gamesavedas"); + str.appendTextID("vcmi.broadcast.gameSavedAs"); str.appendRawString(" "); str.appendRawString(words[1]); broadcastSystemMessage(str); @@ -130,7 +130,7 @@ void PlayerMessageProcessor::commandCheaters(PlayerColor player, const std::vect { if(player.second.cheated) { - auto str = MetaString::createFromTextID("vcmi.broadcast.playercheater"); + auto str = MetaString::createFromTextID("vcmi.broadcast.playerCheater"); str.replaceName(player.first); broadcastSystemMessage(str); playersCheated++; @@ -138,7 +138,7 @@ void PlayerMessageProcessor::commandCheaters(PlayerColor player, const std::vect } if(!playersCheated) - broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.nocheater")); + broadcastSystemMessage(MetaString::createFromTextID("vcmi.broadcast.noCheater")); } void PlayerMessageProcessor::commandStatistic(PlayerColor player, const std::vector & words) @@ -149,7 +149,7 @@ void PlayerMessageProcessor::commandStatistic(PlayerColor player, const std::vec std::string path = gameHandler->gameState()->statistic.writeCsv(); - auto str = MetaString::createFromTextID("vcmi.broadcast.statisticfile"); + auto str = MetaString::createFromTextID("vcmi.broadcast.statisticFile"); str.replaceRawString(path); broadcastSystemMessage(str); } @@ -161,7 +161,7 @@ void PlayerMessageProcessor::commandHelp(PlayerColor player, const std::vectorturnOrder->setMaxSimturnsDuration(currentVoteParameter); break; case ECurrentChatVote::SIMTURNS_FORCE: - msg.appendTextID("vcmi.broadcast.vote.success.contactsblocked"); + msg.appendTextID("vcmi.broadcast.vote.success.contactsBlocked"); msg.replaceRawString(std::to_string(currentVoteParameter)); broadcastSystemMessage(msg); gameHandler->turnOrder->setMinSimturnsDuration(currentVoteParameter); break; case ECurrentChatVote::SIMTURNS_ABORT: - msg.appendTextID("vcmi.broadcast.vote.success.nextday"); + msg.appendTextID("vcmi.broadcast.vote.success.nextDay"); broadcastSystemMessage(msg); gameHandler->turnOrder->setMinSimturnsDuration(0); gameHandler->turnOrder->setMaxSimturnsDuration(0); @@ -301,17 +301,17 @@ void PlayerMessageProcessor::startVoting(PlayerColor initiator, ECurrentChatVote switch(currentVote) { case ECurrentChatVote::SIMTURNS_ALLOW: - msg.appendTextID("vcmi.broadcast.vote.start.untilcontacts"); + msg.appendTextID("vcmi.broadcast.vote.start.untilContacts"); msg.replaceRawString(std::to_string(parameter)); broadcastSystemMessage(msg); break; case ECurrentChatVote::SIMTURNS_FORCE: - msg.appendTextID("vcmi.broadcast.vote.start.contactsblocked"); + msg.appendTextID("vcmi.broadcast.vote.start.contactsBlocked"); msg.replaceRawString(std::to_string(parameter)); broadcastSystemMessage(msg); break; case ECurrentChatVote::SIMTURNS_ABORT: - msg.appendTextID("vcmi.broadcast.vote.start.nextday"); + msg.appendTextID("vcmi.broadcast.vote.start.nextDay"); broadcastSystemMessage(msg); break; case ECurrentChatVote::TIMER_PROLONG: diff --git a/server/processors/TurnOrderProcessor.cpp b/server/processors/TurnOrderProcessor.cpp index 4d88fbbdc..899df2b04 100644 --- a/server/processors/TurnOrderProcessor.cpp +++ b/server/processors/TurnOrderProcessor.cpp @@ -83,7 +83,7 @@ void TurnOrderProcessor::updateAndNotifyContactStatus() continue; MetaString message; - message.appendTextID("vcmi.broadcast.simturn.endbetween"); + message.appendTextID("vcmi.broadcast.simturn.endBetween"); message.replaceName(contact.a); message.replaceName(contact.b); From 81328e258845771cfa5c2c9be2759ccb3ba0f904 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:00:24 +0100 Subject: [PATCH 3/4] fixme & seconds in time (more usual) --- Mods/vcmi/Content/config/english.json | 1 + client/GameChatHandler.cpp | 2 +- lib/texts/TextOperations.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Mods/vcmi/Content/config/english.json b/Mods/vcmi/Content/config/english.json index f648984bc..d5a7af9dd 100644 --- a/Mods/vcmi/Content/config/english.json +++ b/Mods/vcmi/Content/config/english.json @@ -166,6 +166,7 @@ "vcmi.lobby.login.create" : "New Account", "vcmi.lobby.login.login" : "Login", "vcmi.lobby.login.as" : "Login as %s", + "vcmi.lobby.login.spectator" : "Spectator", "vcmi.lobby.header.rooms" : "Game Rooms - %d", "vcmi.lobby.header.channels" : "Chat Channels", "vcmi.lobby.header.chat.global" : "Global Game Chat - %s", // %s -> language name diff --git a/client/GameChatHandler.cpp b/client/GameChatHandler.cpp index ceb9be0aa..34d5866e9 100644 --- a/client/GameChatHandler.cpp +++ b/client/GameChatHandler.cpp @@ -93,7 +93,7 @@ void GameChatHandler::onNewGameMessageReceived(PlayerColor sender, const std::st playerName = LOCPLINT->cb->getStartInfo()->playerInfos.at(sender).name; if (sender.isSpectator()) - playerName = "Spectator"; // FIXME: translate? Provide nickname somewhere? + playerName = VLC->generaltexth->translate("vcmi.lobby.login.spectator"); chatHistory.push_back({playerName, messageText, timeFormatted}); diff --git a/lib/texts/TextOperations.cpp b/lib/texts/TextOperations.cpp index ed46d9080..48fdde924 100644 --- a/lib/texts/TextOperations.cpp +++ b/lib/texts/TextOperations.cpp @@ -221,7 +221,7 @@ std::string TextOperations::getFormattedDateTimeLocal(std::time_t dt) std::string TextOperations::getFormattedTimeLocal(std::time_t dt) { - return vstd::getFormattedDateTime(dt, "%H:%M"); + return vstd::getFormattedDateTime(dt, "%H:%M:%S"); } std::string TextOperations::getCurrentFormattedTimeLocal(std::chrono::seconds timeOffset) From a8709731c4b76d340f24deb79f98e5331fc6e2ae Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:37:51 +0100 Subject: [PATCH 4/4] unify time (without seconds) --- lib/texts/Languages.h | 34 +++++++++++++++++----------------- lib/texts/TextOperations.cpp | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/texts/Languages.h b/lib/texts/Languages.h index 9e0f87585..52b13b851 100644 --- a/lib/texts/Languages.h +++ b/lib/texts/Languages.h @@ -77,23 +77,23 @@ inline const auto & getLanguageList() { static const std::array languages { { - { "czech", "Czech", "Čeština", "CP1250", "cs", "cze", "%d.%m.%Y %H:%M:%S", EPluralForms::CZ_3 }, - { "chinese", "Chinese", "简体中文", "GBK", "zh", "chi", "%Y-%m-%d %H:%M:%S", EPluralForms::VI_1 }, // Note: actually Simplified Chinese - { "english", "English", "English", "CP1252", "en", "eng", "%Y-%m-%d %H:%M:%S", EPluralForms::EN_2 }, // English uses international date/time format here - { "finnish", "Finnish", "Suomi", "CP1252", "fi", "fin", "%d.%m.%Y %H:%M:%S", EPluralForms::EN_2, }, - { "french", "French", "Français", "CP1252", "fr", "fre", "%d/%m/%Y %H:%M:%S", EPluralForms::FR_2, }, - { "german", "German", "Deutsch", "CP1252", "de", "ger", "%d.%m.%Y %H:%M:%S", EPluralForms::EN_2, }, - { "hungarian", "Hungarian", "Magyar", "CP1250", "hu", "hun", "%Y. %m. %d. %H:%M:%S", EPluralForms::EN_2 }, - { "italian", "Italian", "Italiano", "CP1250", "it", "ita", "%d/%m/%Y %H:%M:%S", EPluralForms::EN_2 }, - { "korean", "Korean", "한국어", "CP949", "ko", "kor", "%Y-%m-%d %H:%M:%S", EPluralForms::VI_1 }, - { "polish", "Polish", "Polski", "CP1250", "pl", "pol", "%d.%m.%Y %H:%M:%S", EPluralForms::PL_3 }, - { "portuguese", "Portuguese", "Português", "CP1252", "pt", "por", "%d/%m/%Y %H:%M:%S", EPluralForms::EN_2 }, // Note: actually Brazilian Portuguese - { "russian", "Russian", "Русский", "CP1251", "ru", "rus", "%d.%m.%Y %H:%M:%S", EPluralForms::UK_3 }, - { "spanish", "Spanish", "Español", "CP1252", "es", "spa", "%d/%m/%Y %H:%M:%S", EPluralForms::EN_2 }, - { "swedish", "Swedish", "Svenska", "CP1252", "sv", "swe", "%Y-%m-%d %H:%M:%S", EPluralForms::EN_2 }, - { "turkish", "Turkish", "Türkçe", "CP1254", "tr", "tur", "%d.%m.%Y %H:%M:%S", EPluralForms::EN_2 }, - { "ukrainian", "Ukrainian", "Українська", "CP1251", "uk", "ukr", "%d.%m.%Y %H:%M:%S", EPluralForms::UK_3 }, - { "vietnamese", "Vietnamese", "Tiếng Việt", "UTF-8", "vi", "vie", "%d/%m/%Y %H:%M:%S", EPluralForms::VI_1 }, // Fan translation uses special encoding + { "czech", "Czech", "Čeština", "CP1250", "cs", "cze", "%d.%m.%Y %H:%M", EPluralForms::CZ_3 }, + { "chinese", "Chinese", "简体中文", "GBK", "zh", "chi", "%Y-%m-%d %H:%M", EPluralForms::VI_1 }, // Note: actually Simplified Chinese + { "english", "English", "English", "CP1252", "en", "eng", "%Y-%m-%d %H:%M", EPluralForms::EN_2 }, // English uses international date/time format here + { "finnish", "Finnish", "Suomi", "CP1252", "fi", "fin", "%d.%m.%Y %H:%M", EPluralForms::EN_2, }, + { "french", "French", "Français", "CP1252", "fr", "fre", "%d/%m/%Y %H:%M", EPluralForms::FR_2, }, + { "german", "German", "Deutsch", "CP1252", "de", "ger", "%d.%m.%Y %H:%M", EPluralForms::EN_2, }, + { "hungarian", "Hungarian", "Magyar", "CP1250", "hu", "hun", "%Y. %m. %d. %H:%M", EPluralForms::EN_2 }, + { "italian", "Italian", "Italiano", "CP1250", "it", "ita", "%d/%m/%Y %H:%M", EPluralForms::EN_2 }, + { "korean", "Korean", "한국어", "CP949", "ko", "kor", "%Y-%m-%d %H:%M", EPluralForms::VI_1 }, + { "polish", "Polish", "Polski", "CP1250", "pl", "pol", "%d.%m.%Y %H:%M", EPluralForms::PL_3 }, + { "portuguese", "Portuguese", "Português", "CP1252", "pt", "por", "%d/%m/%Y %H:%M", EPluralForms::EN_2 }, // Note: actually Brazilian Portuguese + { "russian", "Russian", "Русский", "CP1251", "ru", "rus", "%d.%m.%Y %H:%M", EPluralForms::UK_3 }, + { "spanish", "Spanish", "Español", "CP1252", "es", "spa", "%d/%m/%Y %H:%M", EPluralForms::EN_2 }, + { "swedish", "Swedish", "Svenska", "CP1252", "sv", "swe", "%Y-%m-%d %H:%M", EPluralForms::EN_2 }, + { "turkish", "Turkish", "Türkçe", "CP1254", "tr", "tur", "%d.%m.%Y %H:%M", EPluralForms::EN_2 }, + { "ukrainian", "Ukrainian", "Українська", "CP1251", "uk", "ukr", "%d.%m.%Y %H:%M", EPluralForms::UK_3 }, + { "vietnamese", "Vietnamese", "Tiếng Việt", "UTF-8", "vi", "vie", "%d/%m/%Y %H:%M", EPluralForms::VI_1 }, // Fan translation uses special encoding } }; static_assert(languages.size() == static_cast(ELanguages::COUNT), "Languages array is missing a value!"); diff --git a/lib/texts/TextOperations.cpp b/lib/texts/TextOperations.cpp index 48fdde924..ed46d9080 100644 --- a/lib/texts/TextOperations.cpp +++ b/lib/texts/TextOperations.cpp @@ -221,7 +221,7 @@ std::string TextOperations::getFormattedDateTimeLocal(std::time_t dt) std::string TextOperations::getFormattedTimeLocal(std::time_t dt) { - return vstd::getFormattedDateTime(dt, "%H:%M:%S"); + return vstd::getFormattedDateTime(dt, "%H:%M"); } std::string TextOperations::getCurrentFormattedTimeLocal(std::chrono::seconds timeOffset)