]> jfr.im git - irc/znc/znc.git/commitdiff
More translateable strings (fix #1354)
authorAlexey Sokolov <redacted>
Tue, 3 Apr 2018 21:30:18 +0000 (22:30 +0100)
committerAlexey Sokolov <redacted>
Tue, 3 Apr 2018 21:31:20 +0000 (22:31 +0100)
include/znc/User.h
include/znc/znc.h
src/User.cpp
src/znc.cpp

index 3d87f38dfc559d65f7d1362e18c4cecb28e7e423..0f8eb35179364b5d13da3a5ada52104a0df6185a 100644 (file)
@@ -21,6 +21,7 @@
 #include <znc/Utils.h>
 #include <znc/Buffer.h>
 #include <znc/Nick.h>
+#include <znc/Translation.h>
 #include <set>
 #include <vector>
 
@@ -34,7 +35,7 @@ class CIRCSock;
 class CUserTimer;
 class CServer;
 
-class CUser {
+class CUser : private CCoreTranslationMixin {
   public:
     CUser(const CString& sUserName);
     ~CUser();
index 97148c6cbd8e0b98a2cbfb67e98e590aaa5ba6de..ecb2b41a86229873f0f07cecc8e84abcfa20357f 100644 (file)
@@ -35,7 +35,7 @@ class CConfigWriteTimer;
 class CConfig;
 class CFile;
 
-class CZNC {
+class CZNC : private CCoreTranslationMixin {
   public:
     CZNC();
     ~CZNC();
@@ -253,6 +253,8 @@ class CZNC {
     static void DumpConfig(const CConfig* Config);
 
   private:
+    static CString FormatBindError();
+
     CFile* InitPidFile();
 
     bool ReadConfig(CConfig& config, CString& sError);
index b8cf461501850777210a5b8fdac2e3ebdb2fc9b3..3a18a5f008804d383ab5eab108e598e0e84eca88 100644 (file)
@@ -504,11 +504,11 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
 CIRCNetwork* CUser::AddNetwork(const CString& sNetwork, CString& sErrorRet) {
     if (!CIRCNetwork::IsValidNetwork(sNetwork)) {
         sErrorRet =
-            "Invalid network name. It should be alphanumeric. Not to be "
-            "confused with server name";
+            t_s("Invalid network name. It should be alphanumeric. Not to be "
+                "confused with server name");
         return nullptr;
     } else if (FindNetwork(sNetwork)) {
-        sErrorRet = "Network [" + sNetwork.Token(0) + "] already exists";
+        sErrorRet = t_f("Network {1} already exists")(sNetwork);
         return nullptr;
     }
 
@@ -674,8 +674,8 @@ void CUser::UserConnected(CClient* pClient) {
         BounceAllClients();
     }
 
-    pClient->PutClient(":irc.znc.in 001 " + pClient->GetNick() +
-                       " :- Welcome to ZNC -");
+    pClient->PutClient(":irc.znc.in 001 " + pClient->GetNick() + " :" +
+                       t_s("Welcome to ZNC"));
 
     m_vClients.push_back(pClient);
 }
@@ -774,8 +774,8 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks) {
     for (CClient* pSock : m_vClients) {
         if (!IsHostAllowed(pSock->GetRemoteIP())) {
             pSock->PutStatusNotice(
-                "You are being disconnected because your IP is no longer "
-                "allowed to connect to this user");
+                t_s("You are being disconnected because your IP is no longer "
+                    "allowed to connect to this user"));
             pSock->Close();
         }
     }
@@ -904,17 +904,17 @@ bool CUser::IsValid(CString& sErrMsg, bool bSkipPass) const {
     sErrMsg.clear();
 
     if (!bSkipPass && m_sPass.empty()) {
-        sErrMsg = "Pass is empty";
+        sErrMsg = t_s("Password is empty");
         return false;
     }
 
     if (m_sUserName.empty()) {
-        sErrMsg = "Username is empty";
+        sErrMsg = t_s("Username is empty");
         return false;
     }
 
     if (!CUser::IsValidUserName(m_sUserName)) {
-        sErrMsg = "Username is invalid";
+        sErrMsg = t_s("Username is invalid");
         return false;
     }
 
@@ -1185,7 +1185,7 @@ bool CUser::LoadModule(const CString& sModName, const CString& sArgs,
 
     CModInfo ModInfo;
     if (!CZNC::Get().GetModules().GetModInfo(ModInfo, sModName, sModRet)) {
-        sError = "Unable to find modinfo [" + sModName + "] [" + sModRet + "]";
+        sError = t_f("Unable to find modinfo {1}: {2}")(sModName, sModRet);
         return false;
     }
 
index 8e3ba615cc45c5f8bf94f359167b18cd1f324644..4e7216ee176017caef5fbe89c65799b61aa0c592 100644 (file)
@@ -34,12 +34,6 @@ using std::list;
 using std::tuple;
 using std::make_tuple;
 
-static inline CString FormatBindError() {
-    CString sError = (errno == 0 ? CString("unknown error, check the host name")
-                                 : CString(strerror(errno)));
-    return "Unable to bind [" + sError + "]";
-}
-
 CZNC::CZNC()
     : m_TimeStarted(time(nullptr)),
       m_eConfigState(ECONFIG_NOTHING),
@@ -1566,7 +1560,7 @@ bool CZNC::DeleteUser(const CString& sUsername) {
 
 bool CZNC::AddUser(CUser* pUser, CString& sErrorRet, bool bStartup) {
     if (FindUser(pUser->GetUserName()) != nullptr) {
-        sErrorRet = "User already exists";
+        sErrorRet = t_s("User already exists");
         DEBUG("User [" << pUser->GetUserName() << "] - already exists");
         return false;
     }
@@ -1674,7 +1668,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
 
 #ifndef HAVE_IPV6
     if (ADDR_IPV6ONLY == eAddr) {
-        sError = "IPV6 is not enabled";
+        sError = t_s("IPv6 is not enabled");
         CUtils::PrintStatus(false, sError);
         return false;
     }
@@ -1682,7 +1676,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
 
 #ifndef HAVE_LIBSSL
     if (bSSL) {
-        sError = "SSL is not enabled";
+        sError = t_s("SSL is not enabled");
         CUtils::PrintStatus(false, sError);
         return false;
     }
@@ -1690,7 +1684,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
     CString sPemFile = GetPemLocation();
 
     if (bSSL && !CFile::Exists(sPemFile)) {
-        sError = "Unable to locate pem file: [" + sPemFile + "]";
+        sError = t_f("Unable to locate pem file: {1}")(sPemFile);
         CUtils::PrintStatus(false, sError);
 
         // If stdin is e.g. /dev/null and we call GetBoolInput(),
@@ -1709,7 +1703,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
     }
 #endif
     if (!uPort) {
-        sError = "Invalid port";
+        sError = t_s("Invalid port");
         CUtils::PrintStatus(false, sError);
         return false;
     }
@@ -1822,6 +1816,12 @@ bool CZNC::DelListener(CListener* pListener) {
     return false;
 }
 
+CString CZNC::FormatBindError() {
+    CString sError = (errno == 0 ? t_s(("unknown error, check the host name"))
+                                 : CString(strerror(errno)));
+    return t_f("Unable to bind: {1}")(sError);
+}
+
 static CZNC* s_pZNC = nullptr;
 
 void CZNC::CreateInstance() {