diff options
author | Adam <Adam@anope.org> | 2013-09-22 11:25:11 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-09-27 19:11:02 -0400 |
commit | 80c02740d0a99df96fa40e3f3d5bad4ea2e0e2ae (patch) | |
tree | fac80bb223506909a6e90d237e85ae048e1494a0 | |
parent | df3c0b7b52066698a97b34edf5352cf344e991ac (diff) |
Translate listformatter properly
30 files changed, 53 insertions, 43 deletions
diff --git a/include/lists.h b/include/lists.h index 37b3d61a8..271c1d7d1 100644 --- a/include/lists.h +++ b/include/lists.h @@ -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; diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index b64ed9b59..b654ae12f 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -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"); diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index 2714c3fdc..b45f8bda7 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -22,7 +22,7 @@ class CommandBSBotList : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { unsigned count = 0; - ListFormatter list; + ListFormatter list(source.GetAccount()); list.AddColumn("Nick").AddColumn("Mask"); diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index b0419e1e2..414704722 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -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(); diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 7bfed5419..06ddc406e 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -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); } diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index fd9da0db8..1aeadaac8 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -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) { diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index cc0f6798f..984c0089c 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -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"); diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 6fd20d05f..661c54ac6 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -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; diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index e9fc3916e..643fa152e 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -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) diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index e4ca072aa..c40678a5f 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -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) diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index cd08a33a9..0b404ea6a 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -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) diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index 2eec6d17c..e0b2b8834 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -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) diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 9f6f6d3e0..36e12505d 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -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"); diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index 0194079fe..fd4f56e4a 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -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) { diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index 036b5b382..16db11ddb 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -59,7 +59,7 @@ class CommandMSList : public Command } else { - ListFormatter list; + ListFormatter list(source.GetAccount()); list.AddColumn("Number").AddColumn("Sender").AddColumn("Date/Time"); diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index c365133a5..73374c714 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -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) { diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index d9e91af52..5035bfa1a 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -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"); diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index 71d99426e..2c623ce5b 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -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) diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index 9fa8e4998..2f49eb7ac 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -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) diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index 058ae91b4..66ff914e9 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -70,7 +70,7 @@ class CommandNSList : public Command } mync = source.nc; - ListFormatter list; + ListFormatter list(source.GetAccount()); list.AddColumn("Nick").AddColumn("Last usermask"); diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index ef783c8af..87d59379f 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -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); diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index 91987ef80..f3f618f09 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -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) diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index ee651f702..4d31aeb5a 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -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) diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 1cec143e9..6854a4e27 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -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) diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index 3bd909c49..d3c60679d 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -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) { diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index e0f8b4645..d73d08eed 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -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))) diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index ddfc3c3f9..61f48ff59 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -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) diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 3f1a0c26c..a9c285601 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -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> ¶ms) { - 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> ¶ms) { - ListFormatter list; + ListFormatter list(source.GetAccount()); list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Limit").AddColumn("Reason"); this->ProcessList(source, params, list); diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index 62f81d337..b7e3cfcc3 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -183,7 +183,7 @@ class CommandOSSXLineBase : public Command void OnList(CommandSource &source, const std::vector<Anope::string> ¶ms) { - 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> ¶ms) { - ListFormatter list; + ListFormatter list(source.GetAccount()); list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Expires").AddColumn("Reason"); this->ProcessList(source, params, list); } diff --git a/src/misc.cpp b/src/misc.cpp index fe0c49158..8e202aca6 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -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); |