From 9b609c1ccb0686cd7513b5da5949873090e53126 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 9 Jul 2026 21:01:38 +0100 Subject: [PATCH] Various improvements to the timezone list. - Correctly translate the time region message. - Squash time regions with only one zone like Antactica into Misc. - Make sure we use a comma in the zone list even at the end of a line. --- language/anope.en_US.po | 11 ++++++++-- modules/nickserv/ns_set_timezone.cpp | 31 +++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/language/anope.en_US.po b/language/anope.en_US.po index eeb9fcc5b..a8c1d3d05 100644 --- a/language/anope.en_US.po +++ b/language/anope.en_US.po @@ -16,8 +16,8 @@ msgid "" msgstr "" "Project-Id-Version: Anope\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-07-09 18:57+0100\n" -"PO-Revision-Date: 2026-07-09 18:57+0100\n" +"POT-Creation-Date: 2026-07-09 21:01+0100\n" +"PO-Revision-Date: 2026-07-09 21:02+0100\n" "Last-Translator: Sadie Powell \n" "Language-Team: English\n" "Language: en_US\n" @@ -1019,6 +1019,13 @@ msgstr "" msgid "user [reason]" msgstr "" +#: ../modules/nickserv/ns_set_timezone.cpp +#, c-format +msgid " %s (%zu timezone)" +msgid_plural " %s (%zu timezones)" +msgstr[0] "" +msgstr[1] "" + #: ../modules/operserv/os_oper.cpp #, c-format msgid " %s is online using this oper block." diff --git a/modules/nickserv/ns_set_timezone.cpp b/modules/nickserv/ns_set_timezone.cpp index e5ad1d9c2..f9516f16c 100644 --- a/modules/nickserv/ns_set_timezone.cpp +++ b/modules/nickserv/ns_set_timezone.cpp @@ -56,8 +56,10 @@ protected: buffer.clear(); } - buffer.append(buffer.empty() ? " " : ", "); - buffer.append(timezone); + buffer + .append(buffer.empty() ? " " : " ") + .append(timezone) + .append(","); } if (!buffer.empty()) @@ -156,7 +158,10 @@ public: )); for (const auto &[timeregion, timezone] : timeregions) - source.Reply(" %s (%zu timezones)", timeregion.c_str(), timezone.size()); + { + source.Reply(timezone.size(), N_(" %s (%zu timezone)", " %s (%zu timezones)"), + timeregion.c_str(), timezone.size()); + } source.Reply(_("Type \002%s\033\037region\037\002 to list timezones for a region."), source.service->GetQueryCommand("generic/help", source.command).c_str()); @@ -244,8 +249,24 @@ public: auto region = tzsep == Anope::string::npos ? "Misc" : timezone.substr(0, tzsep); timeregions[region].push_back(timezone); } - for (auto &[_, timeregion] : timeregions) - std::sort(timeregion.begin(), timeregion.end()); + + // Eliminate regions with only one timezone. + for (auto it = timeregions.begin(); it != timeregions.end(); ) + { + const auto &[timeregion, timezones] = *it; + if (!timeregion.equals_ci("Misc") && timezones.size() < 2) + { + auto& miscregion = timeregions["Misc"]; + miscregion.insert(miscregion.end(), timezones.begin(), timezones.end()); + it = timeregions.erase(it); + continue; + } + it++; + } + + // Ensure the timezone list is ordered alphabetically. + for (auto &[_, timezones] : timeregions) + std::sort(timezones.begin(), timezones.end()); #endif } };