[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

translating plural forms (Re: multiple merge notifications)

From: Peter Samuelson <peter_at_p12n.org>
Date: 2007-05-11 07:53:24 CEST

[Ben Collins-Sussman]
> --- subversion/svn/notify.c (revision 24986)
> +++ subversion/svn/notify.c (working copy)
> @@ -410,6 +410,18 @@
> svn_error_clear(n->err);
> break;
>
> + case svn_wc_notify_merge_begin:
> + if (n->merge_range->start == n->merge_range->end)
> + err = svn_cmdline_printf(pool, _("--- Merging revision %ld to
> '%s':\n"),
> + n->merge_range->start, path_local);
> + else
> + err = svn_cmdline_printf(pool, _("--- Merging revisions
> %ld-%ld to '%s':\n"),
> + n->merge_range->start,
> n->merge_range->end,
> + path_local);

Instead of _(), it would be appropriate to use the plural-sensitive
form of gettext:

        int numrevs = n->merge_range->end - n->merge_range->start + 1;
        char *tmpstr = dngettext(PACKAGE_NAME,
                                 "--- Merging revision %ld to '%s':\n",
                                 "--- Merging revisions %ld-%ld to '%s':\n",
                                 numrevs);
        if (numrevs == 1)
          err = svn_cmdline_printf(pool, tmpstr,
                                   n->merge_range->start, path_local);
        else
          err = svn_cmdline_printf(pool, tmpstr, n->merge_range->start,
                                   n->merge_range->end, path_local);

This accommodates languages which have more than two forms to denote
singular/plural. For example, I understand that in some languages,
nouns are declined as {one | two | more-than-two}. ngettext and
dngettext handle this correctly.

Of course, if you use dngettext(), you also want to add it to
svn_private_config.hw, to support --disable-nls.

Received on Fri May 11 07:53:46 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.