diff options
author | DukePyrolator <DukePyrolator@anope.org> | 2011-06-13 18:20:22 +0200 |
---|---|---|
committer | DukePyrolator <DukePyrolator@anope.org> | 2011-06-13 18:20:22 +0200 |
commit | 1cd65878dbdae1d64f70522c3586897a9a7adc36 (patch) | |
tree | 30aefc309b0e06b254993a39760abe377bf7bfa7 /src | |
parent | 6148ffa66932e1d85a5f9a90298624da583ce5ed (diff) |
changed some _() to gtl() and updated do_strftime() and duration()
Diffstat (limited to 'src')
-rw-r--r-- | src/botserv.cpp | 6 | ||||
-rw-r--r-- | src/language.cpp | 2 | ||||
-rw-r--r-- | src/misc.cpp | 45 | ||||
-rw-r--r-- | src/regchannel.cpp | 4 |
4 files changed, 28 insertions, 29 deletions
diff --git a/src/botserv.cpp b/src/botserv.cpp index 45d30b395..48b355f24 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -51,7 +51,7 @@ void bot_raw_ban(User *requester, ChannelInfo *ci, User *u, const Anope::string if (ModeManager::FindUserModeByName(UMODE_PROTECTED) && u->IsProtected() && requester != u) { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", GetString(requester->Account(), _(ACCESS_DENIED)).c_str()); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", GetString(requester->Account(), ACCESS_DENIED).c_str()); return; } @@ -62,7 +62,7 @@ void bot_raw_ban(User *requester, ChannelInfo *ci, User *u, const Anope::string if (matches_list(ci->c, u, CMODE_EXCEPT)) { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", GetString(requester->Account(), _("User matches channel except.")).c_str()); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", GetString(requester->Account(), gtl("User matches channel except.")).c_str()); return; } @@ -93,7 +93,7 @@ void bot_raw_kick(User *requester, ChannelInfo *ci, User *u, const Anope::string if (ModeManager::FindUserModeByName(UMODE_PROTECTED) && u->IsProtected() && requester != u) { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", GetString(requester->Account(), _(ACCESS_DENIED)).c_str()); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", GetString(requester->Account(), ACCESS_DENIED).c_str()); return; } diff --git a/src/language.cpp b/src/language.cpp index 250415e9f..4f235ac9a 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -36,7 +36,7 @@ void InitLanguages() const Anope::string GetString(NickCore *nc, const char *string) { - return GetString("anope", nc ? nc->language : "", string); + return GetString("anope", nc ? Config->NSDefLanguage : "", string); } const Anope::string GetString(const Anope::string &domain, const Anope::string &lang, const char *string) diff --git a/src/misc.cpp b/src/misc.cpp index 966af359e..897335b00 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -203,52 +203,51 @@ time_t dotime(const Anope::string &s) * @param seconds time in seconds * @return buffer */ -Anope::string duration(time_t seconds) +Anope::string duration(const time_t &t, NickCore *nc) { /* We first calculate everything */ - time_t days = seconds / 86400; - seconds -= (days * 86400); - time_t hours = seconds / 3600; - seconds -= (hours * 3600); - time_t minutes = seconds / 60; - - Anope::string buffer; + time_t days = (t / 86400); + time_t hours = (t / 3600) % 24; + time_t minutes = (t / 60) % 60; + time_t seconds = (t) % 60; if (!days && !hours && !minutes) - buffer = stringify(seconds) + " second" + (seconds != 1 ? "s" : ""); + return stringify(seconds) + " " + (seconds != 1 ? GetString(nc, gtl("seconds")) : GetString(nc, gtl("second"))); else { bool need_comma = false; + Anope::string buffer; if (days) { - buffer = stringify(days) + " day" + (days != 1 ? "s" : ""); + buffer = stringify(days) + " " + (days != 1 ? GetString(nc, gtl("days")) : GetString(nc, gtl("day"))); need_comma = true; } if (hours) { buffer += need_comma ? ", " : ""; - buffer += stringify(hours) + " hour" + (hours != 1 ? "s" : ""); + buffer += stringify(hours) + " " + (hours != 1 ? GetString(nc, gtl("hours")) : GetString(nc, gtl("hour"))); need_comma = true; } if (minutes) { buffer += need_comma ? ", " : ""; - buffer += stringify(minutes) + " minute" + (minutes != 1 ? "s" : ""); + buffer += stringify(minutes) + " " + (minutes != 1 ? GetString(nc, gtl("minutes")) : GetString(nc, gtl("minute"))); } + return buffer; } - - return buffer; } -Anope::string do_strftime(const time_t &t) +Anope::string do_strftime(const time_t &t, NickCore *nc, bool short_output) { tm tm = *localtime(&t); char buf[BUFSIZE]; - strftime(buf, sizeof(buf), "%b %d %H:%M:%S %Y %Z", &tm); + strftime(buf, sizeof(buf), GetString(nc, gtl("%b %d %H:%M:%S %Y %Z")).c_str(), &tm); + if (short_output) + return buf; if (t < Anope::CurTime) - return Anope::string(buf) + " (" + duration(Anope::CurTime - t) + " ago)"; + return Anope::string(buf) + " " + Anope::printf(GetString(nc, gtl("(%s ago)")).c_str(), duration(Anope::CurTime - t).c_str(), nc); else - return Anope::string(buf) + " (" + duration(t - Anope::CurTime) + " from now)"; + return Anope::string(buf) + " " + Anope::printf(GetString(nc, gtl("(%s from now)")).c_str(), duration(t - Anope::CurTime).c_str(), nc); } /*************************************************************************/ @@ -262,9 +261,9 @@ Anope::string do_strftime(const time_t &t) Anope::string expire_left(NickCore *nc, time_t expires) { if (!expires) - return GetString(nc, _(NO_EXPIRE)); + return GetString(nc, gtl(NO_EXPIRE)); else if (expires <= Anope::CurTime) - return GetString(nc, _("expires at next database update")); + return GetString(nc, gtl("expires at next database update")); else { char buf[256]; @@ -273,21 +272,21 @@ Anope::string expire_left(NickCore *nc, time_t expires) if (diff >= 86400) { int days = diff / 86400; - snprintf(buf, sizeof(buf), GetString(nc, days == 1 ? _("expires in %d day") : _("expires in %d days")).c_str(), days); + snprintf(buf, sizeof(buf), GetString(nc, days == 1 ? gtl("expires in %d day") : gtl("expires in %d days")).c_str(), days); } else { if (diff <= 3600) { int minutes = diff / 60; - snprintf(buf, sizeof(buf), GetString(nc, minutes == 1 ? _("expires in %d minute") : _("expires in %d minutes")).c_str(), minutes); + snprintf(buf, sizeof(buf), GetString(nc, minutes == 1 ? gtl("expires in %d minute") : gtl("expires in %d minutes")).c_str(), minutes); } else { int hours = diff / 3600, minutes; diff -= hours * 3600; minutes = diff / 60; - snprintf(buf, sizeof(buf), GetString(nc, hours == 1 && minutes == 1 ? _("expires in %d hour, %d minute") : (hours == 1 && minutes != 1 ? _("expires in %d hour, %d minutes") : (hours != 1 && minutes == 1 ? _("expires in %d hours, %d minute") : _("expires in %d hours, %d minutes")))).c_str(), hours, minutes); + snprintf(buf, sizeof(buf), GetString(nc, hours == 1 && minutes == 1 ? gtl("expires in %d hour, %d minute") : (hours == 1 && minutes != 1 ? gtl("expires in %d hour, %d minutes") : (hours != 1 && minutes == 1 ? gtl("expires in %d hours, %d minute") : gtl("expires in %d hours, %d minutes")))).c_str(), hours, minutes); } } diff --git a/src/regchannel.cpp b/src/regchannel.cpp index be2746edf..b76c85b64 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -793,7 +793,7 @@ bool ChannelInfo::CheckKick(User *user) if (!user->HasMode(UMODE_OPER) && this->HasFlag(CI_SUSPENDED)) { get_idealban(this, user, mask); - reason = GetString(user->Account(), _("This channel may not be used.")); + reason = GetString(user->Account(), gtl("This channel may not be used.")); set_modes = true; do_kick = true; } @@ -837,7 +837,7 @@ bool ChannelInfo::CheckKick(User *user) if (!do_kick && check_access(user, this, CA_NOJOIN)) { get_idealban(this, user, mask); - reason = GetString(user->Account(), _(CHAN_NOT_ALLOWED_TO_JOIN)); + reason = GetString(user->Account(), CHAN_NOT_ALLOWED_TO_JOIN); do_kick = true; } |