From 408e6e9f01b42897b306416b665d822a8f56945c Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Wed, 6 Sep 2017 00:01:37 +0100 Subject: [PATCH] More translateable strings, #1354 --- modules/keepnick.cpp | 36 +++++++++++++++++------------------- modules/kickrejoin.cpp | 32 +++++++++++++++----------------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/modules/keepnick.cpp b/modules/keepnick.cpp index 7f0891a0..a5885dfd 100644 --- a/modules/keepnick.cpp +++ b/modules/keepnick.cpp @@ -36,15 +36,13 @@ class CKeepNickMod : public CModule { public: MODCONSTRUCTOR(CKeepNickMod) { AddHelpCommand(); - AddCommand("Enable", static_cast( - &CKeepNickMod::OnEnableCommand), - "", "Try to get your primary nick"); - AddCommand("Disable", static_cast( - &CKeepNickMod::OnDisableCommand), - "", "No longer trying to get your primary nick"); - AddCommand("State", static_cast( - &CKeepNickMod::OnStateCommand), - "", "Show the current state"); + AddCommand("Enable", "", t_d("Try to get your primary nick"), + [=](const CString& sLine) { OnEnableCommand(sLine); }); + AddCommand("Disable", "", + t_d("No longer trying to get your primary nick"), + [=](const CString& sLine) { OnDisableCommand(sLine); }); + AddCommand("State", "", t_d("Show the current state"), + [=](const CString& sLine) { OnStateCommand(sLine); }); } ~CKeepNickMod() override {} @@ -158,8 +156,8 @@ class CKeepNickMod : public CModule { // Indeed trying to change to this nick, generate a 433 for it. // This way we can *always* block incoming 433s from the server. PutUser(":" + GetNetwork()->GetIRCServer() + " 433 " + - GetNetwork()->GetIRCNick().GetNick() + " " + sNick + - " :ZNC is already trying to get this nickname"); + GetNetwork()->GetIRCNick().GetNick() + " " + sNick + " :" + + t_s("ZNC is already trying to get this nickname")); return CONTINUE; } @@ -174,15 +172,15 @@ class CKeepNickMod : public CModule { // :leguin.freenode.net 435 mynick badnick #chan :Cannot change nickname while banned on channel // clang-format on if (msg.GetCode() == 435) { - PutModule("Unable to obtain nick " + msg.GetParam(1) + ": " + - msg.GetParam(3) + ", " + msg.GetParam(2)); + PutModule(t_f("Unable to obtain nick {1}: {2}, {3}")( + msg.GetParam(1), msg.GetParam(3), msg.GetParam(2))); Disable(); } // clang-format off // :irc1.unrealircd.org 447 mynick :Can not change nickname while on #chan (+N) // clang-format on if (msg.GetCode() == 447) { - PutModule("Unable to obtain nick: " + msg.GetParam(1)); + PutModule(t_f("Unable to obtain nick {1}")(msg.GetParam(1))); Disable(); } } @@ -192,19 +190,19 @@ class CKeepNickMod : public CModule { void OnEnableCommand(const CString& sCommand) { Enable(); - PutModule("Trying to get your primary nick"); + PutModule(t_s("Trying to get your primary nick")); } void OnDisableCommand(const CString& sCommand) { Disable(); - PutModule("No longer trying to get your primary nick"); + PutModule(t_s("No longer trying to get your primary nick")); } void OnStateCommand(const CString& sCommand) { if (m_pTimer) - PutModule("Currently trying to get your primary nick"); + PutModule(t_s("Currently trying to get your primary nick")); else - PutModule("Currently disabled, try 'enable'"); + PutModule(t_s("Currently disabled, try 'enable'")); } private: @@ -225,4 +223,4 @@ void TModInfo(CModInfo& Info) { Info.SetWikiPage("keepnick"); } -NETWORKMODULEDEFS(CKeepNickMod, "Keep trying for your primary nick") +NETWORKMODULEDEFS(CKeepNickMod, t_s("Keeps trying for your primary nick")) diff --git a/modules/kickrejoin.cpp b/modules/kickrejoin.cpp index eb17e943..baec6aa4 100644 --- a/modules/kickrejoin.cpp +++ b/modules/kickrejoin.cpp @@ -53,12 +53,10 @@ class CRejoinMod : public CModule { public: MODCONSTRUCTOR(CRejoinMod) { AddHelpCommand(); - AddCommand("SetDelay", static_cast( - &CRejoinMod::OnSetDelayCommand), - "", "Set the rejoin delay"); - AddCommand("ShowDelay", static_cast( - &CRejoinMod::OnShowDelayCommand), - "", "Show the rejoin delay"); + AddCommand("SetDelay", t_d(""), t_d("Set the rejoin delay"), + [=](const CString& sLine) { OnSetDelayCommand(sLine); }); + AddCommand("ShowDelay", "", t_d("Show the rejoin delay"), + [=](const CString& sLine) { OnShowDelayCommand(sLine); }); } ~CRejoinMod() override {} @@ -75,9 +73,7 @@ class CRejoinMod : public CModule { if ((i == 0 && sArgs == "0") || i > 0) delay = i; else { - sErrorMsg = - "Illegal argument, " - "must be a positive number or 0"; + sErrorMsg = "Illegal argument, must be a positive number or 0"; return false; } } @@ -90,7 +86,7 @@ class CRejoinMod : public CModule { i = sCommand.Token(1).ToInt(); if (i < 0) { - PutModule("Negative delays don't make any sense!"); + PutModule(t_s("Negative delays don't make any sense!")); return; } @@ -98,16 +94,18 @@ class CRejoinMod : public CModule { SetNV("delay", CString(delay)); if (delay) - PutModule("Rejoin delay set to " + CString(delay) + " seconds"); + PutModule(t_p("Rejoin delay set to 1 second", + "Rejoin delay set to {1} seconds", delay)(delay)); else - PutModule("Rejoin delay disabled"); + PutModule(t_s("Rejoin delay disabled")); } void OnShowDelayCommand(const CString& sCommand) { if (delay) - PutModule("Rejoin delay enabled, " + CString(delay) + " seconds"); + PutModule(t_p("Rejoin delay is set to 1 second", + "Rejoin delay is set to {1} seconds", delay)(delay)); else - PutModule("Rejoin delay disabled"); + PutModule(t_s("Rejoin delay is disabled")); } void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& pChan, @@ -128,8 +126,8 @@ template <> void TModInfo(CModInfo& Info) { Info.SetWikiPage("kickrejoin"); Info.SetHasArgs(true); - Info.SetArgsHelpText( - "You might enter the number of seconds to wait before rejoining."); + Info.SetArgsHelpText(Info.t_s( + "You might enter the number of seconds to wait before rejoining.")); } -NETWORKMODULEDEFS(CRejoinMod, "Autorejoin on kick") +NETWORKMODULEDEFS(CRejoinMod, t_s("Autorejoins on kick"))