Subject: RE: bug#18054: Problematic translation strings in coreutils 8.22‏

From: Sebastian Rasmussen <[email-masked]>
Date: Sat, 19 Jul 2014 11:41:58 +0200

>Excellent attention to detail.
>The patch looks great. The only change I'll make is to s/maint:/doc:/
>in the commit summary.

Oh, ok. It wasn't clear from a quick git log how you usually do this,
but I'll update that.

>> if ((uid_set (uid) || groups) && setgroups (n_gids, gids) != 0)
>> error (EXIT_CANCELED, errno, _("failed to %s supplemental groups"),
>> - gids ? "set" : "clear");
>> + gids ? _("set") : _("clear"));
>
> This is not good; there may be languages where the translation context
> around "set" is different than around "clear".

True, I aimed for making the change as small as I possibly could (I haven't
contributed to coreutils before so I'm unware if you prefer minimalistic
patches or not :) ). But you are of course completely correct.

I provide an updated patch below, I hope I got the indentation correct,
otherwise please correct it for me. Thanks!

 / Sebastian

From f293a9006aa199fe5970c74744ea8db5aa6da70d Mon Sep 17 00:00:00 2001
From: Sebastian Rasmussen <[email-masked]>
Date: Wed, 16 Jul 2014 20:58:12 +0200
Subject: [PATCH] doc: fix two translation message issues

* gl/lib/randread.c (randread_error): xgettext can not handle translation
  strings containing C-expressions, so use the translation macro _() only
  for the real strings after the ternary expression has been evaluated.
* src/chroot.c (main): a translated error string had optional parts
  selected by a ternary expression which were left untranslated, evaluate
  the expression first and then have both resulting strings be translated.
---
 gl/lib/randread.c | 2 +-
 src/chroot.c      | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gl/lib/randread.c b/gl/lib/randread.c
index a073cab..af85653 100644
--- a/gl/lib/randread.c
+++ b/gl/lib/randread.c
@@ -125,7 +125,7 @@ randread_error (void const *file_name)
 {
   if (file_name)
     error (exit_failure, errno,
-           _(errno == 0 ? "%s: end of file" : "%s: read error"),
+           errno == 0 ? _("%s: end of file") : _("%s: read error"),
            quotearg_colon (file_name));
   abort ();
 }
diff --git a/src/chroot.c b/src/chroot.c
index fff0b53..aa191ba 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -392,8 +392,9 @@ main (int argc, char **argv)
 #endif
 
   if ((uid_set (uid) || groups) && setgroups (n_gids, gids) != 0)
-    error (EXIT_CANCELED, errno, _("failed to %s supplemental groups"),
-           gids ? "set" : "clear");
+    error (EXIT_CANCELED, errno,
+           gids ? _("failed to set supplemental groups") :
+           _("failed to clear supplemental groups"));
 
   free (in_gids);
   free (out_gids);
-- 
2.0.1