Subject: Problematic translation strings in coreutils 8.22‏
From: Sebastian Rasmussen <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Fri, 18 Jul 2014 23:48:10 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi!
 
When reviewing the Swedish translation of coreutils I noticed the pecular string
"failed to %s supplemental groups" which (because the contents of %s were
unclear) prompted me to look at the source of coreutils. The %s used in this string
is expanded to either "set" or "clear" but neither of those strings are enclosed by
the _() translation macro.
 
Once saw this I looked for further instances where the translation macro was
used in a strange way and I found the instance in gl/lib/randread.c. In the
.pot-file only "%s: end of file" is present and "%s: read error" is left untranslated.
The reason for this is that the translation macro _() in this instance contains
a ternary expression and only the first string will be parsed and offered for
translation. To fix this I propose to first evaluate the expression and only
then apply the translation macro.
 
Below I provide you with a proposed patch (applying on top of git HEAD).
Applying this patch makes the strings "set" and "clear" appear in the .pot-file
and "%s: read error" be mentioned for lib/randread.c too. I hope the patch
will help you in sorting out this minor issue. Thanks for an excellent set of utilities!
 
 / Sebastian

 
From 1333c446baefe31ebe25a1c18cd8f64a0c122516 Mon Sep 17 00:00:00 2001
From: Sebastian Rasmussen <[email-masked]>
Date: Wed, 16 Jul 2014 20:58:12 +0200
Subject: [PATCH] maint: 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): Two condtional error strings were untranslated.
---
 gl/lib/randread.c | 2 +-
 src/chroot.c      | 2 +-
 2 files changed, 2 insertions(+), 2 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..963f66b 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -393,7 +393,7 @@ main (int argc, char **argv)
 
   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"));
 
   free (in_gids);
   free (out_gids);
-- 
2.0.1