1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 05:56:38 +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
+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);