Mercurial > pidgin
changeset 4276:32fcf4cf5f80
[gaim-migrate @ 4527]
E'ric Boumaour (zongo_fr) writes:
"This patch enables the use of ngettext for singular and
plural forms of sentences ("%s person in room"/"%s
people in room") cf. gettext documentation.
Some call to g_snprintf have been rewritten to make
strings translatable (like "%s has %s")
The patch is also available at
http://www.frankiz.org/gaim/ starting by i18n-ngettext-
http://www.frankiz.org/gaim/i18n-ngettext-20030110.diff
is the current file, a newer date would be an update.
HTH,
Eric"
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 10 Jan 2003 15:36:48 +0000 |
parents | 5ce5b252cdb1 |
children | 12d3ca8f5b5f |
files | src/buddy.c src/buddy_chat.c src/protocols/oscar/oscar.c src/protocols/toc/toc.c src/prpl.c |
diffstat | 5 files changed, 57 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddy.c Fri Jan 10 07:04:23 2003 +0000 +++ b/src/buddy.c Fri Jan 10 15:36:48 2003 +0000 @@ -1576,11 +1576,11 @@ /* I know the line below is really ugly. I only did it this way * because I thought it'd be funny :-) */ - g_snprintf(tmp, sizeof(tmp), "%s has %s", name, - (when & OPT_POUNCE_TYPING) ? "started typing to you" : - (when & OPT_POUNCE_SIGNON) ? "signed on" : - (when & OPT_POUNCE_UNIDLE) ? "returned from being idle" : - "returned from being away"); + g_snprintf(tmp, sizeof(tmp), + (when & OPT_POUNCE_TYPING) ? _("%s has started typing to you") : + (when & OPT_POUNCE_SIGNON) ? _("%s has signed on") : + (when & OPT_POUNCE_UNIDLE) ? _("%s has returned from being idle") : + _("%s has returned from being away"), name); do_error_dialog(tmp, NULL, GAIM_INFO); }
--- a/src/buddy_chat.c Fri Jan 10 07:04:23 2003 +0000 +++ b/src/buddy_chat.c Fri Jan 10 15:36:48 2003 +0000 @@ -945,8 +945,8 @@ add_chat_buddy_common(b, name, pos); - g_snprintf(tmp, sizeof(tmp), _("%d %s in room"), g_list_length(b->in_room), - g_list_length(b->in_room) == 1 ? "person" : "people"); + g_snprintf(tmp, sizeof(tmp), ngettext("%d person in room", "%d people in room", + g_list_length(b->in_room)), g_list_length(b->in_room)); gtk_label_set_text(GTK_LABEL(b->count), tmp); if (b->makesound) @@ -1084,8 +1084,8 @@ return; /* don't remove them from ignored in case they re-enter */ - g_snprintf(tmp, sizeof(tmp), _("%d %s in room"), g_list_length(b->in_room), - g_list_length(b->in_room) == 1 ? "person" : "people"); + g_snprintf(tmp, sizeof(tmp), ngettext("%d person in room", "%d people in room", + g_list_length(b->in_room)), g_list_length(b->in_room)); gtk_label_set_text(GTK_LABEL(b->count), tmp); if (b->makesound) @@ -1652,8 +1652,8 @@ if (c->topic) gtk_entry_set_text(GTK_ENTRY(c->topic_text), c->topic); - g_snprintf(tmp, sizeof(tmp), _("%d %s in room"), g_list_length(c->in_room), - g_list_length(c->in_room) == 1 ? "person" : "people"); + g_snprintf(tmp, sizeof(tmp), ngettext("%d person in room", "%d people in room", + g_list_length(c->in_room)), g_list_length(c->in_room)); gtk_label_set_text(GTK_LABEL(c->count), tmp); while (r) { @@ -1685,8 +1685,8 @@ if (c->topic) gtk_entry_set_text(GTK_ENTRY(c->topic_text), c->topic); - g_snprintf(tmp, sizeof(tmp), _("%d %s in room"), g_list_length(c->in_room), - g_list_length(c->in_room) == 1 ? "person" : "people"); + g_snprintf(tmp, sizeof(tmp), ngettext("%d person in room", "%d people in room", + g_list_length(c->in_room)), g_list_length(c->in_room)); gtk_label_set_text(GTK_LABEL(c->count), tmp); while (r) {
--- a/src/protocols/oscar/oscar.c Fri Jan 10 07:04:23 2003 +0000 +++ b/src/protocols/oscar/oscar.c Fri Jan 10 15:36:48 2003 +0000 @@ -2346,60 +2346,66 @@ /* Invalid (0) */ g_snprintf(buf, sizeof(buf), - nummissed == 1 ? - _("You missed %hu message from %s because it was invalid.") : - _("You missed %hu messages from %s because they were invalid."), - nummissed, - userinfo->sn); + ngettext( + "You missed %hu message from %s because it was invalid.", + "You missed %hu messages from %s because they were invalid.", + nummissed), + userinfo->sn, + nummissed); break; case 1: /* Message too large */ g_snprintf(buf, sizeof(buf), - nummissed == 1 ? - _("You missed %hu message from %s because it was too large.") : - _("You missed %hu messages from %s because they were too large."), - nummissed, - userinfo->sn); + ngettext( + "You missed %hu message from %s because it was too large.", + "You missed %hu messages from %s because they were too large.", + nummissed), + userinfo->sn, + nummissed); break; case 2: /* Rate exceeded */ g_snprintf(buf, sizeof(buf), - nummissed == 1 ? - _("You missed %hu message from %s because the rate limit has been exceeded.") : - _("You missed %hu messages from %s because the rate limit has been exceeded."), - nummissed, - userinfo->sn); + ngettext( + "You missed %hu message from %s because the rate limit has been exceeded.", + "You missed %hu messages from %s because the rate limit has been exceeded.", + nummissed), + userinfo->sn, + nummissed); break; case 3: /* Evil Sender */ g_snprintf(buf, sizeof(buf), - nummissed == 1 ? - _("You missed %hu message from %s because he/she was too evil.") : - _("You missed %hu messages from %s because he/she was too evil."), - nummissed, - userinfo->sn); + ngettext( + "You missed %hu message from %s because he/she was too evil.", + "You missed %hu messages from %s because he/she was too evil.", + nummissed), + userinfo->sn, + nummissed); break; case 4: /* Evil Receiver */ g_snprintf(buf, sizeof(buf), - nummissed == 1 ? - _("You missed %hu message from %s because you are too evil.") : - _("You missed %hu messages from %s because you are too evil."), - nummissed, - userinfo->sn); + ngettext( + "You missed %hu message from %s because you are too evil.", + "You missed %hu messages from %s because you are too evil.", + nummissed), + userinfo->sn, + nummissed); break; default: g_snprintf(buf, sizeof(buf), - nummissed == 1 ? - _("You missed %hu message from %s for an unknown reason.") : - _("You missed %hu messages from %s for an unknown reason."), - nummissed, - userinfo->sn); + ngettext( + "You missed %hu message from %s for an unknown reason.", + "You missed %hu messages from %s for an unknown reason.", + nummissed), + userinfo->sn, + nummissed); break; } do_error_dialog(buf, NULL, GAIM_ERROR);
--- a/src/protocols/toc/toc.c Fri Jan 10 07:04:23 2003 +0000 +++ b/src/protocols/toc/toc.c Fri Jan 10 15:36:48 2003 +0000 @@ -1978,9 +1978,10 @@ index++; } g_snprintf(buf, sizeof(buf), - ft->files == 1 ? - _("%s requests %s to accept %d file: %s (%.2f %s)%s%s") : - _("%s requests %s to accept %d files: %s (%.2f %s)%s%s"), + ngettext( + "%s requests %s to accept %d file: %s (%.2f %s)%s%s", + "%s requests %s to accept %d files: %s (%.2f %s)%s%s", + ft->files), ft->user, ft->gc->username, ft->files, ft->filename, size, sizes[index], (ft->message) ? "\n" : "", (ft->message) ? ft->message : "");
--- a/src/prpl.c Fri Jan 10 07:04:23 2003 +0000 +++ b/src/prpl.c Fri Jan 10 15:36:48 2003 +0000 @@ -482,12 +482,12 @@ if (count < 0) { if (from && subject) - g_snprintf(buf, sizeof buf, "%s has mail from %s: %s", gc->username, from, *subject ? subject : _("No Subject")); + g_snprintf(buf, sizeof buf, _("%s has mail from %s: %s"), gc->username, from, *subject ? subject : _("No Subject")); else - g_snprintf(buf, sizeof buf, "%s has new mail.", gc->username); + g_snprintf(buf, sizeof buf, _("%s has new mail."), gc->username); } else if (count > 0) { - g_snprintf(buf, sizeof buf, "%s has %d new message%s.", - gc->username, count, count == 1 ? "" : "s"); + g_snprintf(buf, sizeof buf, + ngettext("%s has %d new message.","%s has %d new messages.",count), gc->username, count); } else if (mn->email_win) { gtk_widget_destroy(mn->email_win); return;