diff --git a/include/znc/Modules.h b/include/znc/Modules.h index 900989ac..4eaab848 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -60,24 +60,25 @@ class CModInfo; #define ZNC_EXPORT_LIB_EXPORT #endif -#define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE) \ - extern "C" { \ - ZNC_EXPORT_LIB_EXPORT bool ZNCModInfo(double dCoreVersion, \ - CModInfo& Info); \ - ZNC_EXPORT_LIB_EXPORT bool ZNCModInfo(double dCoreVersion, \ - CModInfo& Info) { \ - if (dCoreVersion != VERSION) return false; \ - auto t = [&](const CString& sEnglish, const CString& sContext = "") { \ - return sEnglish.empty() ? "" : Info.t(sEnglish, sContext); \ - }; \ - t(CString()); /* Don't warn about unused t */ \ - Info.SetDescription(DESCRIPTION); \ - Info.SetDefaultType(TYPE); \ - Info.AddType(TYPE); \ - Info.SetLoader(TModLoad); \ - TModInfo(Info); \ - return true; \ - } \ +#define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE) \ + extern "C" { \ + ZNC_EXPORT_LIB_EXPORT bool ZNCModInfo(double dCoreVersion, \ + CModInfo& Info); \ + ZNC_EXPORT_LIB_EXPORT bool ZNCModInfo(double dCoreVersion, \ + CModInfo& Info) { \ + if (dCoreVersion != VERSION) return false; \ + auto t_s = [&](const CString& sEnglish, \ + const CString& sContext = "") { \ + return sEnglish.empty() ? "" : Info.t_s(sEnglish, sContext); \ + }; \ + t_s(CString()); /* Don't warn about unused t_s */ \ + Info.SetDescription(DESCRIPTION); \ + Info.SetDefaultType(TYPE); \ + Info.AddType(TYPE); \ + Info.SetLoader(TModLoad); \ + TModInfo(Info); \ + return true; \ + } \ } /** Instead of writing a constructor, you should call this macro. It accepts all @@ -280,7 +281,7 @@ class CModInfo { void SetDefaultType(EModuleType eType) { m_eDefaultType = eType; } // !Setters - CString t(const CString& sEnglish, const CString& sContext = "") const; + CString t_s(const CString& sEnglish, const CString& sContext = "") const; private: protected: @@ -1301,13 +1302,13 @@ class CModule { #ifndef SWIG // Translation - CString t(const CString& sEnglish, const CString& sContext = "") const; - CInlineFormatMessage f(const CString& sEnglish, - const CString& sContext = "") const; - CInlineFormatMessage p(const CString& sEnglish, const CString& sEnglishes, - int iNum, const CString& sContext = "") const; - CDelayedTranslation d(const CString& sEnglish, - const CString& sContext = "") const; + CString t_s(const CString& sEnglish, const CString& sContext = "") const; + CInlineFormatMessage t_f(const CString& sEnglish, + const CString& sContext = "") const; + CInlineFormatMessage t_p(const CString& sEnglish, const CString& sEnglishes, + int iNum, const CString& sContext = "") const; + CDelayedTranslation t_d(const CString& sEnglish, + const CString& sContext = "") const; #endif protected: diff --git a/include/znc/Socket.h b/include/znc/Socket.h index eea0b4da..34bedf87 100644 --- a/include/znc/Socket.h +++ b/include/znc/Socket.h @@ -279,13 +279,13 @@ class CSocket : public CZNCSock { #ifndef SWIG // Translation. As opposed to CCoreTranslationMixin, this one uses module.mo - CString t(const CString& sEnglish, const CString& sContext = "") const; - CInlineFormatMessage f(const CString& sEnglish, - const CString& sContext = "") const; - CInlineFormatMessage p(const CString& sEnglish, const CString& sEnglishes, - int iNum, const CString& sContext) const; - CDelayedTranslation d(const CString& sEnglish, - const CString& sContext = "") const; + CString t_s(const CString& sEnglish, const CString& sContext = "") const; + CInlineFormatMessage t_f(const CString& sEnglish, + const CString& sContext = "") const; + CInlineFormatMessage t_p(const CString& sEnglish, const CString& sEnglishes, + int iNum, const CString& sContext) const; + CDelayedTranslation t_d(const CString& sEnglish, + const CString& sContext = "") const; #endif private: diff --git a/include/znc/Translation.h b/include/znc/Translation.h index e415be75..28df1da1 100644 --- a/include/znc/Translation.h +++ b/include/znc/Translation.h @@ -78,14 +78,14 @@ class CDelayedTranslation { // CModule defines its own version of these functions. class CCoreTranslationMixin { protected: - static CString t(const CString& sEnglish, const CString& sContext = ""); - static CInlineFormatMessage f(const CString& sEnglish, - const CString& sContext = ""); - static CInlineFormatMessage p(const CString& sEnglish, - const CString& sEnglishes, int iNum, - const CString& sContext = ""); - static CDelayedTranslation d(const CString& sEnglish, - const CString& sContext = ""); + static CString t_s(const CString& sEnglish, const CString& sContext = ""); + static CInlineFormatMessage t_f(const CString& sEnglish, + const CString& sContext = ""); + static CInlineFormatMessage t_p(const CString& sEnglish, + const CString& sEnglishes, int iNum, + const CString& sContext = ""); + static CDelayedTranslation t_d(const CString& sEnglish, + const CString& sContext = ""); }; #endif diff --git a/modules/cert.cpp b/modules/cert.cpp index 6054b156..8254ff7a 100644 --- a/modules/cert.cpp +++ b/modules/cert.cpp @@ -25,9 +25,9 @@ class CCertMod : public CModule { public: void Delete(const CString& line) { if (CFile::Delete(PemFile())) { - PutModule(t("Pem file deleted")); + PutModule(t_s("Pem file deleted")); } else { - PutModule(t( + PutModule(t_s( "The pem file doesn't exist or there was a error deleting the " "pem file.")); } @@ -35,14 +35,13 @@ class CCertMod : public CModule { void Info(const CString& line) { if (HasPemFile()) { - PutModule(f("You have a certificate in {1}")(PemFile())); + PutModule(t_f("You have a certificate in {1}")(PemFile())); } else { - PutModule(t( + PutModule(t_s( "You do not have a certificate. Please use the web interface " "to add a certificate")); if (GetUser()->IsAdmin()) { - PutModule(f( - "Alternatively you can either place one at {1}")( + PutModule(t_f("Alternatively you can either place one at {1}")( PemFile())); } } @@ -50,9 +49,9 @@ class CCertMod : public CModule { MODCONSTRUCTOR(CCertMod) { AddHelpCommand(); - AddCommand("delete", "", d("Delete the current certificate"), + AddCommand("delete", "", t_d("Delete the current certificate"), [=](const CString& sLine) { Delete(sLine); }); - AddCommand("info", "", d("Show the current certificate"), + AddCommand("info", "", t_d("Show the current certificate"), [=](const CString& sLine) { Info(sLine); }); } @@ -70,7 +69,7 @@ class CCertMod : public CModule { return CONTINUE; } - CString GetWebMenuTitle() override { return t("Certificate"); } + CString GetWebMenuTitle() override { return t_s("Certificate"); } bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) override { @@ -103,4 +102,4 @@ void TModInfo(CModInfo& Info) { Info.SetWikiPage("cert"); } -NETWORKMODULEDEFS(CCertMod, t("Use a ssl certificate to connect to a server")) +NETWORKMODULEDEFS(CCertMod, t_s("Use a ssl certificate to connect to a server")) diff --git a/modules/modperl/startup.pl b/modules/modperl/startup.pl index 0501f2a4..b053cbda 100644 --- a/modules/modperl/startup.pl +++ b/modules/modperl/startup.pl @@ -652,7 +652,7 @@ sub CreateSocket { $psock; } -sub t { +sub t_s { my $self = shift; my $module = ref $self; my $english = shift; @@ -660,13 +660,13 @@ sub t { ZNC::CTranslation::Get->Singular("znc-$module", $context, $english); } -sub f { +sub t_f { my $self = shift; - my $fmt = $self->t(@_); + my $fmt = $self->t_s(@_); return sub { sprintf $fmt, @_ } } -sub p { +sub t_p { my $self = shift; my $module = ref $self; my $english = shift; diff --git a/modules/modpython/znc.py b/modules/modpython/znc.py index 48015fff..01292244 100644 --- a/modules/modpython/znc.py +++ b/modules/modpython/znc.py @@ -170,18 +170,18 @@ class Module: return self.GetModName() @classmethod - def t(cls, english, context=''): + def t_s(cls, english, context=''): domain = 'znc-' + cls.__name__ return CTranslation.Get().Singular(domain, context, english) @classmethod - def f(cls, english, context=''): - fmt = cls.t(english, context) + def t_f(cls, english, context=''): + fmt = cls.t_s(english, context) # Returning bound method return fmt.format @classmethod - def p(cls, english, englishes, num, context=''): + def t_p(cls, english, englishes, num, context=''): domain = 'znc-' + cls.__name__ fmt = CTranslation.Get().Plural(domain, context, english, englishes, num) diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index 121dcdcd..01746ce4 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -88,13 +88,13 @@ class CWebAdminMod : public CModule { VPair vParams; vParams.push_back(make_pair("user", "")); AddSubPage(std::make_shared( - "settings", d("Global Settings"), vParams, CWebSubPage::F_ADMIN)); - AddSubPage(std::make_shared("edituser", d("Your Settings"), - vParams)); - AddSubPage(std::make_shared("traffic", d("Traffic Info"), + "settings", t_d("Global Settings"), vParams, CWebSubPage::F_ADMIN)); + AddSubPage(std::make_shared( + "edituser", t_d("Your Settings"), vParams)); + AddSubPage(std::make_shared("traffic", t_d("Traffic Info"), vParams)); AddSubPage(std::make_shared( - "listusers", d("Manage Users"), vParams, CWebSubPage::F_ADMIN)); + "listusers", t_d("Manage Users"), vParams, CWebSubPage::F_ADMIN)); } ~CWebAdminMod() override {} @@ -185,7 +185,7 @@ class CWebAdminMod : public CModule { if (sUsername.empty()) { WebSock.PrintErrorPage( - t("Invalid Submission [Username is required]")); + t_s("Invalid Submission [Username is required]")); return nullptr; } @@ -198,7 +198,7 @@ class CWebAdminMod : public CModule { if (sArg != WebSock.GetParam("password2")) { WebSock.PrintErrorPage( - t("Invalid Submission [Passwords do not match]")); + t_s("Invalid Submission [Passwords do not match]")); return nullptr; } @@ -380,11 +380,11 @@ class CWebAdminMod : public CModule { sModName, sArgs, CModInfo::UserModule, pNewUser, nullptr, sModRet)) { sModLoadError = - f("Unable to load module [{1}]: {2}")(sModName, - sModRet); + t_f("Unable to load module [{1}]: {2}")( + sModName, sModRet); } } catch (...) { - sModLoadError = f( + sModLoadError = t_f( "Unable to load module [{1}] with arguments [{2}]")( sModName, sArgs); } @@ -408,12 +408,12 @@ class CWebAdminMod : public CModule { if (!pNewUser->GetModules().LoadModule( sModName, sArgs, CModInfo::UserModule, pNewUser, nullptr, sModRet)) { - sModLoadError = f("Unable to load module [{1}]: {2}")( + sModLoadError = t_f("Unable to load module [{1}]: {2}")( sModName, sModRet); } } catch (...) { sModLoadError = - f("Unable to load module [{1}] with arguments [{2}]")( + t_f("Unable to load module [{1}] with arguments [{2}]")( sModName, sArgs); } @@ -494,7 +494,7 @@ class CWebAdminMod : public CModule { return NetworkPage(WebSock, Tmpl, pUser); } - WebSock.PrintErrorPage(t("No such user")); + WebSock.PrintErrorPage(t_s("No such user")); return true; } else if (sPageName == "editnetwork") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); @@ -507,7 +507,7 @@ class CWebAdminMod : public CModule { } if (!pNetwork) { - WebSock.PrintErrorPage(t("No such user or network")); + WebSock.PrintErrorPage(t_s("No such user or network")); return true; } @@ -539,7 +539,7 @@ class CWebAdminMod : public CModule { } if (!pNetwork) { - WebSock.PrintErrorPage(t("No such user or network")); + WebSock.PrintErrorPage(t_s("No such user or network")); return true; } @@ -549,7 +549,7 @@ class CWebAdminMod : public CModule { } CChan* pChan = pNetwork->FindChan(sChan); if (!pChan) { - WebSock.PrintErrorPage(t("No such channel")); + WebSock.PrintErrorPage(t_s("No such channel")); return true; } @@ -568,7 +568,7 @@ class CWebAdminMod : public CModule { return ChanPage(WebSock, Tmpl, pNetwork); } - WebSock.PrintErrorPage(t("No such user or network")); + WebSock.PrintErrorPage(t_s("No such user or network")); return true; } else if (sPageName == "delchan") { CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock); @@ -584,7 +584,7 @@ class CWebAdminMod : public CModule { return DelChan(WebSock, pNetwork); } - WebSock.PrintErrorPage(t("No such user or network")); + WebSock.PrintErrorPage(t_s("No such user or network")); return true; } else if (sPageName == "deluser") { if (!spSession->IsAdmin()) { @@ -598,7 +598,7 @@ class CWebAdminMod : public CModule { CUser* pUser = CZNC::Get().FindUser(sUser); if (!pUser) { - WebSock.PrintErrorPage(t("No such user")); + WebSock.PrintErrorPage(t_s("No such user")); return true; } @@ -615,15 +615,15 @@ class CWebAdminMod : public CModule { if (pUser && pUser == spSession->GetUser()) { WebSock.PrintErrorPage( - t("Please don't delete yourself, suicide is not the " - "answer!")); + t_s("Please don't delete yourself, suicide is not the " + "answer!")); return true; } else if (CZNC::Get().DeleteUser(sUser)) { WebSock.Redirect(GetWebPath() + "listusers"); return true; } - WebSock.PrintErrorPage(t("No such user")); + WebSock.PrintErrorPage(t_s("No such user")); return true; } else if (sPageName == "edituser") { CString sUserName = SafeGetUserNameParam(WebSock); @@ -645,7 +645,7 @@ class CWebAdminMod : public CModule { return UserPage(WebSock, Tmpl, pUser); } - WebSock.PrintErrorPage(t("No such user")); + WebSock.PrintErrorPage(t_s("No such user")); return true; } else if (sPageName == "listusers" && spSession->IsAdmin()) { return ListUsersPage(WebSock, Tmpl); @@ -679,7 +679,7 @@ class CWebAdminMod : public CModule { CUser* pUser = pNetwork->GetUser(); if (!pUser) { - WebSock.PrintErrorPage(t("No such user")); + WebSock.PrintErrorPage(t_s("No such user")); return true; } @@ -688,11 +688,11 @@ class CWebAdminMod : public CModule { Tmpl["Network"] = pNetwork->GetName(); CTemplate& breadUser = Tmpl.AddRow("BreadCrumbs"); - breadUser["Text"] = f("Edit User [{1}]")(pUser->GetUserName()); + breadUser["Text"] = t_f("Edit User [{1}]")(pUser->GetUserName()); breadUser["URL"] = GetWebPath() + "edituser?user=" + pUser->GetUserName(); CTemplate& breadNet = Tmpl.AddRow("BreadCrumbs"); - breadNet["Text"] = f("Edit Network [{1}]")(pNetwork->GetName()); + breadNet["Text"] = t_f("Edit Network [{1}]")(pNetwork->GetName()); breadNet["URL"] = GetWebPath() + "editnetwork?user=" + pUser->GetUserName() + "&network=" + pNetwork->GetName(); @@ -702,35 +702,36 @@ class CWebAdminMod : public CModule { Tmpl["Action"] = "editchan"; Tmpl["Edit"] = "true"; Tmpl["Title"] = - f("Edit Channel [{1}] of Network [{2}] of User [{3}]")( + t_f("Edit Channel [{1}] of Network [{2}] of User [{3}]")( pChan->GetName(), pNetwork->GetName(), pUser->GetUserName()); Tmpl["ChanName"] = pChan->GetName(); Tmpl["BufferSize"] = CString(pChan->GetBufferCount()); Tmpl["DefModes"] = pChan->GetDefaultModes(); Tmpl["Key"] = pChan->GetKey(); - breadChan["Text"] = f("Edit Channel [{1}]")(pChan->GetName()); + breadChan["Text"] = t_f("Edit Channel [{1}]")(pChan->GetName()); if (pChan->InConfig()) { Tmpl["InConfig"] = "true"; } } else { Tmpl["Action"] = "addchan"; - Tmpl["Title"] = f("Add Channel to Network [{1}] of User [{2}]")( - pNetwork->GetName(), pUser->GetUserName()); + Tmpl["Title"] = + t_f("Add Channel to Network [{1}] of User [{2}]")( + pNetwork->GetName(), pUser->GetUserName()); Tmpl["BufferSize"] = CString(pUser->GetBufferCount()); Tmpl["DefModes"] = CString(pUser->GetDefaultChanModes()); Tmpl["InConfig"] = "true"; - breadChan["Text"] = t("Add Channel"); + breadChan["Text"] = t_s("Add Channel"); } // o1 used to be AutoCycle which was removed CTemplate& o2 = Tmpl.AddRow("OptionLoop"); o2["Name"] = "autoclearchanbuffer"; - o2["DisplayName"] = t("Auto Clear Chan Buffer"); + o2["DisplayName"] = t_s("Auto Clear Chan Buffer"); o2["Tooltip"] = - t("Automatically Clear Channel Buffer After Playback"); + t_s("Automatically Clear Channel Buffer After Playback"); if ((pChan && pChan->AutoClearChanBuffer()) || (!pChan && pUser->AutoClearChanBuffer())) { o2["Checked"] = "true"; @@ -738,14 +739,14 @@ class CWebAdminMod : public CModule { CTemplate& o3 = Tmpl.AddRow("OptionLoop"); o3["Name"] = "detached"; - o3["DisplayName"] = t("Detached"); + o3["DisplayName"] = t_s("Detached"); if (pChan && pChan->IsDetached()) { o3["Checked"] = "true"; } CTemplate& o4 = Tmpl.AddRow("OptionLoop"); o4["Name"] = "enabled"; - o4["DisplayName"] = t("Enabled"); + o4["DisplayName"] = t_s("Enabled"); if (pChan && !pChan->IsDisabled()) { o4["Checked"] = "true"; } @@ -769,7 +770,7 @@ class CWebAdminMod : public CModule { if (!pChan) { if (sChanName.empty()) { WebSock.PrintErrorPage( - t("Channel name is a required argument")); + t_s("Channel name is a required argument")); return true; } @@ -778,14 +779,14 @@ class CWebAdminMod : public CModule { if (pNetwork->FindChan(pChan->GetName())) { WebSock.PrintErrorPage( - f("Channel [{1}] already exists")(pChan->GetName())); + t_f("Channel [{1}] already exists")(pChan->GetName())); delete pChan; return true; } if (!pNetwork->AddChan(pChan)) { WebSock.PrintErrorPage( - f("Could not add channel [{1}]")(sChanName)); + t_f("Could not add channel [{1}]")(sChanName)); return true; } } @@ -832,7 +833,7 @@ class CWebAdminMod : public CModule { } if (!CZNC::Get().WriteConfig()) { - WebSock.PrintErrorPage(t( + WebSock.PrintErrorPage(t_s( "Channel was added/modified, but config file was not written")); return true; } @@ -909,7 +910,7 @@ class CWebAdminMod : public CModule { } CTemplate& breadUser = Tmpl.AddRow("BreadCrumbs"); - breadUser["Text"] = f("Edit User [{1}]")(pUser->GetUserName()); + breadUser["Text"] = t_f("Edit User [{1}]")(pUser->GetUserName()); breadUser["URL"] = GetWebPath() + "edituser?user=" + pUser->GetUserName(); CTemplate& breadNet = Tmpl.AddRow("BreadCrumbs"); @@ -917,7 +918,7 @@ class CWebAdminMod : public CModule { if (pNetwork) { Tmpl["Action"] = "editnetwork"; Tmpl["Edit"] = "true"; - Tmpl["Title"] = f("Edit Network [{1}] of User [{2}]")( + Tmpl["Title"] = t_f("Edit Network [{1}] of User [{2}]")( pNetwork->GetName(), pUser->GetUserName()); Tmpl["Name"] = pNetwork->GetName(); @@ -940,7 +941,8 @@ class CWebAdminMod : public CModule { Tmpl["TrustAllCerts"] = CString(pNetwork->GetTrustAllCerts()); Tmpl["TrustPKI"] = CString(pNetwork->GetTrustPKI()); - breadNet["Text"] = f("Edit Network [{1}]")(pNetwork->GetName()); + breadNet["Text"] = + t_f("Edit Network [{1}]")(pNetwork->GetName()); const vector& vServers = pNetwork->GetServers(); for (const CServer* pServer : vServers) { @@ -977,15 +979,15 @@ class CWebAdminMod : public CModule { } else { if (!spSession->IsAdmin() && !pUser->HasSpaceForNewNetwork()) { WebSock.PrintErrorPage( - t("Network number limit reached. Ask an admin to " - "increase the limit for you, or delete unneeded " - "networks from Your Settings.")); + t_s("Network number limit reached. Ask an admin to " + "increase the limit for you, or delete unneeded " + "networks from Your Settings.")); return true; } Tmpl["Action"] = "addnetwork"; Tmpl["Title"] = - f("Add Network for User [{1}]")(pUser->GetUserName()); + t_f("Add Network for User [{1}]")(pUser->GetUserName()); Tmpl["IRCConnectEnabled"] = "true"; Tmpl["TrustAllCerts"] = "false"; Tmpl["TrustPKI"] = "true"; @@ -993,7 +995,7 @@ class CWebAdminMod : public CModule { Tmpl["FloodRate"] = "1.0"; Tmpl["FloodBurst"] = "4"; Tmpl["JoinDelay"] = "0"; - breadNet["Text"] = t("Add Network"); + breadNet["Text"] = t_s("Add Network"); } FOR_EACH_MODULE(i, make_pair(pUser, pNetwork)) { @@ -1039,15 +1041,15 @@ class CWebAdminMod : public CModule { CString sName = WebSock.GetParam("name").Trim_n(); if (sName.empty()) { - WebSock.PrintErrorPage(t("Network name is a required argument")); + WebSock.PrintErrorPage(t_s("Network name is a required argument")); return true; } if (!pNetwork && !spSession->IsAdmin() && !pUser->HasSpaceForNewNetwork()) { - WebSock.PrintErrorPage( - t("Network number limit reached. Ask an admin to increase the " - "limit for you, or delete unneeded networks from Your " - "Settings.")); + WebSock.PrintErrorPage(t_s( + "Network number limit reached. Ask an admin to increase the " + "limit for you, or delete unneeded networks from Your " + "Settings.")); return true; } if (!pNetwork || pNetwork->GetName() != sName) { @@ -1156,14 +1158,14 @@ class CWebAdminMod : public CModule { sModName, sArgs, CModInfo::NetworkModule, pUser, pNetwork, sModRet)) { sModLoadError = - f("Unable to load module [{1}]: {2}")(sModName, - sModRet); + t_f("Unable to load module [{1}]: {2}")( + sModName, sModRet); } } else if (pMod->GetArgs() != sArgs) { if (!pNetwork->GetModules().ReloadModule( sModName, sArgs, pUser, pNetwork, sModRet)) { sModLoadError = - f("Unable to reload module [{1}]: {2}")( + t_f("Unable to reload module [{1}]: {2}")( sModName, sModRet); } } @@ -1199,7 +1201,7 @@ class CWebAdminMod : public CModule { } if (!CZNC::Get().WriteConfig()) { - WebSock.PrintErrorPage(t( + WebSock.PrintErrorPage(t_s( "Network was added/modified, but config file was not written")); return true; } @@ -1223,13 +1225,13 @@ class CWebAdminMod : public CModule { } if (!pUser) { - WebSock.PrintErrorPage(t("No such user")); + WebSock.PrintErrorPage(t_s("No such user")); return true; } if (sNetwork.empty()) { WebSock.PrintErrorPage( - t("That network doesn't exist for this user")); + t_s("That network doesn't exist for this user")); return true; } @@ -1246,7 +1248,7 @@ class CWebAdminMod : public CModule { if (!CZNC::Get().WriteConfig()) { WebSock.PrintErrorPage( - t("Network was deleted, but config file was not written")); + t_s("Network was deleted, but config file was not written")); return true; } @@ -1260,7 +1262,7 @@ class CWebAdminMod : public CModule { if (sChan.empty()) { WebSock.PrintErrorPage( - t("That channel doesn't exist for this network")); + t_s("That channel doesn't exist for this network")); return true; } @@ -1269,7 +1271,7 @@ class CWebAdminMod : public CModule { if (!CZNC::Get().WriteConfig()) { WebSock.PrintErrorPage( - t("Channel was deleted, but config file was not written")); + t_s("Channel was deleted, but config file was not written")); return true; } @@ -1287,14 +1289,15 @@ class CWebAdminMod : public CModule { if (!WebSock.GetParam("submitted").ToUInt()) { if (pUser) { Tmpl["Action"] = "edituser"; - Tmpl["Title"] = f("Edit User [{1}]")(pUser->GetUserName()); + Tmpl["Title"] = t_f("Edit User [{1}]")(pUser->GetUserName()); Tmpl["Edit"] = "true"; } else { CString sUsername = WebSock.GetParam("clone", false); pUser = CZNC::Get().FindUser(sUsername); if (pUser) { - Tmpl["Title"] = f("Clone User [{1}]")(pUser->GetUserName()); + Tmpl["Title"] = + t_f("Clone User [{1}]")(pUser->GetUserName()); Tmpl["Clone"] = "true"; Tmpl["CloneUsername"] = pUser->GetUserName(); } @@ -1475,10 +1478,10 @@ class CWebAdminMod : public CModule { CTemplate& o1 = Tmpl.AddRow("OptionLoop"); o1["Name"] = "autoclearchanbuffer"; - o1["DisplayName"] = t("Auto Clear Chan Buffer"); + o1["DisplayName"] = t_s("Auto Clear Chan Buffer"); o1["Tooltip"] = - t("Automatically Clear Channel Buffer After Playback (the " - "default value for new channels)"); + t_s("Automatically Clear Channel Buffer After Playback (the " + "default value for new channels)"); if (!pUser || pUser->AutoClearChanBuffer()) { o1["Checked"] = "true"; } @@ -1487,21 +1490,21 @@ class CWebAdminMod : public CModule { CTemplate& o4 = Tmpl.AddRow("OptionLoop"); o4["Name"] = "multiclients"; - o4["DisplayName"] = t("Multi Clients"); + o4["DisplayName"] = t_s("Multi Clients"); if (!pUser || pUser->MultiClients()) { o4["Checked"] = "true"; } CTemplate& o7 = Tmpl.AddRow("OptionLoop"); o7["Name"] = "appendtimestamp"; - o7["DisplayName"] = t("Append Timestamps"); + o7["DisplayName"] = t_s("Append Timestamps"); if (pUser && pUser->GetTimestampAppend()) { o7["Checked"] = "true"; } CTemplate& o8 = Tmpl.AddRow("OptionLoop"); o8["Name"] = "prependtimestamp"; - o8["DisplayName"] = t("Prepend Timestamps"); + o8["DisplayName"] = t_s("Prepend Timestamps"); if (pUser && pUser->GetTimestampPrepend()) { o8["Checked"] = "true"; } @@ -1509,14 +1512,14 @@ class CWebAdminMod : public CModule { if (spSession->IsAdmin()) { CTemplate& o9 = Tmpl.AddRow("OptionLoop"); o9["Name"] = "denyloadmod"; - o9["DisplayName"] = t("Deny LoadMod"); + o9["DisplayName"] = t_s("Deny LoadMod"); if (pUser && pUser->DenyLoadMod()) { o9["Checked"] = "true"; } CTemplate& o10 = Tmpl.AddRow("OptionLoop"); o10["Name"] = "isadmin"; - o10["DisplayName"] = t("Admin"); + o10["DisplayName"] = t_s("Admin"); if (pUser && pUser->IsAdmin()) { o10["Checked"] = "true"; } @@ -1526,7 +1529,7 @@ class CWebAdminMod : public CModule { CTemplate& o11 = Tmpl.AddRow("OptionLoop"); o11["Name"] = "denysetbindhost"; - o11["DisplayName"] = t("Deny SetBindHost"); + o11["DisplayName"] = t_s("Deny SetBindHost"); if (pUser && pUser->DenySetBindHost()) { o11["Checked"] = "true"; } @@ -1534,9 +1537,9 @@ class CWebAdminMod : public CModule { CTemplate& o12 = Tmpl.AddRow("OptionLoop"); o12["Name"] = "autoclearquerybuffer"; - o12["DisplayName"] = t("Auto Clear Query Buffer"); + o12["DisplayName"] = t_s("Auto Clear Query Buffer"); o12["Tooltip"] = - t("Automatically Clear Query Buffer After Playback"); + t_s("Automatically Clear Query Buffer After Playback"); if (!pUser || pUser->AutoClearQueryBuffer()) { o12["Checked"] = "true"; } @@ -1560,7 +1563,7 @@ class CWebAdminMod : public CModule { CString sUsername = WebSock.GetParam("user"); if (!pUser && CZNC::Get().FindUser(sUsername)) { WebSock.PrintErrorPage( - f("Invalid Submission: User {1} already exists")(sUsername)); + t_f("Invalid Submission: User {1} already exists")(sUsername)); return true; } @@ -1582,24 +1585,24 @@ class CWebAdminMod : public CModule { // Add User Submission if (!CZNC::Get().AddUser(pNewUser, sErr)) { delete pNewUser; - WebSock.PrintErrorPage(f("Invalid submission: {1}")(sErr)); + WebSock.PrintErrorPage(t_f("Invalid submission: {1}")(sErr)); return true; } pUser = pNewUser; sConfigErrorMsg = - t("User was added, but config file was not written"); + t_s("User was added, but config file was not written"); } else { // Edit User Submission if (!pUser->Clone(*pNewUser, sErr, false)) { delete pNewUser; - WebSock.PrintErrorPage(f("Invalid submission: {1}")(sErr)); + WebSock.PrintErrorPage(t_f("Invalid submission: {1}")(sErr)); return true; } delete pNewUser; sConfigErrorMsg = - t("User was edited, but config file was not written"); + t_s("User was edited, but config file was not written"); } CTemplate TmplMod; @@ -1628,7 +1631,7 @@ class CWebAdminMod : public CModule { bool ListUsersPage(CWebSock& WebSock, CTemplate& Tmpl) { std::shared_ptr spSession = WebSock.GetSession(); const map& msUsers = CZNC::Get().GetUserMap(); - Tmpl["Title"] = t("Manage Users"); + Tmpl["Title"] = t_s("Manage Users"); Tmpl["Action"] = "listusers"; for (const auto& it : msUsers) { @@ -1649,7 +1652,7 @@ class CWebAdminMod : public CModule { bool TrafficPage(CWebSock& WebSock, CTemplate& Tmpl) { std::shared_ptr spSession = WebSock.GetSession(); - Tmpl["Title"] = t("Traffic Info"); + Tmpl["Title"] = t_s("Traffic Info"); Tmpl["Uptime"] = CZNC::Get().GetUptime(); const map& msUsers = CZNC::Get().GetUserMap(); @@ -1757,7 +1760,7 @@ class CWebAdminMod : public CModule { eAddr = ADDR_IPV6ONLY; } else { WebSock.GetSession()->AddError( - t("Choose either IPv4 or IPv6 or both.")); + t_s("Choose either IPv4 or IPv6 or both.")); return SettingsPage(WebSock, Tmpl); } } @@ -1774,7 +1777,7 @@ class CWebAdminMod : public CModule { eAccept = CListener::ACCEPT_HTTP; } else { WebSock.GetSession()->AddError( - t("Choose either IRC or HTTP or both.")); + t_s("Choose either IRC or HTTP or both.")); return SettingsPage(WebSock, Tmpl); } } @@ -1787,7 +1790,7 @@ class CWebAdminMod : public CModule { } if (!CZNC::Get().WriteConfig()) { WebSock.GetSession()->AddError( - t("Port was changed, but config file was not written")); + t_s("Port was changed, but config file was not written")); } } else { WebSock.GetSession()->AddError(sMessage); @@ -1813,7 +1816,7 @@ class CWebAdminMod : public CModule { if (bIPv6) { eAddr = ADDR_IPV6ONLY; } else { - WebSock.GetSession()->AddError(t("Invalid request.")); + WebSock.GetSession()->AddError(t_s("Invalid request.")); return SettingsPage(WebSock, Tmpl); } } @@ -1823,11 +1826,11 @@ class CWebAdminMod : public CModule { CZNC::Get().DelListener(pListener); if (!CZNC::Get().WriteConfig()) { WebSock.GetSession()->AddError( - t("Port was changed, but config file was not written")); + t_s("Port was changed, but config file was not written")); } } else { WebSock.GetSession()->AddError( - t("The specified listener was not found.")); + t_s("The specified listener was not found.")); } return SettingsPage(WebSock, Tmpl); @@ -1837,7 +1840,7 @@ class CWebAdminMod : public CModule { Tmpl.SetFile("settings.tmpl"); if (!WebSock.GetParam("submitted").ToUInt()) { Tmpl["Action"] = "settings"; - Tmpl["Title"] = t("Global Settings"); + Tmpl["Title"] = t_s("Global Settings"); Tmpl["StatusPrefix"] = CZNC::Get().GetStatusPrefix(); Tmpl["MaxBufferSize"] = CString(CZNC::Get().GetMaxBufferSize()); Tmpl["ConnectDelay"] = CString(CZNC::Get().GetConnectDelay()); @@ -2019,14 +2022,15 @@ class CWebAdminMod : public CModule { if (!CZNC::Get().GetModules().LoadModule( sModName, sArgs, CModInfo::GlobalModule, nullptr, nullptr, sModRet)) { - sModLoadError = f("Unable to load module [{1}]: {2}")( + sModLoadError = t_f("Unable to load module [{1}]: {2}")( sModName, sModRet); } } else if (pMod->GetArgs() != sArgs) { if (!CZNC::Get().GetModules().ReloadModule( sModName, sArgs, nullptr, nullptr, sModRet)) { - sModLoadError = f("Unable to reload module [{1}]: {2}")( - sModName, sModRet); + sModLoadError = + t_f("Unable to reload module [{1}]: {2}")(sModName, + sModRet); } } @@ -2054,7 +2058,7 @@ class CWebAdminMod : public CModule { if (!CZNC::Get().WriteConfig()) { WebSock.GetSession()->AddError( - t("Settings were changed, but config file was not written")); + t_s("Settings were changed, but config file was not written")); } WebSock.Redirect(GetWebPath() + "settings"); diff --git a/src/ClientCommand.cpp b/src/ClientCommand.cpp index 5993bfdc..f1e7b0e9 100644 --- a/src/ClientCommand.cpp +++ b/src/ClientCommand.cpp @@ -47,27 +47,27 @@ void CClient::UserCommand(CString& sLine) { HelpUser(sLine.Token(1)); } else if (sCommand.Equals("LISTNICKS")) { if (!m_pNetwork) { - PutStatus( - t("You must be connected with a network to use this command")); + PutStatus(t_s( + "You must be connected with a network to use this command")); return; } CString sChan = sLine.Token(1); if (sChan.empty()) { - PutStatus(t("Usage: ListNicks <#chan>")); + PutStatus(t_s("Usage: ListNicks <#chan>")); return; } CChan* pChan = m_pNetwork->FindChan(sChan); if (!pChan) { - PutStatus(f("You are not on [{1}]")(sChan)); + PutStatus(t_f("You are not on [{1}]")(sChan)); return; } if (!pChan->IsOn()) { - PutStatus(f("You are not on [{1}] (trying)")(sChan)); + PutStatus(t_f("You are not on [{1}] (trying)")(sChan)); return; } @@ -76,7 +76,7 @@ void CClient::UserCommand(CString& sLine) { const CString& sPerms = (pIRCSock) ? pIRCSock->GetPerms() : ""; if (msNicks.empty()) { - PutStatus(f("No nicks on [{1}]")(sChan)); + PutStatus(t_f("No nicks on [{1}]")(sChan)); return; } diff --git a/src/Modules.cpp b/src/Modules.cpp index 46d899eb..0adfbd30 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -1995,28 +1995,28 @@ CString CModCommand::GetDescription() const { return m_bTranslating ? m_dDesc.Resolve() : m_sDesc; } -CString CModule::t(const CString& sEnglish, const CString& sContext) const { +CString CModule::t_s(const CString& sEnglish, const CString& sContext) const { return CTranslation::Get().Singular("znc-" + GetModName(), sContext, sEnglish); } -CInlineFormatMessage CModule::f(const CString& sEnglish, - const CString& sContext) const { - return CInlineFormatMessage(t(sEnglish, sContext)); +CInlineFormatMessage CModule::t_f(const CString& sEnglish, + const CString& sContext) const { + return CInlineFormatMessage(t_s(sEnglish, sContext)); } -CInlineFormatMessage CModule::p(const CString& sEnglish, - const CString& sEnglishes, int iNum, - const CString& sContext) const { +CInlineFormatMessage CModule::t_p(const CString& sEnglish, + const CString& sEnglishes, int iNum, + const CString& sContext) const { return CInlineFormatMessage(CTranslation::Get().Plural( "znc-" + GetModName(), sContext, sEnglish, sEnglishes, iNum)); } -CDelayedTranslation CModule::d(const CString& sEnglish, - const CString& sContext) const { +CDelayedTranslation CModule::t_d(const CString& sEnglish, + const CString& sContext) const { return CDelayedTranslation("znc-" + GetModName(), sContext, sEnglish); } -CString CModInfo::t(const CString& sEnglish, const CString& sContext) const { +CString CModInfo::t_s(const CString& sEnglish, const CString& sContext) const { return CTranslation::Get().Singular("znc-" + GetName(), sContext, sEnglish); } diff --git a/src/Socket.cpp b/src/Socket.cpp index cb5f8b21..dcf53b98 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -612,22 +612,22 @@ void CIRCSocket::IcuExtFromUCallback(UConverterFromUnicodeArgs* fromArgs, #endif -CString CSocket::t(const CString& sEnglish, const CString& sContext) const { - return GetModule()->t(sEnglish, sContext); +CString CSocket::t_s(const CString& sEnglish, const CString& sContext) const { + return GetModule()->t_s(sEnglish, sContext); } -CInlineFormatMessage CSocket::f(const CString& sEnglish, - const CString& sContext) const { - return GetModule()->f(sEnglish, sContext); +CInlineFormatMessage CSocket::t_f(const CString& sEnglish, + const CString& sContext) const { + return GetModule()->t_f(sEnglish, sContext); } -CInlineFormatMessage CSocket::p(const CString& sEnglish, - const CString& sEnglishes, int iNum, - const CString& sContext) const { - return GetModule()->p(sEnglish, sEnglishes, iNum, sContext); +CInlineFormatMessage CSocket::t_p(const CString& sEnglish, + const CString& sEnglishes, int iNum, + const CString& sContext) const { + return GetModule()->t_p(sEnglish, sEnglishes, iNum, sContext); } -CDelayedTranslation CSocket::d(const CString& sEnglish, - const CString& sContext) const { - return GetModule()->d(sEnglish, sContext); +CDelayedTranslation CSocket::t_d(const CString& sEnglish, + const CString& sContext) const { + return GetModule()->t_d(sEnglish, sContext); } diff --git a/src/Translation.cpp b/src/Translation.cpp index fa0c1223..dc097857 100644 --- a/src/Translation.cpp +++ b/src/Translation.cpp @@ -87,26 +87,26 @@ void CTranslation::DelReference(const CString& sDomain) { } } -CString CCoreTranslationMixin::t(const CString& sEnglish, - const CString& sContext) { +CString CCoreTranslationMixin::t_s(const CString& sEnglish, + const CString& sContext) { return CTranslation::Get().Singular("znc", sContext, sEnglish); } -CInlineFormatMessage CCoreTranslationMixin::f(const CString& sEnglish, - const CString& sContext) { - return CInlineFormatMessage(t(sEnglish, sContext)); +CInlineFormatMessage CCoreTranslationMixin::t_f(const CString& sEnglish, + const CString& sContext) { + return CInlineFormatMessage(t_s(sEnglish, sContext)); } -CInlineFormatMessage CCoreTranslationMixin::p(const CString& sEnglish, - const CString& sEnglishes, - int iNum, - const CString& sContext) { +CInlineFormatMessage CCoreTranslationMixin::t_p(const CString& sEnglish, + const CString& sEnglishes, + int iNum, + const CString& sContext) { return CInlineFormatMessage(CTranslation::Get().Plural( "znc", sContext, sEnglish, sEnglishes, iNum)); } -CDelayedTranslation CCoreTranslationMixin::d(const CString& sEnglish, - const CString& sContext) { +CDelayedTranslation CCoreTranslationMixin::t_d(const CString& sEnglish, + const CString& sContext) { return CDelayedTranslation("znc", sContext, sEnglish); } diff --git a/translation_pot.py b/translation_pot.py index 2ce95831..69a87aed 100755 --- a/translation_pot.py +++ b/translation_pot.py @@ -73,10 +73,10 @@ subprocess.check_call(['xgettext', '--omit-header', '-D', args.include_dir, '-o', main_pot, - '--keyword=t:1,1t', '--keyword=t:1,2c,2t', - '--keyword=f:1,1t', '--keyword=f:1,2c,2t', - '--keyword=p:1,2,3t', '--keyword=p:1,2,4c,4t', - '--keyword=d:1,1t', '--keyword=d:1,2c,2t', + '--keyword=t_s:1,1t', '--keyword=t_s:1,2c,2t', + '--keyword=t_f:1,1t', '--keyword=t_f:1,2c,2t', + '--keyword=t_p:1,2,3t', '--keyword=t_p:1,2,4c,4t', + '--keyword=t_d:1,1t', '--keyword=t_d:1,2c,2t', ] + args.explicit_sources) if os.path.isfile(main_pot): pot_list.append(main_pot)