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

[PATCH] Proper plural localisation of conflict summary

From: Mattias Engdegård <mattiase_at_bredband.net>
Date: Sat, 13 Apr 2013 23:27:41 +0200

This is a good example of how a string that does not distinguish
between singular and plural in English still needs to be localised in
a number-aware way:

        SVN_ERR(svn_cmdline_printf(scratch_pool,
          _(" Text conflicts: %d remaining (and %d already resolved)
\n"),
          n_text, n_text_r));

In general, the actual numbers must agree with the phrases. Strictly
speaking that may also be the case for strings like

"Text conflicts: %d"

but we can probably get away without doing so, since the text before
the colon is considered to be a quantity-independent label, not a part
of the same phrase. The patch does not change these strings.

[[[
Use correct grammatical number localisation for conflict summary
messages.

* subversion/svn/notify.c
   (report_conflicts_remaining_and_resolved): New.
   (svn_cl__notifier_print_conflict_stats):
    Call report_conflicts_remaining_and_resolved for number-aware
    localisation of messages.
]]]

Index: subversion/svn/notify.c
===================================================================
--- subversion/svn/notify.c (revision 1467576)
+++ subversion/svn/notify.c (working copy)
@@ -89,6 +89,28 @@
   return SVN_NO_ERROR;
 }
 
+/* Output the string
+ " {prefix}: {n_remaining} remaining (and {n_resolved} already resolved)"
+ with proper localisation. */
+static svn_error_t *
+report_conflicts_remaining_and_resolved(apr_pool_t *pool, const char *prefix,
+ int n_remaining, int n_resolved)
+{
+ const char *remaining = apr_psprintf(pool,
+ Q_("%d remaining",
+ "%d remaining",
+ n_remaining),
+ n_remaining);
+ const char *resolved = apr_psprintf(pool,
+ Q_("and %d already resolved",
+ "and %d already resolved",
+ n_resolved),
+ n_resolved);
+ SVN_ERR(svn_cmdline_printf(pool, _(" %s: %s (%s)\n"),
+ prefix, remaining, resolved));
+ return SVN_NO_ERROR;
+}
+
 svn_error_t *
 svn_cl__notifier_print_conflict_stats(void *baton, apr_pool_t *scratch_pool)
 {
@@ -125,17 +147,14 @@
   else
     {
       if (n_text > 0 || n_text_r > 0)
- SVN_ERR(svn_cmdline_printf(scratch_pool,
- _(" Text conflicts: %d remaining (and %d already resolved)\n"),
- n_text, n_text_r));
+ SVN_ERR(report_conflicts_remaining_and_resolved(scratch_pool,
+ _("Text conflicts"), n_text, n_text_r));
       if (n_prop > 0 || n_prop_r > 0)
- SVN_ERR(svn_cmdline_printf(scratch_pool,
- _(" Property conflicts: %d remaining (and %d already resolved)\n"),
- n_prop, n_prop_r));
+ SVN_ERR(report_conflicts_remaining_and_resolved(scratch_pool,
+ _("Property conflicts"), n_prop, n_prop_r));
       if (n_tree > 0 || n_tree_r > 0)
- SVN_ERR(svn_cmdline_printf(scratch_pool,
- _(" Tree conflicts: %d remaining (and %d already resolved)\n"),
- n_tree, n_tree_r));
+ SVN_ERR(report_conflicts_remaining_and_resolved(scratch_pool,
+ _("Tree conflicts"), n_tree, n_tree_r));
     }
   if (nb->skipped_paths > 0)
     SVN_ERR(svn_cmdline_printf(scratch_pool,

Received on 2013-04-13 23:28:17 CEST

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