findutils-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Findutils-patches] [PATCH 5/9] Translate error messages, mark other str


From: James Youngman
Subject: [Findutils-patches] [PATCH 5/9] Translate error messages, mark other strings as not needing it.
Date: Sat, 9 Jul 2011 23:15:47 +0100

* find/print.c (get_format_flags_length): Mark printf format flags
as not needing translation.
(get_format_specifer_length): Likewise for format specifiers.
(insert_fprintf): Also (unsupported) format specifiers here.
(do_time_format): Mark trivial format strings as not needing
translation.
(format_date): Also here.
(format_date): Translate an error message.
(ctime_format): Weekdays and months are not translated, since we
are following ctime().
(mode_to_filetype): Mark file type letters as not needing
translation.
(do_fprintf): Annotate the name of the current directory as not
needing translation.  Likewise the empty string.
(do_fprintf): Mark file type letters (for the %Y format) as not
needing translation.
---
 ChangeLog    |   18 ++++++++++++++++++
 find/print.c |   57 ++++++++++++++++++++++++++++++---------------------------
 2 files changed, 48 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ae16336..1c00220 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2011-07-09  James Youngman  <address@hidden>
 
+       Translate error messages, mark other strings as not needing it.
+       * find/print.c (get_format_flags_length): Mark printf format flags
+       as not needing translation.
+       (get_format_specifer_length): Likewise for format specifiers.
+       (insert_fprintf): Also (unsupported) format specifiers here.
+       (do_time_format): Mark trivial format strings as not needing
+       translation.
+       (format_date): Also here.
+       (format_date): Translate an error message.
+       (ctime_format): Weekdays and months are not translated, since we
+       are following ctime().
+       (mode_to_filetype): Mark file type letters as not needing
+       translation.
+       (do_fprintf): Annotate the name of the current directory as not
+       needing translation.  Likewise the empty string.
+       (do_fprintf): Mark file type letters (for the %Y format) as not
+       needing translation.
+
        Annotate strings as needing translation or not as appropriate.
        * find/util.c (debugassoc): Translate debug help strings, but not
        the names of the debug options themselves.
diff --git a/find/print.c b/find/print.c
index e307d95..db5952a 100644
--- a/find/print.c
+++ b/find/print.c
@@ -277,7 +277,7 @@ get_format_flags_length(const char *p)
 {
   size_t n = 0;
   /* Scan past flags, width and precision, to verify kind. */
-  for (; p[++n] && strchr ("-+ #", p[n]);)
+  for (; p[++n] && strchr (N_("-+ #"), p[n]);)
     {
       /* Do nothing. */
     }
@@ -292,11 +292,11 @@ get_format_flags_length(const char *p)
 static size_t
 get_format_specifer_length(char ch)
 {
-  if (strchr ("abcdDfFgGhHiklmMnpPsStuUyYZ%", ch))
+  if (strchr (N_("abcdDfFgGhHiklmMnpPsStuUyYZ%"), ch))
     {
       return 1;
     }
-  else if (strchr ("ABCT", ch))
+  else if (strchr (N_("ABCT"), ch))
     {
       return 2;
     }
@@ -397,7 +397,7 @@ insert_fprintf (struct format_val *vec,
            }
          else
            {
-             if (strchr ("{[(", fmt_editpos[0]))
+             if (strchr (N_("{[("), fmt_editpos[0]))
                {
                  error (EXIT_FAILURE, 0,
                         _("error: the format directive `%%%c' is reserved for 
future use"),
@@ -493,7 +493,7 @@ do_time_format (const char *fmt, const struct tm *p, const 
char *ns, size_t ns_s
    * case.
    */
   timefmt = xmalloc (strlen (fmt) + 2u);
-  sprintf (timefmt, "_%s", fmt);
+  sprintf (timefmt, N_("_%s"), fmt);
 
   /* altered_time is a similar time, but in which both
    * digits of the seconds field are different.
@@ -624,7 +624,7 @@ format_date (struct timespec ts, int kind)
   /* Format the main part of the time. */
   if (kind == '+')
     {
-      strcpy (fmt, "%F+%T");
+      strcpy (fmt, N_("%F+%T"));
       need_ns_suffix = 1;
     }
   else
@@ -656,7 +656,8 @@ format_date (struct timespec ts, int kind)
        * The reason for discouraging this is that in the future, the
        * granularity may not be nanoseconds.
        */
-      charsprinted = snprintf (ns_buf, NS_BUF_LEN, ".%09ld0", (long 
int)ts.tv_nsec);
+      charsprinted = snprintf (ns_buf, NS_BUF_LEN, N_(".%09ld0"),
+                              (long int)ts.tv_nsec);
       assert (charsprinted < NS_BUF_LEN);
     }
   else
@@ -709,7 +710,7 @@ format_date (struct timespec ts, int kind)
          if (strlen (ns_buf) >= remaining)
            {
              error (0, 0,
-                    "charsprinted=%ld but remaining=%lu: ns_buf=%s",
+                    _("charsprinted=%ld but remaining=%lu: ns_buf=%s"),
                     (long)charsprinted, (unsigned long)remaining, ns_buf);
            }
          assert (strlen (ns_buf) < remaining);
@@ -751,8 +752,10 @@ ctime_format (struct timespec ts)
       assert (ptm->tm_sec  <= 61); /* allows 2 leap seconds. */
 
       /* wkday mon mday hh:mm:ss.nnnnnnnnn yyyy */
+      /* Weekday/month abbreviations are not translated, since we are
+        following the behaviour of ctime(). */
       nout = snprintf (resultbuf, TIME_BUF_LEN,
-                      "%3s %3s %2d %02d:%02d:%02d.%010ld %04d",
+                      N_("%3s %3s %2d %02d:%02d:%02d.%010ld %04d"),
                       weekdays[ptm->tm_wday],
                       months[ptm->tm_mon],
                       ptm->tm_mday,
@@ -835,30 +838,30 @@ mode_to_filetype (mode_t m)
 {
 #define HANDLE_TYPE(t,letter) if (m==t) { return letter; }
 #ifdef S_IFREG
-  HANDLE_TYPE(S_IFREG,  "f");  /* regular file */
+  HANDLE_TYPE(S_IFREG,  N_("f")); /* regular file */
 #endif
 #ifdef S_IFDIR
-  HANDLE_TYPE(S_IFDIR,  "d");  /* directory */
+  HANDLE_TYPE(S_IFDIR,  N_("d")); /* directory */
 #endif
 #ifdef S_IFLNK
-  HANDLE_TYPE(S_IFLNK,  "l");  /* symbolic link */
+  HANDLE_TYPE(S_IFLNK,  N_("l")); /* symbolic link */
 #endif
 #ifdef S_IFSOCK
-  HANDLE_TYPE(S_IFSOCK, "s");  /* Unix domain socket */
+  HANDLE_TYPE(S_IFSOCK, N_("s")); /* Unix domain socket */
 #endif
 #ifdef S_IFBLK
-  HANDLE_TYPE(S_IFBLK,  "b");  /* block device */
+  HANDLE_TYPE(S_IFBLK,  N_("b")); /* block device */
 #endif
 #ifdef S_IFCHR
-  HANDLE_TYPE(S_IFCHR,  "c");  /* character device */
+  HANDLE_TYPE(S_IFCHR,  N_("c")); /* character device */
 #endif
 #ifdef S_IFIFO
-  HANDLE_TYPE(S_IFIFO,  "p");  /* FIFO */
+  HANDLE_TYPE(S_IFIFO,  N_("p")); /* FIFO */
 #endif
 #ifdef S_IFDOOR
-  HANDLE_TYPE(S_IFDOOR, "D");  /* Door (e.g. on Solaris) */
+  HANDLE_TYPE(S_IFDOOR, N_("D")); /* Door (e.g. on Solaris) */
 #endif
-  return "U";                  /* Unknown */
+  return N_("U");              /* Unknown */
 }
 
 
@@ -964,7 +967,7 @@ do_fprintf (struct format_val *dest,
                 * print the string because it contains characters
                 * other than just '%s'.  The %h expands to ".".
                 */
-               checked_print_quoted (dest, segment->text, ".");
+               checked_print_quoted (dest, segment->text, N_("."));
              }
            else
              {
@@ -1025,7 +1028,7 @@ do_fprintf (struct format_val *dest,
                /* We still need to honour the field width etc., so this is
                 * not a no-op.
                 */
-               checked_print_quoted (dest, segment->text, "");
+               checked_print_quoted (dest, segment->text, N_(""));
              }
            free (linkname);
          }
@@ -1101,7 +1104,7 @@ do_fprintf (struct format_val *dest,
            }
          else
            {
-             cp = "";
+             cp = N_("");
            }
          checked_print_quoted (dest, segment->text, cp);
          break;
@@ -1169,18 +1172,18 @@ do_fprintf (struct format_val *dest,
                  {
                    if ( errno == ENOENT )
                      {
-                       checked_fprintf (dest, segment->text, "N");
+                       checked_fprintf (dest, segment->text, N_("N"));
                        break;
                      }
                    else if ( errno == ELOOP )
                      {
-                       checked_fprintf (dest, segment->text, "L");
+                       checked_fprintf (dest, segment->text, N_("L"));
                        break;
                      }
                    else
                      {
-                       checked_fprintf (dest, segment->text, "?");
-                       error (0, errno, "%s",
+                       checked_fprintf (dest, segment->text, N_("?"));
+                       error (0, errno, N_("%s"),
                               safely_quote_err_filename (0, pathname));
                        /* exit_status = 1;
                           return ; */
@@ -1217,7 +1220,7 @@ do_fprintf (struct format_val *dest,
                /* If getfilecon fails, there will in the general case
                   still be some text to print.   We just make %Z expand
                   to an empty string. */
-               checked_fprintf (dest, segment->text, "");
+               checked_fprintf (dest, segment->text, N_(""));
 
                error (0, errno, _("getfilecon failed: %s"),
                    safely_quote_err_filename (0, pathname));
@@ -1297,7 +1300,7 @@ pred_fprintf (const char *pathname, struct stat 
*stat_buf, struct predicate *pre
               * "[] foo").
               */
              /* trusted */
-             checked_fprintf (dest, segment->text, "");
+             checked_fprintf (dest, segment->text, N_(""));
            }
        }
       else
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]