diff --git a/include/znc/Client.h b/include/znc/Client.h index e52b2ec8..6d33a3f3 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -35,7 +35,7 @@ class CMessage; class CChan; // !Forward Declarations -class CAuthBase { +class CAuthBase : private CCoreTranslationMixin { public: CAuthBase(const CString& sUsername, const CString& sPassword, CZNCSock* pSock) diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index 0f989ef6..ee5ba8db 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -37,7 +37,7 @@ class CIRCNetworkPingTimer; class CIRCNetworkJoinTimer; class CMessage; -class CIRCNetwork { +class CIRCNetwork : private CCoreTranslationMixin { public: static bool IsValidNetwork(const CString& sNetwork); diff --git a/include/znc/Modules.h b/include/znc/Modules.h index ce0a39ff..28fdd3a6 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -335,7 +335,7 @@ CModule* TModLoad(ModHandle p, CUser* pUser, CIRCNetwork* pNetwork, } /** A helper class for handling commands in modules. */ -class CModCommand { +class CModCommand : private CCoreTranslationMixin { public: /// Type for the callback function that handles the actual command. typedef void (CModule::*ModCmdFunc)(const CString& sLine); @@ -1386,7 +1386,7 @@ class CModule { std::map m_mCommands; }; -class CModules : public std::vector { +class CModules : public std::vector, private CCoreTranslationMixin { public: CModules(); ~CModules(); diff --git a/src/Client.cpp b/src/Client.cpp index a39d6d39..c8c7c23c 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -72,7 +72,7 @@ using std::vector; } \ } \ } else { \ - PutStatus("No such module [" + MOD + "]"); \ + PutStatus(t_f("No such module {1}")(MOD)); \ } \ } @@ -361,9 +361,9 @@ void CAuthBase::RefuseLogin(const CString& sReason) { // login. Use sReason because there are other reasons than "wrong // password" for a login to be rejected (e.g. fail2ban). if (pUser) { - pUser->PutStatusNotice("A client from [" + GetRemoteIP() + "] attempted " - "to login as you, but was rejected [" + - sReason + "]."); + pUser->PutStatusNotice(t_f( + "A client from {1} attempted to login as you, but was rejected: " + "{2}")(GetRemoteIP(), sReason)); } GLOBALMODULECALL(OnFailedLogin(GetUsername(), GetRemoteIP()), NOTHING); @@ -397,7 +397,7 @@ void CClient::AcceptLogin(CUser& User) { if (!m_sNetwork.empty()) { m_pNetwork = m_pUser->FindNetwork(m_sNetwork); if (!m_pNetwork) { - PutStatus("Network (" + m_sNetwork + ") doesn't exist."); + PutStatus(t_f("Network {1} doesn't exist.")(m_sNetwork)); } } else if (!m_pUser->GetNetworks().empty()) { // If a user didn't supply a network, and they have a network called @@ -411,21 +411,20 @@ void CClient::AcceptLogin(CUser& User) { if (!m_pNetwork) m_pNetwork = *m_pUser->GetNetworks().begin(); if (m_pNetwork && m_pUser->GetNetworks().size() > 1) { PutStatusNotice( - "You have several networks configured, but no network was " - "specified for the connection."); - PutStatusNotice("Selecting network [" + m_pNetwork->GetName() + - "]. To see list of all configured networks, use " - "/znc ListNetworks"); + t_s("You have several networks configured, but no network was " + "specified for the connection.")); PutStatusNotice( + t_f("Selecting network {1}. To see list of all configured " + "networks, use /znc ListNetworks")(m_pNetwork->GetName())); + PutStatusNotice(t_f( "If you want to choose another network, use /znc JumpNetwork " - ", or connect to ZNC with username " + - m_pUser->GetUserName() + "/ (instead of just " + - m_pUser->GetUserName() + ")"); + ", or connect to ZNC with username {1}/ " + "(instead of just {1})")(m_pUser->GetUserName())); } } else { PutStatusNotice( - "You have no networks configured. Use /znc AddNetwork to " - "add one."); + t_s("You have no networks configured. Use /znc AddNetwork " + " to add one.")); } SetNetwork(m_pNetwork, false); @@ -435,7 +434,7 @@ void CClient::AcceptLogin(CUser& User) { NETWORKMODULECALL(OnClientLogin(), m_pUser, m_pNetwork, this, NOTHING); } -void CClient::Timeout() { PutClient("ERROR :Closing link [Timeout]"); } +void CClient::Timeout() { PutClient("ERROR :" + t_s("Closing link: Timeout")); } void CClient::Connected() { DEBUG(GetSockName() << " == Connected();"); } @@ -457,15 +456,15 @@ void CClient::Disconnected() { void CClient::ReachedMaxBuffer() { DEBUG(GetSockName() << " == ReachedMaxBuffer()"); if (IsAttached()) { - PutClient("ERROR :Closing link [Too long raw line]"); + PutClient("ERROR :" + t_s("Closing link: Too long raw line")); } Close(); } void CClient::BouncedOff() { PutStatusNotice( - "You are being disconnected because another user just authenticated as " - "you."); + t_s("You are being disconnected because another user just " + "authenticated as you.")); Close(Csock::CLT_AFTERWRITE); } @@ -1018,9 +1017,9 @@ bool CClient::OnCTCPMessage(CCTCPMessage& Message) { if (!GetIRCSock()) { // Some lagmeters do a NOTICE to their own nick, ignore those. if (!sTarget.Equals(m_sNick)) - PutStatus("Your CTCP to [" + Message.GetTarget() + - "] got lost, " - "you are not connected to IRC!"); + PutStatus(t_f( + "Your CTCP to {1} got lost, you are not connected to IRC!")( + Message.GetTarget())); continue; } @@ -1145,9 +1144,9 @@ bool CClient::OnNoticeMessage(CNoticeMessage& Message) { if (!GetIRCSock()) { // Some lagmeters do a NOTICE to their own nick, ignore those. if (!sTarget.Equals(m_sNick)) - PutStatus("Your notice to [" + Message.GetTarget() + - "] got lost, " - "you are not connected to IRC!"); + PutStatus( + t_f("Your notice to {1} got lost, you are not connected to " + "IRC!")(Message.GetTarget())); continue; } @@ -1185,7 +1184,7 @@ bool CClient::OnPartMessage(CPartMessage& Message) { CChan* pChan = m_pNetwork ? m_pNetwork->FindChan(sChan) : nullptr; if (pChan && !pChan->IsOn()) { - PutStatusNotice("Removing channel [" + sChan + "]"); + PutStatusNotice(t_f("Removing channel {1}")(sChan)); m_pNetwork->DelChan(sChan); } else { sChans += (sChans.empty()) ? sChan : CString("," + sChan); @@ -1261,9 +1260,9 @@ bool CClient::OnTextMessage(CTextMessage& Message) { if (!GetIRCSock()) { // Some lagmeters do a PRIVMSG to their own nick, ignore those. if (!sTarget.Equals(m_sNick)) - PutStatus("Your message to [" + Message.GetTarget() + - "] got lost, " - "you are not connected to IRC!"); + PutStatus( + t_f("Your message to {1} got lost, you are not connected " + "to IRC!")(Message.GetTarget())); continue; } @@ -1315,13 +1314,13 @@ bool CClient::OnOtherMessage(CMessage& Message) { if (sTarget.Equals("status")) { if (sModCommand.empty()) - PutStatus("Hello. How may I help you?"); + PutStatus(t_s("Hello. How may I help you?")); else UserCommand(sModCommand); } else { if (sModCommand.empty()) CALLMOD(sTarget, this, m_pUser, m_pNetwork, - PutModule("Hello. How may I help you?")) + PutModule(t_s("Hello. How may I help you?"))) else CALLMOD(sTarget, this, m_pUser, m_pNetwork, OnModCommand(sModCommand)) @@ -1335,16 +1334,18 @@ bool CClient::OnOtherMessage(CMessage& Message) { CString sPatterns = Message.GetParams(0); if (sPatterns.empty()) { - PutStatusNotice("Usage: /attach <#chans>"); + PutStatusNotice(t_s("Usage: /attach <#chans>")); return true; } set sChans = MatchChans(sPatterns); unsigned int uAttachedChans = AttachChans(sChans); - PutStatusNotice("There were [" + CString(sChans.size()) + - "] channels matching [" + sPatterns + "]"); - PutStatusNotice("Attached [" + CString(uAttachedChans) + "] channels"); + PutStatusNotice(t_p("There was {1} channel matching [{2}]", + "There were {1} channels matching [{2}]", + sChans.size())(sChans.size(), sPatterns)); + PutStatusNotice(t_p("Attached {1} channel", "Attached {1} channels", + uAttachedChans)(uAttachedChans)); return true; } else if (sCommand.Equals("DETACH")) { @@ -1355,16 +1356,18 @@ bool CClient::OnOtherMessage(CMessage& Message) { CString sPatterns = Message.GetParams(0); if (sPatterns.empty()) { - PutStatusNotice("Usage: /detach <#chans>"); + PutStatusNotice(t_s("Usage: /detach <#chans>")); return true; } set sChans = MatchChans(sPatterns); unsigned int uDetached = DetachChans(sChans); - PutStatusNotice("There were [" + CString(sChans.size()) + - "] channels matching [" + sPatterns + "]"); - PutStatusNotice("Detached [" + CString(uDetached) + "] channels"); + PutStatusNotice(t_p("There was {1} channel matching [{2}]", + "There were {1} channels matching [{2}]", + sChans.size())(sChans.size(), sPatterns)); + PutStatusNotice(t_p("Detached {1} channel", "Detached {1} channels", + uDetached)(uDetached)); return true; } else if (sCommand.Equals("PROTOCTL")) { diff --git a/src/IRCNetwork.cpp b/src/IRCNetwork.cpp index 6ad65e6a..217096f2 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -233,7 +233,8 @@ void CIRCNetwork::Clone(const CIRCNetwork& Network, bool bCloneName) { if (pSock) { PutStatus( - "Jumping servers because this server is no longer in the list"); + t_s("Jumping servers because this server is no longer in the " + "list")); pSock->Quit(); } } @@ -468,7 +469,9 @@ bool CIRCNetwork::ParseConfig(CConfig* pConfig, CString& sError, } if (!bFound) { sNotice = - "Loading network module [simple_away] instead"; + "NOTICE: awaynick was retired, loading network " + "module [simple_away] instead; if you still need " + "awaynick, install it as an external module"; sModName = "simple_away"; // not a fatal error if simple_away is not available LoadModule(sModName, sArgs, sNotice, sModRet); @@ -635,7 +638,7 @@ void CIRCNetwork::ClientConnected(CClient* pClient) { if (m_RawBuffer.IsEmpty()) { pClient->PutClient(":irc.znc.in 001 " + pClient->GetNick() + - " :- Welcome to ZNC -"); + " :" + t_s("Welcome to ZNC")); } else { const CString& sClientNick = pClient->GetNick(false); MCString msParams; @@ -723,12 +726,13 @@ void CIRCNetwork::ClientConnected(CClient* pClient) { // Tell them why they won't connect if (!GetIRCConnectEnabled()) pClient->PutStatus( - "You are currently disconnected from IRC. " - "Use 'connect' to reconnect."); + t_s("You are currently disconnected from IRC. Use 'connect' to " + "reconnect.")); if (CDebug::Debug()) { - pClient->PutStatus("ZNC is presently running in DEBUG mode. Sensitive" - " data during your current session may be exposed to the host."); + pClient->PutStatus( + t_s("ZNC is presently running in DEBUG mode. Sensitive data during " + "your current session may be exposed to the host.")); } } @@ -758,7 +762,7 @@ std::vector CIRCNetwork::FindClients( void CIRCNetwork::SetUser(CUser* pUser) { for (CClient* pClient : m_vClients) { pClient->PutStatus( - "This network is being deleted or moved to another user."); + t_s("This network is being deleted or moved to another user.")); pClient->SetNetwork(nullptr); } @@ -987,8 +991,8 @@ bool CIRCNetwork::JoinChan(CChan* pChan) { if (m_pUser->JoinTries() != 0 && pChan->GetJoinTries() >= m_pUser->JoinTries()) { - PutStatus("The channel " + pChan->GetName() + - " could not be joined, disabling it."); + PutStatus(t_f("The channel {1} could not be joined, disabling it.")( + pChan->GetName())); pChan->Disable(); } else { pChan->IncJoinTries(); @@ -1116,7 +1120,7 @@ bool CIRCNetwork::DelServer(const CString& sName, unsigned short uPort, if (pIRCSock) { pIRCSock->Quit(); - PutStatus("Your current server was removed, jumping..."); + PutStatus(t_s("Your current server was removed, jumping...")); } } else if (!bSawCurrentServer) { // Our current server comes after the server which we @@ -1278,8 +1282,9 @@ bool CIRCNetwork::Connect() { bool bSSL = pServer->IsSSL(); #ifndef HAVE_LIBSSL if (bSSL) { - PutStatus("Cannot connect to [" + pServer->GetString(false) + - "], ZNC is not compiled with SSL."); + PutStatus( + t_f("Cannot connect to {1}, because ZNC is not compiled with SSL " + "support.")(pServer->GetString(false))); CZNC::Get().AddNetworkToQueue(this); return false; } @@ -1299,7 +1304,7 @@ bool CIRCNetwork::Connect() { &bAbort); if (bAbort) { DEBUG("Some module aborted the connection attempt"); - PutStatus("Some module aborted the connection attempt"); + PutStatus(t_s("Some module aborted the connection attempt")); delete pIRCSock; CZNC::Get().AddNetworkToQueue(this); return false; diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 53734706..2aef7663 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -481,7 +481,7 @@ bool CIRCSock::OnCTCPMessage(CCTCPMessage& Message) { bool CIRCSock::OnErrorMessage(CMessage& Message) { // ERROR :Closing Link: nick[24.24.24.24] (Excess Flood) CString sError = Message.GetParam(0); - m_pNetwork->PutStatus("Error from Server [" + sError + "]"); + m_pNetwork->PutStatus(t_f("Error from server: {1}")(sError)); return true; } @@ -682,8 +682,8 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) { if (m_bAuthed && sServer == "irc.znc.in") { // m_bAuthed == true => we already received another 001 => we // might be in a traffic loop - m_pNetwork->PutStatus( - "ZNC seems to be connected to itself, disconnecting..."); + m_pNetwork->PutStatus(t_s( + "ZNC seems to be connected to itself, disconnecting...")); Quit(); return true; } @@ -730,11 +730,11 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) { CString sPort = Message.GetParam(2); CString sInfo = Message.GetParam(3); m_pNetwork->PutStatus( - "Server [" + m_pNetwork->GetCurrentServer()->GetString(false) + - "] redirects us to [" + sHost + ":" + sPort + - "] with reason [" + sInfo + "]"); + t_f("Server {1} redirects us to {2}:{3} with reason: {3}")( + m_pNetwork->GetCurrentServer()->GetString(false), sHost, + sPort, sInfo)); m_pNetwork->PutStatus( - "Perhaps you want to add it as a new server."); + t_s("Perhaps you want to add it as a new server.")); // Don't send server redirects to the client return true; } @@ -963,9 +963,9 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) { } if (pChan) { pChan->Disable(); - m_pNetwork->PutStatus("Channel [" + pChan->GetName() + - "] is linked to " - "another channel and was thus disabled."); + m_pNetwork->PutStatus( + t_f("Channel {1} is linked to another channel and was thus " + "disabled.")(pChan->GetName())); } break; } @@ -976,7 +976,7 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) { // TLS if (!GetSSL()) { StartTLS(); - m_pNetwork->PutStatus("Switched to SSL (STARTTLS)"); + m_pNetwork->PutStatus(t_s("Switched to SSL (STARTTLS)")); } return true; @@ -1029,7 +1029,7 @@ bool CIRCSock::OnQuitMessage(CQuitMessage& Message) { bool bIsVisible = false; if (Nick.NickEquals(GetNick())) { - m_pNetwork->PutStatus("You quit [" + Message.GetReason() + "]"); + m_pNetwork->PutStatus(t_f("You quit: {1}")(Message.GetReason())); // We don't call module hooks and we don't // forward this quit to clients (Some clients // disconnect if they receive such a QUIT) @@ -1235,7 +1235,7 @@ void CIRCSock::Disconnected() { if (!m_pNetwork->GetUser()->IsBeingDeleted() && m_pNetwork->GetIRCConnectEnabled() && m_pNetwork->GetServers().size() != 0) { - m_pNetwork->PutStatus("Disconnected from IRC. Reconnecting..."); + m_pNetwork->PutStatus(t_s("Disconnected from IRC. Reconnecting...")); } m_pNetwork->ClearRawBuffer(); m_pNetwork->ClearMotdBuffer(); @@ -1265,11 +1265,11 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) { DEBUG(GetSockName() << " == SockError(" << iErrno << " " << sError << ")"); if (!m_pNetwork->GetUser()->IsBeingDeleted()) { if (GetConState() != CST_OK) { - m_pNetwork->PutStatus("Cannot connect to IRC (" + sError + - "). Retrying..."); + m_pNetwork->PutStatus( + t_f("Cannot connect to IRC ({1}). Retrying...")(sError)); } else { - m_pNetwork->PutStatus("Disconnected from IRC (" + sError + - "). Reconnecting..."); + m_pNetwork->PutStatus( + t_f("Disconnected from IRC ({1}). Reconnecting...")(sError)); } #ifdef HAVE_LIBSSL if (iErrno == errnoBadSSLCert) { @@ -1299,9 +1299,8 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) { CString sSHA256 = GetSSLPeerFingerprint(); m_pNetwork->PutStatus("SHA-256: " + sSHA256); m_pNetwork->PutStatus( - "If you trust this certificate, do /znc " - "AddTrustedServerFingerprint " + - sSHA256); + t_f("If you trust this certificate, do /znc " + "AddTrustedServerFingerprint {1}")(sSHA256)); } } #endif @@ -1316,7 +1315,8 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) { void CIRCSock::Timeout() { DEBUG(GetSockName() << " == Timeout()"); if (!m_pNetwork->GetUser()->IsBeingDeleted()) { - m_pNetwork->PutStatus("IRC connection timed out. Reconnecting..."); + m_pNetwork->PutStatus( + t_s("IRC connection timed out. Reconnecting...")); } m_pNetwork->ClearRawBuffer(); m_pNetwork->ClearMotdBuffer(); @@ -1328,7 +1328,7 @@ void CIRCSock::Timeout() { void CIRCSock::ConnectionRefused() { DEBUG(GetSockName() << " == ConnectionRefused()"); if (!m_pNetwork->GetUser()->IsBeingDeleted()) { - m_pNetwork->PutStatus("Connection Refused. Reconnecting..."); + m_pNetwork->PutStatus(t_s("Connection Refused. Reconnecting...")); } m_pNetwork->ClearRawBuffer(); m_pNetwork->ClearMotdBuffer(); @@ -1336,7 +1336,7 @@ void CIRCSock::ConnectionRefused() { void CIRCSock::ReachedMaxBuffer() { DEBUG(GetSockName() << " == ReachedMaxBuffer()"); - m_pNetwork->PutStatus("Received a too long line from the IRC server!"); + m_pNetwork->PutStatus(t_s("Received a too long line from the IRC server!")); Quit(); } @@ -1440,7 +1440,7 @@ void CIRCSock::SendAltNick(const CString& sBadNick) { } else { char cLetter = 0; if (sBadNick.empty()) { - m_pNetwork->PutUser("No free nick available"); + m_pNetwork->PutUser(t_s("No free nick available")); Quit(); return; } @@ -1448,7 +1448,7 @@ void CIRCSock::SendAltNick(const CString& sBadNick) { cLetter = sBadNick.back(); if (cLetter == 'z') { - m_pNetwork->PutUser("No free nick found"); + m_pNetwork->PutUser(t_s("No free nick found")); Quit(); return; } diff --git a/src/Modules.cpp b/src/Modules.cpp index fbc0ac91..4b97cabb 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -525,8 +525,9 @@ bool CModule::AddCommand(const CString& sCmd, const COptionalTranslation& Args, } void CModule::AddHelpCommand() { - AddCommand("Help", &CModule::HandleHelpCommand, "search", - "Generate this output"); + AddCommand("Help", t_d("", "modhelpcmd"), + t_d("Generate this output", "modhelpcmd"), + [=](const CString& sLine) { HandleHelpCommand(sLine); }); } bool CModule::RemCommand(const CString& sCmd) { @@ -569,7 +570,7 @@ void CModule::HandleHelpCommand(const CString& sLine) { } } if (Table.empty()) { - PutModule("No matches for '" + sFilter + "'"); + PutModule(t_f("No matches for '{1}'")(sFilter)); } else { PutModule(Table); } @@ -687,9 +688,9 @@ void CModule::OnUnknownModCommand(const CString& sLine) { // This function is only called if OnModCommand wasn't // overriden, so no false warnings for modules which don't use // CModCommand for command handling. - PutModule("This module doesn't implement any commands."); + PutModule(t_s("This module doesn't implement any commands.")); else - PutModule("Unknown command!"); + PutModule(t_s("Unknown command!")); } void CModule::OnQuit(const CNick& Nick, const CString& sMessage, @@ -1629,7 +1630,7 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, sRetMsg = ""; if (FindModule(sModule) != nullptr) { - sRetMsg = "Module [" + sModule + "] already loaded."; + sRetMsg = t_f("Module {1} already loaded.")(sModule); return false; } @@ -1643,7 +1644,7 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CModInfo Info; if (!FindModPath(sModule, sModPath, sDataPath)) { - sRetMsg = "Unable to find module [" + sModule + "]"; + sRetMsg = t_f("Unable to find module {1}")(sModule); return false; } Info.SetName(sModule); @@ -1655,20 +1656,20 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, if (!Info.SupportsType(eType)) { dlclose(p); - sRetMsg = "Module [" + sModule + "] does not support module type [" + - CModInfo::ModuleTypeToString(eType) + "]."; + sRetMsg = t_f("Module {1} does not support module type {1}.")( + sModule, CModInfo::ModuleTypeToString(eType)); return false; } if (!pUser && eType == CModInfo::UserModule) { dlclose(p); - sRetMsg = "Module [" + sModule + "] requires a user."; + sRetMsg = t_f("Module {1} requires a user.")(sModule); return false; } if (!pNetwork && eType == CModInfo::NetworkModule) { dlclose(p); - sRetMsg = "Module [" + sModule + "] requires a network."; + sRetMsg = t_f("Module {1} requires a network.")(sModule); return false; } @@ -1684,15 +1685,15 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs, bLoaded = pModule->OnLoad(sArgs, sRetMsg); } catch (const CModule::EModException&) { bLoaded = false; - sRetMsg = "Caught an exception"; + sRetMsg = t_s("Caught an exception"); } if (!bLoaded) { UnloadModule(sModule, sModPath); if (!sRetMsg.empty()) - sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg; + sRetMsg = t_f("Module {1} aborted: {2}")(sModule, sRetMsg); else - sRetMsg = "Module [" + sModule + "] aborted."; + sRetMsg = t_f("Module {1} aborted.")(sModule); return false; } @@ -1716,7 +1717,7 @@ bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) { sRetMsg = ""; if (!pModule) { - sRetMsg = "Module [" + sMod + "] not loaded."; + sRetMsg = t_f("Module [{1}] not loaded.")(sMod); return false; } @@ -1740,12 +1741,12 @@ bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) { } dlclose(p); - sRetMsg = "Module [" + sMod + "] unloaded"; + sRetMsg = t_f("Module {1} unloaded.")(sMod); return true; } - sRetMsg = "Unable to unload module [" + sMod + "]"; + sRetMsg = t_f("Unable to unload module {1}.")(sMod); return false; } @@ -1758,7 +1759,7 @@ bool CModules::ReloadModule(const CString& sModule, const CString& sArgs, CModule* pModule = FindModule(sMod); if (!pModule) { - sRetMsg = "Module [" + sMod + "] not loaded"; + sRetMsg = t_f("Module [{1}] not loaded.")(sMod); return false; } @@ -1774,7 +1775,7 @@ bool CModules::ReloadModule(const CString& sModule, const CString& sArgs, return false; } - sRetMsg = "Reloaded module [" + sMod + "]"; + sRetMsg = t_f("Reloaded module {1}.")(sMod); return true; } @@ -1789,7 +1790,7 @@ bool CModules::GetModInfo(CModInfo& ModInfo, const CString& sModule, if (bHandled) return bSuccess; if (!FindModPath(sModule, sModPath, sTmp)) { - sRetMsg = "Unable to find module [" + sModule + "]"; + sRetMsg = t_f("Unable to find module {1}.")(sModule); return false; } @@ -1915,9 +1916,8 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath, ((sModule[a] < 'a') || (sModule[a] > 'z')) && ((sModule[a] < 'A') || (sModule[a] > 'Z')) && (sModule[a] != '_')) { sRetMsg = - "Module names can only contain letters, numbers and " - "underscores, [" + - sModule + "] is invalid."; + t_f("Module names can only contain letters, numbers and " + "underscores, [{1}] is invalid")(sModule); return nullptr; } } @@ -1940,8 +1940,8 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath, // dlerror() returns pointer to static buffer, which may be overwritten // very soon with another dl call also it may just return null. const char* cDlError = dlerror(); - CString sDlError = cDlError ? cDlError : "Unknown error"; - sRetMsg = "Unable to open module [" + sModule + "] [" + sDlError + "]"; + CString sDlError = cDlError ? cDlError : t_s("Unknown error"); + sRetMsg = t_f("Unable to open module {1}: {2}")(sModule, sDlError); return nullptr; } @@ -1950,30 +1950,28 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath, *reinterpret_cast(&fpZNCModuleEntry) = dlsym(p, "ZNCModuleEntry"); if (!fpZNCModuleEntry) { dlclose(p); - sRetMsg = "Could not find ZNCModuleEntry in module [" + sModule + "]"; + sRetMsg = t_f("Could not find ZNCModuleEntry in module {1}")(sModule); return nullptr; } const CModuleEntry* pModuleEntry = fpZNCModuleEntry(); if (std::strcmp(pModuleEntry->pcVersion, VERSION_STR) || std::strcmp(pModuleEntry->pcVersionExtra, VERSION_EXTRA)) { - sRetMsg = "Version mismatch for module [" + sModule + - "] (core is " VERSION_STR VERSION_EXTRA - ", module is built for " + - CString(pModuleEntry->pcVersion) + - pModuleEntry->pcVersionExtra + "), recompile this module."; + sRetMsg = t_f( + "Version mismatch for module {1}: core is {2}, module is built for " + "{3}. Recompile this module.")( + sModule, VERSION_STR VERSION_EXTRA, + CString(pModuleEntry->pcVersion) + pModuleEntry->pcVersionExtra); dlclose(p); return nullptr; } if (std::strcmp(pModuleEntry->pcCompileOptions, ZNC_COMPILE_OPTIONS_STRING)) { - sRetMsg = - "Module [" + sModule + - "] is built incompatibly (core is '" ZNC_COMPILE_OPTIONS_STRING - "', module is '" + - CString(pModuleEntry->pcCompileOptions) + - "'), recompile this module."; + sRetMsg = t_f( + "Module {1} is built incompatibly: core is '{2}', module is '{3}'. " + "Recompile this module.")(sModule, ZNC_COMPILE_OPTIONS_STRING, + pModuleEntry->pcCompileOptions); dlclose(p); return nullptr; } @@ -2001,14 +1999,14 @@ CModCommand::CModCommand(const CString& sCmd, CmdFunc func, : m_sCmd(sCmd), m_pFunc(std::move(func)), m_Args(Args), m_Desc(Desc) {} void CModCommand::InitHelp(CTable& Table) { - Table.AddColumn("Command"); - Table.AddColumn("Description"); + Table.AddColumn(t_s("Command", "modhelpcmd")); + Table.AddColumn(t_s("Description", "modhelpcmd")); } void CModCommand::AddHelp(CTable& Table) const { Table.AddRow(); - Table.SetCell("Command", GetCommand() + " " + GetArgs()); - Table.SetCell("Description", GetDescription()); + Table.SetCell(t_s("Command", "modhelpcmd"), GetCommand() + " " + GetArgs()); + Table.SetCell(t_s("Description", "modhelpcmd"), GetDescription()); } CString CModule::t_s(const CString& sEnglish, const CString& sContext) const {