1
0
mirror of https://github.com/anope/anope.git synced 2026-06-28 08:36:37 +02:00

Translate listformatter properly

This commit is contained in:
Adam
2013-09-22 11:25:11 -04:00
parent df3c0b7b52
commit 80c02740d0
30 changed files with 53 additions and 43 deletions
+2
View File
@@ -67,9 +67,11 @@ class CoreExport ListFormatter
public:
typedef std::map<Anope::string, Anope::string> ListEntry;
private:
NickCore *nc;
std::vector<Anope::string> columns;
std::vector<ListEntry> entries;
public:
ListFormatter(NickCore *nc);
ListFormatter &AddColumn(const Anope::string &name);
void AddEntry(const ListEntry &entry);
bool IsEmpty() const;
+1 -1
View File
@@ -187,7 +187,7 @@ class CommandBSBadwords : public Command
{
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST";
ListFormatter list;
ListFormatter list(source.GetAccount());
BadWords *bw = ci->GetExt<BadWords>("badwords");
list.AddColumn("Number").AddColumn("Word").AddColumn("Type");
+1 -1
View File
@@ -22,7 +22,7 @@ class CommandBSBotList : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
unsigned count = 0;
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Nick").AddColumn("Mask");
+4 -4
View File
@@ -425,7 +425,7 @@ class CommandCSAccess : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Level").AddColumn("Mask");
this->ProcessList(source, ci, params, list);
}
@@ -438,7 +438,7 @@ class CommandCSAccess : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Level").AddColumn("Mask").AddColumn("By").AddColumn("Last seen");
this->ProcessList(source, ci, params, list);
}
@@ -660,7 +660,7 @@ class CommandCSLevels : public Command
{
source.Reply(_("Access level settings for channel %s:"), ci->name.c_str());
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Name").AddColumn("Level");
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
@@ -754,7 +754,7 @@ class CommandCSLevels : public Command
{
source.Reply(_("The following feature/function names are available:"));
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Name").AddColumn("Description");
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
+2 -2
View File
@@ -360,7 +360,7 @@ class CommandCSAKick : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
this->ProcessList(source, ci, params, list);
}
@@ -373,7 +373,7 @@ class CommandCSAKick : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("Creator").AddColumn("Created").AddColumn("Last used").AddColumn("Reason");
this->ProcessList(source, ci, params, list);
}
+1 -1
View File
@@ -109,7 +109,7 @@ class CommandEntryMessage : public Command
source.Reply(_("Entry message list for \002%s\002:"), ci->name.c_str());
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Creator").AddColumn("Created").AddColumn("Message");
for (unsigned i = 0; i < (*messages)->size(); ++i)
{
+1 -1
View File
@@ -267,7 +267,7 @@ class CommandCSFlags : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("Flags").AddColumn("Creator").AddColumn("Created");
+1 -1
View File
@@ -70,7 +70,7 @@ class CommandCSList : public Command
source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str());
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Name").AddColumn("Description");
Anope::map<ChannelInfo *> ordered_map;
+1 -1
View File
@@ -123,7 +123,7 @@ public:
source.Reply(_("There currently are no logging configurations for %s."), ci->name.c_str());
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Service").AddColumn("Command").AddColumn("Method").AddColumn("");
for (unsigned i = 0; i < (*ls)->size(); ++i)
+1 -1
View File
@@ -422,7 +422,7 @@ class CommandCSMode : public Command
}
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Mode").AddColumn("Param").AddColumn("Creator").AddColumn("Created");
for (ModeLocks::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it)
+1 -1
View File
@@ -378,7 +378,7 @@ class CommandCSXOP : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask");
if (!nick.empty() && nick.find_first_not_of("1234567890,-") == Anope::string::npos)
+1 -1
View File
@@ -54,7 +54,7 @@ class CommandHSList : public Command
}
unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get<unsigned>("listmax", "50");
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Creator").AddColumn("Created");
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
+1 -1
View File
@@ -295,7 +295,7 @@ class CommandHSWaiting : public Command
{
unsigned counter = 0;
unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get<unsigned>("listmax");
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Created");
+1 -1
View File
@@ -76,7 +76,7 @@ class CommandMSIgnore : public Command
source.Reply(_("Memo ignore list is empty."));
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Mask");
for (unsigned i = 0; i < mi->ignores.size(); ++i)
{
+1 -1
View File
@@ -59,7 +59,7 @@ class CommandMSList : public Command
}
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Sender").AddColumn("Date/Time");
+1 -1
View File
@@ -96,7 +96,7 @@ class CommandNSAJoin : public Command
source.Reply(_("%s's auto join list is empty."), nc->display.c_str());
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Channel").AddColumn("Key");
for (unsigned i = 0; i < (*channels)->size(); ++i)
{
+1 -1
View File
@@ -42,7 +42,7 @@ class CommandNSAList : public Command
nc = na->nc;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
int chan_count = 0;
list.AddColumn("Number").AddColumn("Channel").AddColumn("Access");
+2 -2
View File
@@ -150,7 +150,7 @@ class CommandNSCert : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Certificate");
for (unsigned i = 0; i < cl->GetCertCount(); ++i)
@@ -240,7 +240,7 @@ class CommandNSCert : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Certificate");
for (unsigned i = 0; i < cl->GetCertCount(); ++i)
+1 -1
View File
@@ -295,7 +295,7 @@ class CommandNSGList : public Command
else
nc = source.GetAccount();
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Nick").AddColumn("Expires");
time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire");
for (unsigned i = 0; i < nc->aliases->size(); ++i)
+1 -1
View File
@@ -70,7 +70,7 @@ class CommandNSList : public Command
}
mync = source.nc;
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Nick").AddColumn("Last usermask");
+2 -2
View File
@@ -327,7 +327,7 @@ class CommandOSAKill : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
this->ProcessList(source, params, list);
@@ -341,7 +341,7 @@ class CommandOSAKill : public Command
return;
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("Creator").AddColumn("Created").AddColumn("Expires").AddColumn("Reason");
this->ProcessList(source, params, list);
+1 -1
View File
@@ -53,7 +53,7 @@ class CommandOSConfig : public Command
if (!items)
continue;
ListFormatter lflist;
ListFormatter lflist(source.GetAccount());
lflist.AddColumn("Name").AddColumn("Value");
for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it)
+2 -2
View File
@@ -213,7 +213,7 @@ class CommandOSDNS : public Command
return;
}
ListFormatter lf;
ListFormatter lf(source.GetAccount());
lf.AddColumn("Server").AddColumn("IP").AddColumn("Limit").AddColumn("State");
for (unsigned i = 0; i < dns_servers->size(); ++i)
{
@@ -249,7 +249,7 @@ class CommandOSDNS : public Command
if (!zones->empty())
{
ListFormatter lf2;
ListFormatter lf2(source.GetAccount());
lf2.AddColumn("Zone").AddColumn("Servers");
for (unsigned i = 0; i < zones->size(); ++i)
+1 -1
View File
@@ -289,7 +289,7 @@ class CommandOSForbid : public Command
source.Reply(_("Forbid list is empty."));
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Mask").AddColumn("Type").AddColumn("Reason");
for (unsigned i = 0; i < forbids.size(); ++i)
+1 -1
View File
@@ -208,7 +208,7 @@ class CommandOSIgnore : public Command
source.Reply(_("Ignore list is empty."));
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Mask").AddColumn("Creator").AddColumn("Reason").AddColumn("Expires");
for (std::list<IgnoreData>::const_iterator ign = ignores.begin(), ign_end = ignores.end(); ign != ign_end; ++ign)
{
+2 -2
View File
@@ -38,7 +38,7 @@ class CommandOSChanList : public Command
modes.insert("PRIVATE");
}
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Name").AddColumn("Users").AddColumn("Modes").AddColumn("Topic");
if (!pattern.empty() && (u2 = User::Find(pattern, true)))
@@ -143,7 +143,7 @@ class CommandOSUserList : public Command
if (!opt.empty() && opt.equals_ci("INVISIBLE"))
modes.insert("INVIS");
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Name").AddColumn("Mask");
if (!pattern.empty() && (c = Channel::Find(pattern)))
+1 -1
View File
@@ -113,7 +113,7 @@ class NewsBase : public Command
source.Reply(msgs[MSG_LIST_NONE]);
else
{
ListFormatter lflist;
ListFormatter lflist(source.GetAccount());
lflist.AddColumn("Number").AddColumn("Creator").AddColumn("Created").AddColumn("Text");
for (unsigned i = 0, end = list.size(); i < end; ++i)
+3 -3
View File
@@ -181,7 +181,7 @@ class CommandOSSession : public Command
source.Reply(_("Invalid threshold value. It must be a valid integer greater than 1."));
else
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Session").AddColumn("Host");
for (SessionService::SessionMap::iterator it = session_service->GetSessions().begin(), it_end = session_service->GetSessions().end(); it != it_end; ++it)
@@ -527,7 +527,7 @@ class CommandOSException : public Command
void DoList(CommandSource &source, const std::vector<Anope::string> &params)
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Limit").AddColumn("Mask");
this->ProcessList(source, params, list);
@@ -535,7 +535,7 @@ class CommandOSException : public Command
void DoView(CommandSource &source, const std::vector<Anope::string> &params)
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Limit").AddColumn("Reason");
this->ProcessList(source, params, list);
+2 -2
View File
@@ -183,7 +183,7 @@ class CommandOSSXLineBase : public Command
void OnList(CommandSource &source, const std::vector<Anope::string> &params)
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
this->ProcessList(source, params, list);
@@ -191,7 +191,7 @@ class CommandOSSXLineBase : public Command
void OnView(CommandSource &source, const std::vector<Anope::string> &params)
{
ListFormatter list;
ListFormatter list(source.GetAccount());
list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Expires").AddColumn("Reason");
this->ProcessList(source, params, list);
}
+12 -4
View File
@@ -121,6 +121,10 @@ bool NumberList::InvalidRange(const Anope::string &)
return true;
}
ListFormatter::ListFormatter(NickCore *acc) : nc(acc)
{
}
ListFormatter &ListFormatter::AddColumn(const Anope::string &name)
{
this->columns.push_back(name);
@@ -139,10 +143,14 @@ bool ListFormatter::IsEmpty() const
void ListFormatter::Process(std::vector<Anope::string> &buffer)
{
std::vector<Anope::string> tcolumns;
std::map<Anope::string, size_t> lenghts;
std::set<Anope::string> breaks;
for (unsigned i = 0; i < this->columns.size(); ++i)
lenghts[this->columns[i]] = this->columns[i].length();
{
tcolumns.push_back(Language::Translate(this->nc, this->columns[i].c_str()));
lenghts[this->columns[i]] = tcolumns[i].length();
}
for (unsigned i = 0; i < this->entries.size(); ++i)
{
ListEntry &e = this->entries[i];
@@ -176,9 +184,9 @@ void ListFormatter::Process(std::vector<Anope::string> &buffer)
}
else if (!s.empty())
s += " ";
s += this->columns[i];
if (i + 1 != this->columns.size())
for (unsigned j = this->columns[i].length(); j < lenghts[this->columns[i]]; ++j)
s += tcolumns[i];
if (i + 1 != this->columns.size())
for (unsigned j = tcolumns[i].length(); j < lenghts[this->columns[i]]; ++j)
s += " ";
}
buffer.push_back(s);