Localization bugs in findutils

View: New views
4 Messages — Rating Filter:   Alert me  

Localization bugs in findutils

by Jorma Karvonen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

here are some messages that probably need to be localized. I have
shown them in localized form:

find/fstype.c:203
error(1, 0, _("Cannot read mounted file system list"));

find/find.c:296
error(1, 0, _("Cannot read list of mounted devices."));

find/find.c:693
error(1, errno,
        _("failed to return to parent directory"));

find/ftsfind.c:344
fprintf(fp, _("Outstanding execdirs:"));

All text in while loop within lines 346 and 375 would need refactoring
to be localized, I think.

find/parser.c:1030
error(1, errno, _("Unexpected suffix %s on %s"),

find/parser.c:1036
error(1, errno, _("Expected an integer: %s"),

find/parser.c:3340
const char *errmsg = _("arithmetic overflow while converting %s "
    "days to a number of seconds");

find/parser.c: lines 3385-3399 need refactoring
find/parser.c: lines 3496-3502 need refactoring

The following should not be localized:
find/pred.c:1427
fprintf (stderr, _("< %s ... %s > ? "), program, arg);

find/pred.c:2302
error(0, 0,
      _("charsprinted=%ld but remaining=%lu: ns_buf=%s"),
      (long)charsprinted, (unsigned long)remaining, ns_buf);

What about localizing weekdays and months starting with line 2312 ?

find/pred.c:2440 p->need_stat ? "[call stat] " : "",
find/pred.c:2441 p->need_type ? "[need type] " : "");

find/pred.c:2465
fprintf(stderr, _("Predicate success rates after completion:\n"));

find/tree.c:347
fprintf(stderr, "%s:\n", _("predlist before merge sort"))

find/tree.c:394
fprintf(stderr, "%s:\n", _("predlist after merge sort"));

function consider_arm_swap() includes several strings without
localizing. The rest of file contains also many other strings without
localizing.

find/util.c:492
fprintf(stderr, _("fallback_stat(): stat(%s) failed; falling back on
lstat()\n"), name);

Best regards,

Jorma Karvonen



Re: Localization bugs in findutils

by James Youngman-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 23, 2009 at 6:09 PM, Jorma Karvonen
<karvonen.jorma@...> wrote:
> Hello,
>
> here are some messages that probably need to be localized. I have
> shown them in localized form:

Thanks, I'm not sure which version of findutils you started with, but
since you gave the strings too, I had no problems finding the messages
you were referring to.  A couple of them were obsolete, but thanks for
finding the ones that were still in there!

I have left a few of the messages un-translated as they're just debug
messages.   I attach the patch I just pushed.

Thanks again!
James.

[0001-Localise-some-previously-non-localised-strings.patch]

From a49936fc251bbe8082ab7b4a098e339a3a50be68 Mon Sep 17 00:00:00 2001
From: James Youngman <jay@...>
Date: Sun, 8 Nov 2009 22:26:30 +0000
Subject: [PATCH] Localise some previously non-localised strings.
To: findutils-patches@...

* find/find.c (init_mounted_dev_list): Pass translatable string
gettext.
(safely_chdir_lstat): Likewise.
* find/fstype.c (must_read_fs_list): Likewise.
* find/parser.c (safe_atoi): Likewise.
---
 ChangeLog     |    7 +++++++
 find/find.c   |    4 ++--
 find/fstype.c |    2 +-
 find/parser.c |    6 +++---
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f67c3fa..126e32a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-11-08  James Youngman  <jay@...>
 
+ Localise some previously non-localised strings.
+ * find/find.c (init_mounted_dev_list): Pass translatable string
+ gettext.
+ (safely_chdir_lstat): Likewise.
+ * find/fstype.c (must_read_fs_list): Likewise.
+ * find/parser.c (safe_atoi): Likewise.
+
  Updated a number of translation messages.
  * po/it.po: Updated Italian translation.
  * po/fi.po: Updated Finnish translation.
diff --git a/find/find.c b/find/find.c
index 908ed1f..a271f3f 100644
--- a/find/find.c
+++ b/find/find.c
@@ -299,7 +299,7 @@ init_mounted_dev_list(int mandatory)
   mounted_devices = get_mounted_devices(&num_mounted_devices);
   if (mandatory && (NULL == mounted_devices))
     {
-      error(1, 0, "Cannot read list of mounted devices.");
+      error(1, 0, _("Cannot read list of mounted devices."));
     }
 }
 
@@ -696,7 +696,7 @@ safely_chdir_lstat(const char *dest,
    * is fatal.
    */
   error(1, errno,
- "failed to return to parent directory");
+ _("failed to return to parent directory"));
  }
     }
   else
diff --git a/find/fstype.c b/find/fstype.c
index 8d0161b..001e009 100644
--- a/find/fstype.c
+++ b/find/fstype.c
@@ -200,7 +200,7 @@ must_read_fs_list(bool need_fs_type)
        * use because gnulib has abstracted all that stuff away.
        * Hence we cannot issue a specific error message here.
        */
-      error(1, 0, "Cannot read mounted file system list");
+      error(1, 0, _("Cannot read mounted file system list"));
     }
   return entries;
 }
diff --git a/find/parser.c b/find/parser.c
index 76b1297..1016b41 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -1032,7 +1032,7 @@ safe_atoi (const char *s)
     }
   else if (*end)
     {
-      error(1, errno, "Unexpected suffix %s on %s",
+      error(1, errno, _("Unexpected suffix %s on %s"),
     quotearg_n_style(0, options.err_quoting_style, end),
     quotearg_n_style(1, options.err_quoting_style, s));
     }
@@ -3390,8 +3390,8 @@ parse_time (const struct parser_table* entry, char *argv[], int *arg_ptr)
   struct time_val tval;
   enum comparison_type comp;
   const char *timearg, *orig_timearg;
-  const char *errmsg = "arithmetic overflow while converting %s "
-    "days to a number of seconds";
+  const char *errmsg = _("arithmetic overflow while converting %s "
+ "days to a number of seconds");
   struct timespec origin;
 
   if (!collect_arg(argv, arg_ptr, &timearg))
--
1.5.6.5



[PATCH] Adjust two xargs diagnostics (was: Localization bugs in findutils

by Jim Meyering :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

James Youngman wrote:

> On Fri, Oct 23, 2009 at 6:09 PM, Jorma Karvonen
> <karvonen.jorma@...> wrote:
>> Hello,
>>
>> here are some messages that probably need to be localized. I have
>> shown them in localized form:
>
> Thanks, I'm not sure which version of findutils you started with, but
> since you gave the strings too, I had no problems finding the messages
> you were referring to.  A couple of them were obsolete, but thanks for
> finding the ones that were still in there!
>
> I have left a few of the messages un-translated as they're just debug
> messages.   I attach the patch I just pushed.
>
> Thanks again!
> James.
...
> -  const char *errmsg = "arithmetic overflow while converting %s "
> -    "days to a number of seconds";
> +  const char *errmsg = _("arithmetic overflow while converting %s "
> + "days to a number of seconds");
>    struct timespec origin;
>
>    if (!collect_arg(argv, arg_ptr, &timearg))

Hi James,

I spotted at least one more with this:

  $ grep -nE '\<error \([^"]*"[^"]*[a-z]{3}' $(g ls-files) | grep -v '_('
  xargs/xargs.c:1009:         error (1, errno, "/dev/tty");
  xargs/xargs.c:1093:     error (1, errno, "could not create pipe before fork");

Regarding this one,
  xargs/xargs.c:1009:         error (1, errno, "/dev/tty");
it's better for those on the receiving end of such a diagnostic
to say what operation was being attempted, so...


[btw, the above check for unmarked-yet-translatable diagnostics is automated
 in gnulib's maint.mk.  If you're interested, running "make syntax-check"
 can detect problems like this;  to enable, use gnulib's maintainer-makefile
 module. ]


From 333b90e420200f8c083264ba1781dc01221d2807 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@...>
Date: Mon, 9 Nov 2009 10:39:35 +0100
Subject: [PATCH] Adjust two xargs diagnostics.

* xargs/xargs.c (print_args): Give a better diagnostic when
failing to open /dev/tty.
(xargs_do_exec): Mark a diagnostic for translation.
---
 ChangeLog     |    7 +++++++
 xargs/xargs.c |    4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 126e32a..6c88e3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-11-09  Jim Meyering  <meyering@...>
+
+ Adjust two xargs diagnostics.
+ * xargs/xargs.c (print_args): Give a better diagnostic when
+ failing to open /dev/tty.
+ (xargs_do_exec): Mark a diagnostic for translation.
+
 2009-11-08  James Youngman  <jay@...>

  Localise some previously non-localised strings.
diff --git a/xargs/xargs.c b/xargs/xargs.c
index fb97696..4bf61d2 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -1006,7 +1006,7 @@ print_args (boolean ask)
  {
   tty_stream = fopen ("/dev/tty", "r");
   if (!tty_stream)
-    error (1, errno, "/dev/tty");
+    error (1, errno, _("failed to open /dev/tty for reading"));
  }
       fputs ("?...", stderr);
       fflush (stderr);
@@ -1090,7 +1090,7 @@ xargs_do_exec (struct buildcmd_control *ctl, struct buildcmd_state *state)
       wait_for_proc (false, 0u);

       if (pipe(fd))
- error (1, errno, "could not create pipe before fork");
+ error (1, errno, _("could not create pipe before fork"));
       fcntl(fd[1], F_SETFD, FD_CLOEXEC);

       /* If we run out of processes, wait for a child to return and
--
1.6.5.2.351.g0943



Re: [PATCH] Adjust two xargs diagnostics (was: Localization bugs in findutils

by James Youngman-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 9, 2009 at 9:44 AM, Jim Meyering <jim@...> wrote:

> From 333b90e420200f8c083264ba1781dc01221d2807 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering@...>
> Date: Mon, 9 Nov 2009 10:39:35 +0100
> Subject: [PATCH] Adjust two xargs diagnostics.
>
> * xargs/xargs.c (print_args): Give a better diagnostic when
> failing to open /dev/tty.
> (xargs_do_exec): Mark a diagnostic for translation.

Applied and pushed.   Thanks.

James.