mirror of
https://github.com/znc/znc.git
synced 2026-07-04 17:01:23 +02:00
Make it possible to translate arguments in help text of module commands
Ref #1354
This commit is contained in:
@@ -352,7 +352,8 @@ class CModCommand {
|
||||
*/
|
||||
CModCommand(const CString& sCmd, CModule* pMod, ModCmdFunc func,
|
||||
const CString& sArgs, const CString& sDesc);
|
||||
CModCommand(const CString& sCmd, CmdFunc func, const CString& sArgs,
|
||||
CModCommand(const CString& sCmd, CmdFunc func,
|
||||
const COptionalTranslation& Args,
|
||||
const COptionalTranslation& Desc);
|
||||
|
||||
/** Copy constructor, needed so that this can be saved in a std::map.
|
||||
@@ -378,7 +379,7 @@ class CModCommand {
|
||||
|
||||
const CString& GetCommand() const { return m_sCmd; }
|
||||
CmdFunc GetFunction() const { return m_pFunc; }
|
||||
const CString& GetArgs() const { return m_sArgs; }
|
||||
CString GetArgs() const { return m_Args.Resolve(); }
|
||||
CString GetDescription() const { return m_Desc.Resolve(); }
|
||||
|
||||
void Call(const CString& sLine) const { m_pFunc(sLine); }
|
||||
@@ -386,7 +387,7 @@ class CModCommand {
|
||||
private:
|
||||
CString m_sCmd;
|
||||
CmdFunc m_pFunc;
|
||||
CString m_sArgs;
|
||||
COptionalTranslation m_Args;
|
||||
COptionalTranslation m_Desc;
|
||||
};
|
||||
|
||||
@@ -1150,8 +1151,8 @@ class CModule {
|
||||
const CString& sArgs = "", const CString& sDesc = "");
|
||||
/// @param dDesc Either a string "", or the result of t_d()
|
||||
/// @return True if the command was successfully added.
|
||||
bool AddCommand(const CString& sCmd, const CString& sArgs,
|
||||
const COptionalTranslation& dDesc,
|
||||
bool AddCommand(const CString& sCmd, const COptionalTranslation& Args,
|
||||
const COptionalTranslation& Desc,
|
||||
std::function<void(const CString& sLine)> func);
|
||||
/// @return True if the command was successfully removed.
|
||||
bool RemCommand(const CString& sCmd);
|
||||
|
||||
@@ -28,7 +28,7 @@ class CAdminLogMod : public CModule {
|
||||
AddHelpCommand();
|
||||
AddCommand("Show", "", t_d("Show the logging target"),
|
||||
[=](const CString& sLine) { OnShowCommand(sLine); });
|
||||
AddCommand("Target", "<file|syslog|both> [path]",
|
||||
AddCommand("Target", t_d("<file|syslog|both> [path]"),
|
||||
t_d("Set the logging target"),
|
||||
[=](const CString& sLine) { OnTargetCommand(sLine); });
|
||||
openlog("znc", LOG_PID, LOG_DAEMON);
|
||||
|
||||
+7
-7
@@ -335,26 +335,26 @@ class CAliasMod : public CModule {
|
||||
|
||||
MODCONSTRUCTOR(CAliasMod), sending_lines(false) {
|
||||
AddHelpCommand();
|
||||
AddCommand("Create", "<name>",
|
||||
AddCommand("Create", t_d("<name>"),
|
||||
t_d("Creates a new, blank alias called name."),
|
||||
[=](const CString& sLine) { CreateCommand(sLine); });
|
||||
AddCommand("Delete", "<name>", t_d("Deletes an existing alias."),
|
||||
AddCommand("Delete", t_d("<name>"), t_d("Deletes an existing alias."),
|
||||
[=](const CString& sLine) { DeleteCommand(sLine); });
|
||||
AddCommand("Add", "<name> <action ...>",
|
||||
AddCommand("Add", t_d("<name> <action ...>"),
|
||||
t_d("Adds a line to an existing alias."),
|
||||
[=](const CString& sLine) { AddCmd(sLine); });
|
||||
AddCommand("Insert", "<name> <pos> <action ...>",
|
||||
AddCommand("Insert", t_d("<name> <pos> <action ...>"),
|
||||
t_d("Inserts a line into an existing alias."),
|
||||
[=](const CString& sLine) { InsertCommand(sLine); });
|
||||
AddCommand("Remove", "<name> <pos>",
|
||||
AddCommand("Remove", t_d("<name> <pos>"),
|
||||
t_d("Removes a line from an existing alias."),
|
||||
[=](const CString& sLine) { RemoveCommand(sLine); });
|
||||
AddCommand("Clear", "<name>",
|
||||
AddCommand("Clear", t_d("<name>"),
|
||||
t_d("Removes all lines from an existing alias."),
|
||||
[=](const CString& sLine) { ClearCommand(sLine); });
|
||||
AddCommand("List", "", t_d("Lists all aliases by name."),
|
||||
[=](const CString& sLine) { ListCommand(sLine); });
|
||||
AddCommand("Info", "<name>",
|
||||
AddCommand("Info", t_d("<name>"),
|
||||
t_d("Reports the actions performed by an alias."),
|
||||
[=](const CString& sLine) { InfoCommand(sLine); });
|
||||
AddCommand(
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
msgid "Show the logging target"
|
||||
msgstr ""
|
||||
|
||||
#: adminlog.cpp:31
|
||||
msgid "<file|syslog|both> [path]"
|
||||
msgstr ""
|
||||
|
||||
#: adminlog.cpp:32
|
||||
msgid "Set the logging target"
|
||||
msgstr ""
|
||||
|
||||
+26
-10
@@ -15,7 +15,7 @@ msgid "Deleted alias: {1}"
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:213 alias.cpp:224 alias.cpp:246 alias.cpp:265 alias.cpp:276
|
||||
#: alias.cpp:332
|
||||
#: alias.cpp:333
|
||||
msgid "Alias does not exist."
|
||||
msgstr ""
|
||||
|
||||
@@ -44,50 +44,66 @@ msgstr ""
|
||||
msgid "Actions for alias {1}:"
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:330
|
||||
#: alias.cpp:331
|
||||
msgid "End of actions for alias {1}."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:338
|
||||
#: alias.cpp:338 alias.cpp:341 alias.cpp:352 alias.cpp:357
|
||||
msgid "<name>"
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:339
|
||||
msgid "Creates a new, blank alias called name."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:340
|
||||
#: alias.cpp:341
|
||||
msgid "Deletes an existing alias."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:343
|
||||
msgid "<name> <action ...>"
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:344
|
||||
msgid "Adds a line to an existing alias."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:346
|
||||
msgid "<name> <pos> <action ...>"
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:347
|
||||
msgid "Inserts a line into an existing alias."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:349
|
||||
msgid "<name> <pos>"
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:350
|
||||
msgid "Removes a line from an existing alias."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:352
|
||||
#: alias.cpp:353
|
||||
msgid "Removes all lines from an existing alias."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:354
|
||||
#: alias.cpp:355
|
||||
msgid "Lists all aliases by name."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:357
|
||||
#: alias.cpp:358
|
||||
msgid "Reports the actions performed by an alias."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:361
|
||||
#: alias.cpp:362
|
||||
msgid "Generate a list of commands to copy your alias config."
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:373
|
||||
#: alias.cpp:374
|
||||
msgid "Clearing all of them!"
|
||||
msgstr ""
|
||||
|
||||
#: alias.cpp:408
|
||||
#: alias.cpp:409
|
||||
msgid "Provides bouncer-side command alias support."
|
||||
msgstr ""
|
||||
|
||||
+7
-6
@@ -517,10 +517,10 @@ bool CModule::AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func,
|
||||
return AddCommand(cmd);
|
||||
}
|
||||
|
||||
bool CModule::AddCommand(const CString& sCmd, const CString& sArgs,
|
||||
bool CModule::AddCommand(const CString& sCmd, const COptionalTranslation& Args,
|
||||
const COptionalTranslation& Desc,
|
||||
std::function<void(const CString& sLine)> func) {
|
||||
CModCommand cmd(sCmd, std::move(func), sArgs, Desc);
|
||||
CModCommand cmd(sCmd, std::move(func), Args, Desc);
|
||||
return AddCommand(std::move(cmd));
|
||||
}
|
||||
|
||||
@@ -1958,18 +1958,19 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
|
||||
}
|
||||
|
||||
CModCommand::CModCommand()
|
||||
: m_sCmd(), m_pFunc(nullptr), m_sArgs(), m_Desc("") {}
|
||||
: m_sCmd(), m_pFunc(nullptr), m_Args(""), m_Desc("") {}
|
||||
|
||||
CModCommand::CModCommand(const CString& sCmd, CModule* pMod, ModCmdFunc func,
|
||||
const CString& sArgs, const CString& sDesc)
|
||||
: m_sCmd(sCmd),
|
||||
m_pFunc([pMod, func](const CString& sLine) { (pMod->*func)(sLine); }),
|
||||
m_sArgs(sArgs),
|
||||
m_Args(sArgs),
|
||||
m_Desc(sDesc) {}
|
||||
|
||||
CModCommand::CModCommand(const CString& sCmd, CmdFunc func,
|
||||
const CString& sArgs, const COptionalTranslation& Desc)
|
||||
: m_sCmd(sCmd), m_pFunc(std::move(func)), m_sArgs(sArgs), m_Desc(Desc) {}
|
||||
const COptionalTranslation& Args,
|
||||
const COptionalTranslation& Desc)
|
||||
: m_sCmd(sCmd), m_pFunc(std::move(func)), m_Args(Args), m_Desc(Desc) {}
|
||||
|
||||
void CModCommand::InitHelp(CTable& Table) {
|
||||
Table.AddColumn("Command");
|
||||
|
||||
Reference in New Issue
Block a user