translate interval strings; translate more NickServ messages
authorMichael Poole <mdpoole@troilus.org>
Tue, 30 Mar 2004 04:40:38 +0000 (04:40 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 30 Mar 2004 04:40:38 +0000 (04:40 +0000)
* Translate interval strings to the user's language.

* Translate cookie emails and auth failure messages based on the
account's preferred language, rather than the user's preferred
language (they will not be authed, so they would get lang_C).
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-39

src/chanserv.c
src/common.h
src/global.c
src/main.c
src/mod-helpserv.c
src/mod-memoserv.c
src/mod-sockcheck.c
src/nickserv.c
src/opserv.c
src/saxdb.c
src/tools.c

index ed5a433b867517b679852fce0c6412be88b57ce8..9fdec6c577a3d6fe4117ec83601915511a448f61 100644 (file)
@@ -1334,7 +1334,7 @@ expire_channels(UNUSED_ARG(void *data))
     struct userData *user;
     char delay[INTERVALLEN], reason[INTERVALLEN + 64];
 
-    intervalString(delay, chanserv_conf.channel_expire_delay);
+    intervalString(delay, chanserv_conf.channel_expire_delay, NULL);
     sprintf(reason, "Channel registration automatically expired after %s of disuse.", delay);
 
     for(channel = channelList; channel; channel = next)
@@ -1539,7 +1539,7 @@ static CHANSERV_FUNC(cmd_noregister)
         {
             dnr = iter_data(it);
             if(dnr->set)
-                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
             else
                 reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
             matches++;
@@ -1548,7 +1548,7 @@ static CHANSERV_FUNC(cmd_noregister)
         {
             dnr = iter_data(it);
             if(dnr->set)
-                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
             else
                 reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
             matches++;
@@ -1557,7 +1557,7 @@ static CHANSERV_FUNC(cmd_noregister)
         {
             dnr = iter_data(it);
             if(dnr->set)
-                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+                reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
             else
                 reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
             matches++;
@@ -2381,7 +2381,7 @@ cmd_trim_bans(struct userNode *user, struct chanNode *channel, unsigned long dur
         count++;
     }
 
-    intervalString(interval, duration);
+    intervalString(interval, duration, user->handle_info);
     send_message(user, chanserv, "CSMSG_TRIMMED_BANS", count, channel->name, interval);
     return 1;
 }
@@ -2429,7 +2429,7 @@ cmd_trim_users(struct userNode *user, struct chanNode *channel, unsigned short m
         min_access = 1;
         max_access = UL_OWNER;
     }
-    send_message(user, chanserv, "CSMSG_TRIMMED_USERS", count, min_access, max_access, channel->name, intervalString(interval, duration));
+    send_message(user, chanserv, "CSMSG_TRIMMED_USERS", count, min_access, max_access, channel->name, intervalString(interval, duration, user->handle_info));
     return 1;
 }
 
@@ -2826,7 +2826,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c
                             /* automated kickban */
                         }
                        else if(duration)
-                           reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration));
+                           reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration, user->handle_info));
                        else
                            reply("CSMSG_BAN_ADDED", name, channel->name);
 
@@ -2933,7 +2933,7 @@ eject_user(struct userNode *user, struct chanNode *channel, unsigned int argc, c
     else if(action & ACTION_ADD_BAN)
     {
        if(duration)
-           reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration));
+           reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration, user->handle_info));
        else
            reply("CSMSG_BAN_ADDED", name, channel->name);
     }
@@ -3449,7 +3449,7 @@ cmd_list_users(struct userNode *user, struct chanNode *channel, unsigned int arg
         else if(!uData->seen)
             ary[2] = "Never";
         else
-            ary[2] = intervalString(seen, now - uData->seen);
+            ary[2] = intervalString(seen, now - uData->seen, user->handle_info);
         ary[2] = strdup(ary[2]);
         if(IsUserSuspended(uData))
             ary[3] = "Suspended";
@@ -3556,12 +3556,12 @@ static CHANSERV_FUNC(cmd_bans)
        if(!timed)
            expires = "";
        else if(ban->expires)
-           expires = intervalString(e_buffer, ban->expires - now);
+           expires = intervalString(e_buffer, ban->expires - now, user->handle_info);
        else
            expires = msg_never;
 
        if(ban->triggered)
-           triggered = intervalString(t_buffer, now - ban->triggered);
+           triggered = intervalString(t_buffer, now - ban->triggered, user->handle_info);
        else
            triggered = msg_never;
 
@@ -3795,34 +3795,34 @@ show_suspension_info(struct svccmd *cmd, struct userNode *user, struct suspended
         reply("CSMSG_CHANNEL_SUSPENDED_0", suspended->suspender, suspended->reason);
         break;
     case 1: /* no issue time, expires in future */
-        intervalString(buf1, suspended->expires-now);
+        intervalString(buf1, suspended->expires-now, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_1", suspended->suspender, buf1, suspended->reason);
         break;
     case 2: /* no issue time, expired */
-        intervalString(buf1, now-suspended->expires);
+        intervalString(buf1, now-suspended->expires, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_2", suspended->suspender, buf1, suspended->reason);
         break;
     case 3: /* no issue time, revoked */
-        intervalString(buf1, now-suspended->revoked);
+        intervalString(buf1, now-suspended->revoked, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_3", suspended->suspender, buf1, suspended->reason);
         break;
     case 4: /* issue time set, indefinite expiration */
-        intervalString(buf1, now-suspended->issued);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_4", buf1, suspended->suspender, suspended->reason);
         break;
     case 5: /* issue time set, expires in future */
-        intervalString(buf1, now-suspended->issued);
-        intervalString(buf2, suspended->expires-now);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
+        intervalString(buf2, suspended->expires-now, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_5", buf1, suspended->suspender, buf2, suspended->reason);
         break;
     case 6: /* issue time set, expired */
-        intervalString(buf1, now-suspended->issued);
-        intervalString(buf2, now-suspended->expires);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
+        intervalString(buf2, now-suspended->expires, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_6", buf1, suspended->suspender, buf2, suspended->reason);
         break;
     case 7: /* issue time set, revoked */
-        intervalString(buf1, now-suspended->issued);
-        intervalString(buf2, now-suspended->revoked);
+        intervalString(buf1, now-suspended->issued, user->handle_info);
+        intervalString(buf2, now-suspended->revoked, user->handle_info);
         reply("CSMSG_CHANNEL_SUSPENDED_7", buf1, suspended->suspender, buf2, suspended->reason);
         break;
     default:
@@ -3870,8 +3870,8 @@ static CHANSERV_FUNC(cmd_info)
             reply("CSMSG_CHANNEL_OWNER", owner->handle->handle);
     reply("CSMSG_CHANNEL_USERS", cData->userCount);
     reply("CSMSG_CHANNEL_BANS", cData->banCount);
-    reply("CSMSG_CHANNEL_VISITED", intervalString(buffer, now - cData->visited));
-    reply("CSMSG_CHANNEL_REGISTERED", intervalString(buffer, now - cData->registered));
+    reply("CSMSG_CHANNEL_VISITED", intervalString(buffer, now - cData->visited, user->handle_info));
+    reply("CSMSG_CHANNEL_REGISTERED", intervalString(buffer, now - cData->registered, user->handle_info));
 
     privileged = IsStaff(user);
     if(((uData && uData->access >= UL_COOWNER) || privileged) && cData->registrar)
@@ -3908,8 +3908,8 @@ static CHANSERV_FUNC(cmd_netinfo)
     reply("CSMSG_NETWORK_CHANNELS", registered_channels);
     reply("CSMSG_NETWORK_BANS", banCount);
     reply("CSMSG_CHANNEL_USERS", userCount);
-    reply("CSMSG_SERVICES_UPTIME", intervalString(interval, time(NULL) - boot_time));
-    reply("CSMSG_BURST_LENGTH",intervalString(interval, burst_length));
+    reply("CSMSG_SERVICES_UPTIME", intervalString(interval, time(NULL) - boot_time, user->handle_info));
+    reply("CSMSG_BURST_LENGTH", intervalString(interval, burst_length, user->handle_info));
     return 1;
 }
 
@@ -4115,7 +4115,7 @@ static CHANSERV_FUNC(cmd_seen)
     if(uData->present)
        reply("CSMSG_USER_PRESENT", handle->handle);
     else if(uData->seen)
-        reply("CSMSG_USER_SEEN", handle->handle, channel->name, intervalString(seen, now - uData->seen));
+        reply("CSMSG_USER_SEEN", handle->handle, channel->name, intervalString(seen, now - uData->seen, user->handle_info));
     else
         reply("CSMSG_NEVER_SEEN", handle->handle, channel->name);
 
@@ -4667,7 +4667,7 @@ static CHANSERV_FUNC(cmd_unvisited)
             limit = atoi(argv[2]);
     }
 
-    intervalString(buffer, interval);
+    intervalString(buffer, interval, user->handle_info);
     reply("CSMSG_UNVISITED_HEADER", limit, buffer);
 
     for(cData = channelList; cData && matches < limit; cData = cData->next)
@@ -4675,7 +4675,7 @@ static CHANSERV_FUNC(cmd_unvisited)
        if((now - cData->visited) < interval)
             continue;
 
-       intervalString(buffer, now - cData->visited);
+       intervalString(buffer, now - cData->visited, user->handle_info);
        reply("CSMSG_UNVISITED_DATA", cData->channel->name, buffer);
        matches++;
     }
index a16b14b846d1b7eabb319320528f3e7d15bc3c19..952b1de056e85cc90241ac82eae7f3fd03a0b6e9 100644 (file)
@@ -162,12 +162,14 @@ void STRUCTNAME##_clean(struct STRUCTNAME *list) {\
   free(list->list);\
 }
 
-/* The longest string that's likely to be produced is "10 minutes, and 10
-   seconds." (27 characters) */
-#define INTERVALLEN    32
+/* The longest string that is likely to be produced in English is "10
+ * minutes, and 10 seconds" (27 characters).  Other languages will
+ * vary, so there's plenty of leeway.
+ */
+#define INTERVALLEN    50
 
-char *intervalString2(char *output, time_t interval, int brief);
-#define intervalString(OUTPUT, INTERVAL) intervalString2((OUTPUT), (INTERVAL), 0)
+struct handle_info;
+char *intervalString(char *output, time_t interval, struct handle_info *hi);
 int getipbyname(const char *name, unsigned long *ip);
 int set_policer_param(const char *param, void *data, void *extra);
 const char *strtab(unsigned int ii);
index c8106685e8465102b6b1c28e08bd57fa1352abec..0e9c2b1034a110a4b8b35415aa6cdafecc7ab939 100644 (file)
@@ -442,13 +442,9 @@ static GLOBAL_FUNC(cmd_list)
         table.contents[nn][0] = strdup(buffer);
         table.contents[nn][1] = messageType(message);
         if(message->duration)
-        {
-            intervalString(buffer, message->posted + message->duration - now);
-        }
+            intervalString(buffer, message->posted + message->duration - now, user->handle_info);
         else
-        {
             strcpy(buffer, "Never.");
-        }
         table.contents[nn][2] = strdup(buffer);
         table.contents[nn][3] = message->from;
        length = strlen(message->message);
index 997c4786d0786c268f8a4cb73c96ce2a1031263f..32ff878ccf1812e59953924d7aaccd8085e4efc7 100644 (file)
@@ -117,6 +117,20 @@ static const struct message_entry msgtab[] = {
     { "MSG_DB_WRITE_ERROR", "Error while writing database %s." },
     { "MSG_DB_WROTE_DB", "Wrote database %s (in "FMT_TIME_T".%06lu seconds)." },
     { "MSG_DB_WROTE_ALL", "Wrote all databases (in "FMT_TIME_T".%06lu seconds)." },
+    { "MSG_AND", "and" },
+    { "MSG_0_SECONDS", "0 seconds" },
+    { "MSG_YEAR", "year" },
+    { "MSG_YEARS", "years" },
+    { "MSG_WEEK", "week" },
+    { "MSG_WEEKS", "weeks" },
+    { "MSG_DAY", "day" },
+    { "MSG_DAYS", "days" },
+    { "MSG_HOUR", "hour" },
+    { "MSG_HOURS", "hours" },
+    { "MSG_MINUTE", "minute" },
+    { "MSG_MINUTES", "minutes" },
+    { "MSG_SECOND", "second" },
+    { "MSG_SECONDS", "seconds" },
     { NULL, NULL }
 };
 
index 177e11e53708f0a2ef4e479fc9b0bdc4cde4519b..57a42caf3ecb179502746cbbe8f40dc3c1ace406 100644 (file)
@@ -924,7 +924,7 @@ static struct helpserv_request * create_request(struct userNode *user, struct he
         sprintf(lbuf[0], fmt, req->id);
     }
     if (req != hs->unhandled) {
-        intervalString(unh, now - hs->unhandled->opened);
+        intervalString(unh, now - hs->unhandled->opened, user->handle_info);
         fmt = user_find_message(user, "HSMSG_REQ_UNHANDLED_TIME");
         sprintf(lbuf[1], fmt, unh);
     } else {
@@ -1067,7 +1067,7 @@ static void helpserv_usermsg(struct userNode *user, struct helpserv_bot *hs, cha
         char buf[MAX_LINE_SIZE], updatestr[INTERVALLEN], timestr[MAX_LINE_SIZE];
 
         strftime(timestr, MAX_LINE_SIZE, HSFMT_TIME, localtime(&req->opened));
-        intervalString(updatestr, now - req->updated);
+        intervalString(updatestr, now - req->updated, user->handle_info);
         if (req->helper && (hs->notify >= NOTIFY_USER))
             if (user->handle_info)
                 helpserv_notify(req->helper, "HSMSG_PAGE_UPD_REQUEST_AUTHED", req->id, user->nick, user->handle_info->handle, timestr, updatestr);
@@ -1241,7 +1241,7 @@ static HELPSERV_USERCMD(usercmd_wait) {
             pos = count;
     }
     assert(pos >= 0);
-    intervalString(buf, now - req->hs->unhandled->opened);
+    intervalString(buf, now - req->hs->unhandled->opened, req->user->handle_info);
     helpserv_user_reply("HSMSG_WAIT_STATUS", pos+1, count, buf);
 }
 
@@ -1768,7 +1768,7 @@ static HELPSERV_FUNC(cmd_list) {
         }
         tbl.contents[line][1] = strdup(username);
         tbl.contents[line][2] = req->helper ? req->helper->handle->handle : "(Unassigned)";
-        intervalString(opentime, now - req->opened);
+        intervalString(opentime, now - req->opened, user->handle_info);
         tbl.contents[line][3] = strdup(opentime);
         tbl.contents[line][4] = ((req->user || req->handle->users) ? "Online" : "Offline");
     }
@@ -1802,7 +1802,7 @@ static void helpserv_show(int from_opserv, struct helpserv_bot *hs, struct userN
     else
         helpserv_notice(user, "HSMSG_REQ_INFO_2e");
     strftime(buf, MAX_LINE_SIZE, HSFMT_TIME, localtime(&req->opened));
-    intervalString(buf2, now - req->opened);
+    intervalString(buf2, now - req->opened, user->handle_info);
     helpserv_notice(user, "HSMSG_REQ_INFO_3", buf, buf2);
     helpserv_notice(user, "HSMSG_REQ_INFO_4");
     for (nn=0; nn < req->text->used; nn++)
@@ -2313,7 +2313,7 @@ static HELPSERV_FUNC(cmd_bots) {
         tbl.contents[i][1] = bot->helpchan->name;
         tbl.contents[i][2] = owner ? owner->handle->handle : "None";
         tbl.contents[i][3] = alloca(INTERVALLEN);
-        intervalString((char*)tbl.contents[i][3], now - bot->last_active);
+        intervalString((char*)tbl.contents[i][3], now - bot->last_active, user->handle_info);
     }
 
     table_send((from_opserv ? opserv : hs->helpserv), user->nick, 0, NULL, tbl);
@@ -2399,7 +2399,7 @@ static void run_whine_interval(void *data) {
         if (reqlist.used) {
             char strwhinedelay[INTERVALLEN];
 
-            intervalString(strwhinedelay, (time_t)hs->intervals[INTERVAL_WHINE_DELAY]);
+            intervalString(strwhinedelay, (time_t)hs->intervals[INTERVAL_WHINE_DELAY], NULL);
 #if ANNOYING_ALERT_PAGES
             tbl.length = reqlist.used + 1;
             tbl.width = 4;
@@ -2420,7 +2420,7 @@ static void run_whine_interval(void *data) {
                 tbl.contents[i][0] = strdup(reqid);
                 tbl.contents[i][1] = unh->user ? unh->user->nick : "Not online";
                 tbl.contents[i][2] = unh->handle ? unh->handle->handle : "Not authed";
-                intervalString(unh_time, now - unh->opened);
+                intervalString(unh_time, now - unh->opened, NULL);
                 tbl.contents[i][3] = strdup(unh_time);
             }
 
@@ -2500,11 +2500,11 @@ static void run_whine_interval(void *data) {
                 }
                 tbl.contents[i][2] = strdup(reqid);
 
-                intervalString(idle_time, now - mn->idle_since);
+                intervalString(idle_time, now - mn->idle_since, NULL);
                 tbl.contents[i][3] = strdup(idle_time);
             }
 
-            intervalString(stridledelay, (time_t)hs->intervals[INTERVAL_IDLE_DELAY]);
+            intervalString(stridledelay, (time_t)hs->intervals[INTERVAL_IDLE_DELAY], NULL);
             helpserv_page(PGSRC_STATUS, "HSMSG_PAGE_IDLE_HEADER", mode_list.used, hs->helpchan->name, stridledelay);
             table_send(hs->helpserv, hs->page_targets[PGSRC_STATUS]->name, 0, page_types[hs->page_types[PGSRC_STATUS]].func, tbl);
 
@@ -3000,7 +3000,7 @@ static int opt_interval(struct userNode *user, struct helpserv_bot *hs, int from
             return 0;
         }
         if (new_int && new_int < min) {
-            intervalString(buf, min);
+            intervalString(buf, min, user->handle_info);
             helpserv_notice(user, "HSMSG_INVALID_INTERVAL", user_find_message(user, interval_types[idx].print_name), buf);
             return 0;
         }
@@ -3008,7 +3008,7 @@ static int opt_interval(struct userNode *user, struct helpserv_bot *hs, int from
         changed = 1;
     }
     if (hs->intervals[idx]) {
-        intervalString(buf, hs->intervals[idx]);
+        intervalString(buf, hs->intervals[idx], user->handle_info);
         helpserv_notice(user, interval_types[idx].print_name, buf);
     } else
         helpserv_notice(user, interval_types[idx].print_name, user_find_message(user, "HSMSG_0_DISABLED"));
index 729fae1fd92ea326c52f191cb3b9a47b02fa46ae..1fc9b1fb4fa94e47f20a0aaef1decffd28482804 100644 (file)
@@ -357,7 +357,7 @@ static MODCMD_FUNC(cmd_expiry)
         return 1;
     }
 
-    intervalString(interval, memoserv_conf.message_expiry);
+    intervalString(interval, memoserv_conf.message_expiry, user->handle_info);
     reply("MSMSG_EXPIRY", interval, memoserv_conf.message_expiry);
     return 1;
 }
index 0a07eabf1f603a79440dee4c1b3ea13efc6f8e67..0e038221f187ca3972504de184ed5f810c2081ba 100644 (file)
@@ -1080,7 +1080,7 @@ static MODCMD_FUNC(cmd_stats_proxycheck)
             reply("PCMSG_NOT_CACHED", hostname);
             return 0;
         }
-        intervalString(elapse_buf, now - sci->last_touched);
+        intervalString(elapse_buf, now - sci->last_touched, user->handle_info);
         switch (sci->decision) {
         case CHECKING: msg = "PCMSG_STATUS_CHECKING"; break;
         case ACCEPT: msg = "PCMSG_STATUS_ACCEPTED"; break;
index 98351a8cd7d0a4b7ecdce513aba1fd31361839a1..3c1fb57c97723a2f7a1d0b0247f6daa5674f6d1d 100644 (file)
@@ -161,7 +161,7 @@ static const struct message_entry msgtab[] = {
     { "NSMSG_NICK_NOT_REGISTERED", "Nick $b%s$b has not been registered to any account." },
     { "NSMSG_HANDLE_NOT_FOUND", "Could not find your account -- did you register yet?" },
     { "NSMSG_ALREADY_AUTHED", "You are already authed to account $b%s$b; you must reconnect to auth to a different account." },
-    { "NSMSG_USE_AUTHCOOKIE", "Your hostmask is not valid for account $b%s$b.  Please use the $bauthcookie$b command to grant yourself access.  (/msg $S authcookie %s)" },
+    { "NSMSG_USE_AUTHCOOKIE", "Your hostmask is not valid for account $b%1$s$b.  Please use the $bauthcookie$b command to grant yourself access.  (/msg $S authcookie %1$s)" },
     { "NSMSG_HOSTMASK_INVALID", "Your hostmask is not valid for account $b%s$b." },
     { "NSMSG_USER_IS_SERVICE", "$b%s$b is a network service; you can only use that command on real users." },
     { "NSMSG_USER_PREV_AUTH", "$b%s$b is already authenticated." },
@@ -974,17 +974,17 @@ nickserv_make_cookie(struct userNode *user, struct handle_info *hi, enum cookie_
     case ACTIVATION:
         hi->passwd[0] = 0; /* invalidate password */
         send_message(user, nickserv, "NSMSG_USE_COOKIE_REGISTER");
-        fmt = user_find_message(user, "NSEMAIL_ACTIVATION_SUBJECT");
+        fmt = handle_find_message(hi, "NSEMAIL_ACTIVATION_SUBJECT");
         snprintf(subject, sizeof(subject), fmt, netname);
-        fmt = user_find_message(user, "NSEMAIL_ACTIVATION_BODY");
+        fmt = handle_find_message(hi, "NSEMAIL_ACTIVATION_BODY");
         snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
         first_time = 1;
         break;
     case PASSWORD_CHANGE:
         send_message(user, nickserv, "NSMSG_USE_COOKIE_RESETPASS");
-        fmt = user_find_message(user, "NSEMAIL_PASSWORD_CHANGE_SUBJECT");
+        fmt = handle_find_message(hi, "NSEMAIL_PASSWORD_CHANGE_SUBJECT");
         snprintf(subject, sizeof(subject), fmt, netname);
-        fmt = user_find_message(user, "NSEMAIL_PASSWORD_CHANGE_BODY");
+        fmt = handle_find_message(hi, "NSEMAIL_PASSWORD_CHANGE_BODY");
         snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
         break;
     case EMAIL_CHANGE:
@@ -992,18 +992,18 @@ nickserv_make_cookie(struct userNode *user, struct handle_info *hi, enum cookie_
         hi->email_addr = cookie->data;
         if (misc) {
             send_message(user, nickserv, "NSMSG_USE_COOKIE_EMAIL_2");
-            fmt = user_find_message(user, "NSEMAIL_EMAIL_CHANGE_SUBJECT");
+            fmt = handle_find_message(hi, "NSEMAIL_EMAIL_CHANGE_SUBJECT");
             snprintf(subject, sizeof(subject), fmt, netname);
-            fmt = user_find_message(user, "NSEMAIL_EMAIL_CHANGE_BODY_NEW");
+            fmt = handle_find_message(hi, "NSEMAIL_EMAIL_CHANGE_BODY_NEW");
             snprintf(body, sizeof(body), fmt, netname, cookie->cookie+COOKIELEN/2, nickserv->nick, self->name, hi->handle, COOKIELEN/2);
             sendmail(nickserv, hi, subject, body, 1);
-            fmt = user_find_message(user, "NSEMAIL_EMAIL_CHANGE_BODY_OLD");
+            fmt = handle_find_message(hi, "NSEMAIL_EMAIL_CHANGE_BODY_OLD");
             snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle, COOKIELEN/2, hi->email_addr);
         } else {
             send_message(user, nickserv, "NSMSG_USE_COOKIE_EMAIL_1");
-            fmt = user_find_message(user, "NSEMAIL_EMAIL_VERIFY_SUBJECT");
+            fmt = handle_find_message(hi, "NSEMAIL_EMAIL_VERIFY_SUBJECT");
             snprintf(subject, sizeof(subject), fmt, netname);
-            fmt = user_find_message(user, "NSEMAIL_EMAIL_VERIFY_BODY");
+            fmt = handle_find_message(hi, "NSEMAIL_EMAIL_VERIFY_BODY");
             snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
             sendmail(nickserv, hi, subject, body, 1);
             subject[0] = 0;
@@ -1011,9 +1011,9 @@ nickserv_make_cookie(struct userNode *user, struct handle_info *hi, enum cookie_
         hi->email_addr = misc;
         break;
     case ALLOWAUTH:
-        fmt = user_find_message(user, "NSEMAIL_ALLOWAUTH_SUBJECT");
+        fmt = handle_find_message(hi, "NSEMAIL_ALLOWAUTH_SUBJECT");
         snprintf(subject, sizeof(subject), fmt, netname);
-        fmt = user_find_message(user, "NSEMAIL_ALLOWAUTH_BODY");
+        fmt = handle_find_message(hi, "NSEMAIL_ALLOWAUTH_BODY");
         snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
         send_message(user, nickserv, "NSMSG_USE_COOKIE_AUTH");
         break;
@@ -1235,7 +1235,7 @@ static NICKSERV_FUNC(cmd_handleinfo)
     reply("NSMSG_HANDLEINFO_REGGED", ctime(&hi->registered));
 
     if (!hi->users) {
-       intervalString(buff, now - hi->lastseen);
+       intervalString(buff, now - hi->lastseen, user->handle_info);
        reply("NSMSG_HANDLEINFO_LASTSEEN", buff);
     } else {
        reply("NSMSG_HANDLEINFO_LASTSEEN_NOW");
@@ -1509,18 +1509,24 @@ static NICKSERV_FUNC(cmd_auth)
         reply("NSMSG_HANDLE_NOT_FOUND");
         return 0;
     }
+    /* Responses from here on look up the language used by the handle they asked about. */
     passwd = argv[pw_arg];
     if (!valid_user_for(user, hi)) {
         if (hi->email_addr && nickserv_conf.email_enabled)
-            reply("NSMSG_USE_AUTHCOOKIE", hi->handle, hi->handle);
+            send_message_type(4, user, cmd->parent->bot,
+                              handle_find_message(hi, "NSMSG_USE_AUTHCOOKIE"),
+                              hi->handle);
         else
-            reply("NSMSG_HOSTMASK_INVALID", hi->handle);
+            send_message_type(4, user, cmd->parent->bot,
+                              handle_find_message(hi, "NSMSG_HOSTMASK_INVALID"),
+                              hi->handle);
         argv[pw_arg] = "BADMASK";
         return 1;
     }
     if (!checkpass(passwd, hi->passwd)) {
         unsigned int n;
-        reply("NSMSG_PASSWORD_INVALID");
+        send_message_type(4, user, cmd->parent->bot,
+                          handle_find_message(hi, "NSMSG_PASSWORD_INVALID"));
         argv[pw_arg] = "BADPASS";
         for (n=0; n<failpw_func_used; n++) failpw_func_list[n](user, hi);
         if (nickserv_conf.autogag_enabled) {
@@ -1540,29 +1546,31 @@ static NICKSERV_FUNC(cmd_auth)
         return 1;
     }
     if (HANDLE_FLAGGED(hi, SUSPENDED)) {
-        reply("NSMSG_HANDLE_SUSPENDED");
+        send_message_type(4, user, cmd->parent->bot,
+                          handle_find_message(hi, "NSMSG_HANDLE_SUSPENDED"));
         argv[pw_arg] = "SUSPENDED";
         return 1;
     }
     maxlogins = hi->maxlogins ? hi->maxlogins : nickserv_conf.default_maxlogins;
     for (used = 0, other = hi->users; other; other = other->next_authed) {
         if (++used >= maxlogins) {
-            reply("NSMSG_MAX_LOGINS", maxlogins);
+            send_message_type(4, user, cmd->parent->bot,
+                              handle_find_message(hi, "NSMSG_MAX_LOGINS"),
+                              maxlogins);
             argv[pw_arg] = "MAXLOGINS";
             return 1;
         }
     }
 
+    set_user_handle_info(user, hi, 1);
     if (nickserv_conf.email_required && !hi->email_addr)
         reply("NSMSG_PLEASE_SET_EMAIL");
     if (!is_secure_password(hi->handle, passwd, NULL))
         reply("NSMSG_WEAK_PASSWORD");
     if (hi->passwd[0] != '$')
         cryptpass(passwd, hi->passwd);
-
     reply("NSMSG_AUTH_SUCCESS");
     argv[pw_arg] = "****";
-    set_user_handle_info(user, hi, 1);
     return 1;
 }
 
index 6d31e784884a2ff8a3ab276e87a6c63fe8bbedcf..74a4380998bf6aa75f0c0cfd4fe890a5d0a2ba60 100644 (file)
@@ -1193,7 +1193,7 @@ static MODCMD_FUNC(cmd_whois)
 #endif
     reply("OSMSG_WHOIS_SERVER", target->uplink->name);
     reply("OSMSG_WHOIS_ACCOUNT", (target->handle_info ? target->handle_info->handle : "Not authenticated"));
-    intervalString(buffer, now - target->timestamp);
+    intervalString(buffer, now - target->timestamp, user->handle_info);
     reply("OSMSG_WHOIS_NICK_AGE", buffer);
     if (target->channels.used <= MAX_CHANNELS_WHOIS)
        opserv_ison(user, target, "OSMSG_WHOIS_CHANNELS");
@@ -1395,8 +1395,9 @@ static MODCMD_FUNC(cmd_stats_network2) {
 #endif
         tbl.contents[nn][1] = buffer;
         ofs = strlen(buffer) + 1;
-        intervalString(buffer + ofs, now - server->link);
-        if (server->self_burst) strcat(buffer + ofs, " Bursting");
+        intervalString(buffer + ofs, now - server->link, user->handle_info);
+        if (server->self_burst)
+            strcat(buffer + ofs, " Bursting");
         tbl.contents[nn][2] = buffer + ofs;
         nn++;
     }
@@ -1428,9 +1429,9 @@ static MODCMD_FUNC(cmd_stats_trusted) {
         th = dict_find(opserv_trusted_hosts, argv[1], NULL);
         if (th) {
             if (th->issued)
-                intervalString(issued, now - th->issued);
+                intervalString(issued, now - th->issued, user->handle_info);
             if (th->expires)
-                intervalString(length, th->expires - now);
+                intervalString(length, th->expires - now, user->handle_info);
             if (th->limit)
                 sprintf(limit, "limit %lu", th->limit);
             reply("OSMSG_HOST_IS_TRUSTED",
@@ -1448,9 +1449,9 @@ static MODCMD_FUNC(cmd_stats_trusted) {
         for (it = dict_first(opserv_trusted_hosts); it; it = iter_next(it)) {
             th = iter_data(it);
             if (th->issued)
-                intervalString(issued, now - th->issued);
+                intervalString(issued, now - th->issued, user->handle_info);
             if (th->expires)
-                intervalString(length, th->expires - now);
+                intervalString(length, th->expires - now, user->handle_info);
             if (th->limit)
                 sprintf(limit, "limit %lu", th->limit);
             reply("OSMSG_HOST_IS_TRUSTED", iter_key(it),
@@ -1491,7 +1492,7 @@ static MODCMD_FUNC(cmd_stats_uptime) {
             clocks_per_sec = CLOCKS_PER_SEC;
         }
     }
-    intervalString(uptime, time(NULL)-boot_time);
+    intervalString(uptime, time(NULL)-boot_time, user->handle_info);
     times(&buf);
     reply("OSMSG_UPTIME_STATS",
           uptime, lines_processed,
@@ -1540,8 +1541,10 @@ static MODCMD_FUNC(cmd_stats_gags) {
     table.contents[0][3] = "Reason";
     for (nn=1, gag=gagList; gag; nn++, gag=gag->next) {
         char expstr[INTERVALLEN];
-        if (gag->expires) intervalString(expstr, gag->expires - now);
-        else strcpy(expstr, "Never");
+        if (gag->expires)
+            intervalString(expstr, gag->expires - now, user->handle_info);
+        else
+            strcpy(expstr, "Never");
         table.contents[nn] = calloc(table.width, sizeof(char*));
         table.contents[nn][0] = gag->mask;
         table.contents[nn][1] = gag->owner;
index 2ddd158536a29e1b1c5eee98fefec3e6f5c0235d..88f8352e614b90dc570e8975df4bf7b76db7fafa 100644 (file)
@@ -423,14 +423,14 @@ static MODCMD_FUNC(cmd_stats_databases) {
         tbl.contents[ii][0] = db->name;
         tbl.contents[ii][1] = db->mondo_section ? db->mondo_section : db->filename;
         if (db->write_interval) {
-            intervalString(buf, db->write_interval);
+            intervalString(buf, db->write_interval, user->handle_info);
         } else {
             strcpy(buf, "Never");
         }
         tbl.contents[ii][2] = buf;
         if (db->last_write) {
-            intervalString(buf+INTERVALLEN, now - db->last_write);
-            intervalString(buf+INTERVALLEN*2, db->last_write_duration);
+            intervalString(buf+INTERVALLEN, now - db->last_write, user->handle_info);
+            intervalString(buf+INTERVALLEN*2, db->last_write_duration, user->handle_info);
         } else {
             strcpy(buf+INTERVALLEN, "Never");
             strcpy(buf+INTERVALLEN*2, "Never");
index c2fc94e17a8842ccd3904b249af1bbc24f07ce0e..219d0afdc91ede210005662e444a5bbf42bb8a65 100644 (file)
@@ -18,6 +18,7 @@
  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
+#include "helpfile.h"
 #include "log.h"
 #include "nickserv.h"
 #include "recdb.h"
@@ -643,25 +644,29 @@ unsplit_string(char *set[], unsigned int max, char *dest)
 }
 
 char *
-intervalString2(char *output, time_t interval, int brief)
+intervalString(char *output, time_t interval, struct handle_info *hi)
 {
     static const struct {
-        const char *name;
+        const char *msg_single;
+        const char *msg_plural;
         long length;
     } unit[] = {
-        { "year", 365 * 24 * 60 * 60 },
-        { "week",   7 * 24 * 60 * 60 },
-        { "day",        24 * 60 * 60 },
-        { "hour",            60 * 60 },
-        { "minute",               60 },
-        { "second",                1 }
+        { "MSG_YEAR",   "MSG_YEARS", 365 * 24 * 60 * 60 },
+        { "MSG_WEEK",   "MSG_WEEKS",   7 * 24 * 60 * 60 },
+        { "MSG_DAY",    "MSG_DAYS",        24 * 60 * 60 },
+        { "MSG_HOUR",   "MSG_HOURS",            60 * 60 },
+        { "MSG_MINUTE", "MSG_MINUTES",               60 },
+        { "MSG_SECOND", "MSG_SECONDS",                1 }
     };
+    struct language *lang;
+    const char *msg;
     unsigned int type, words, pos, count;
 
+    lang = hi ? hi->language : lang_C;
     if(!interval)
     {
-       strcpy(output, brief ? "0s" : "0 seconds");
-       return output;
+        msg = language_find_message(lang, "MSG_0_SECONDS");
+       return strcpy(output, msg);
     }
 
     for (type = 0, words = pos = 0;
@@ -672,15 +677,15 @@ intervalString2(char *output, time_t interval, int brief)
         count = interval / unit[type].length;
         interval = interval % unit[type].length;
 
-        if (brief)
-            pos += sprintf(output + pos, "%d%c", count, unit[type].name[0]);
-        else if (words == 1)
-            pos += sprintf(output + pos, " and %d %s", count, unit[type].name);
+        if (words++ == 1) {
+            msg = language_find_message(lang, "MSG_AND");
+            pos += sprintf(output + pos, " %s ", msg);
+        }
+        if (count == 1)
+            msg = language_find_message(lang, unit[type].msg_single);
         else
-            pos += sprintf(output + pos, "%d %s", count, unit[type].name);
-        if (count != 1)
-            output[pos++] = 's';
-        words++;
+            msg = language_find_message(lang, unit[type].msg_plural);
+        pos += sprintf(output + pos, "%d %s", count, msg);
     }
 
     output[pos] = 0;