findutils-patches
[Top][All Lists]
Advanced

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

[Findutils-patches] [PATCH 4/9] Annotate strings as needing translation


From: James Youngman
Subject: [Findutils-patches] [PATCH 4/9] Annotate strings as needing translation or not as appropriate.
Date: Sat, 9 Jul 2011 23:15:46 +0100

* find/util.c (debugassoc): Translate debug help strings, but not
the names of the debug options themselves.
(show_valid_debug_options): Translate help messages.
(show_valid_debug_options): Mark debug output as not needing
translation (where it contains no text as such).
(check_nofollow): Mark kernel names (Linux and FreeBSD) that we
match against what we find in the result of uname() as not needing
translation.
(fd_leak_check_is_enabled): Mark environment variable names as not
needing translation.
(set_option_defaults): Likewise.
(cleanup): Translate the human-readable name for stdout.
(fallback_stat): Translate an error message and use error() to
issue it, rather than fprintf.
(debug_stat): Annotate a debug string as not needing translation.
(process_debug_options): Mark the list of delimiter characters as
not needing translation.
(process_leading_options): Likewise with option names.
(report_file_err): Mark trivial format strings as not needing
translation.
---
 ChangeLog   |   22 +++++++++++++++++++
 NEWS        |    3 +-
 find/util.c |   66 ++++++++++++++++++++++++++++++++++-------------------------
 3 files changed, 62 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1c474aa..ae16336 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2011-07-09  James Youngman  <address@hidden>
 
+       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.
+       (show_valid_debug_options): Translate help messages.
+       (show_valid_debug_options): Mark debug output as not needing
+       translation (where it contains no text as such).
+       (check_nofollow): Mark kernel names (Linux and FreeBSD) that we
+       match against what we find in the result of uname() as not needing
+       translation.
+       (fd_leak_check_is_enabled): Mark environment variable names as not
+       needing translation.
+       (set_option_defaults): Likewise.
+       (cleanup): Translate the human-readable name for stdout.
+       (fallback_stat): Translate an error message and use error() to
+       issue it, rather than fprintf.
+       (debug_stat): Annotate a debug string as not needing translation.
+       (process_debug_options): Mark the list of delimiter characters as
+       not needing translation.
+       (process_leading_options): Likewise with option names.
+       (report_file_err): Mark trivial format strings as not needing
+       translation.
+
        Indicate predicates and debug strings don't need translation.
        * find/tree.c (matches_start_point): Don't translate the name of
        the current directory.
diff --git a/NEWS b/NEWS
index 2a019d8..f7926c3 100644
--- a/NEWS
+++ b/NEWS
@@ -56,7 +56,8 @@ with implementations which have duplicate entries (for example
 The file system type names "afs" and "unknown" are now always
 untranslated strings.  This means that a find command lines like "find
 . -fstype unknown" and "find . -fstype afs" will work as-is in a
-variety of locales, instead of just the C locale.
+variety of locales, instead of just the C locale.  The help strings
+for debug ("find -D") options are now marked as needing translation.
 
 * Major changes in release 4.5.10, 2011-05-11
 
diff --git a/find/util.c b/find/util.c
index 94e9549..175b40e 100644
--- a/find/util.c
+++ b/find/util.c
@@ -68,13 +68,13 @@ struct debug_option_assoc
 };
 static struct debug_option_assoc debugassoc[] =
   {
-    { "help", DebugHelp, "Explain the various -D options" },
-    { "tree", DebugExpressionTree, "Display the expression tree" },
-    { "search",DebugSearch, "Navigate the directory tree verbosely" },
-    { "stat", DebugStat, "Trace calls to stat(2) and lstat(2)" },
-    { "rates", DebugSuccessRates, "Indicate how often each predicate 
succeeded" },
-    { "opt",  DebugExpressionTree|DebugTreeOpt, "Show diagnostic information 
relating to optimisation" },
-    { "exec", DebugExec,  "Show diagnostic information relating to -exec, 
-execdir, -ok and -okdir" }
+    { N_("help"),  DebugHelp, "Explain the various -D options"},
+    { N_("tree"),  DebugExpressionTree, "Display the expression tree"},
+    { N_("search"),DebugSearch, "Navigate the directory tree verbosely"},
+    { N_("stat"),  DebugStat, "Trace calls to stat(2) and lstat(2)"},
+    { N_("rates"), DebugSuccessRates, "Indicate how often each predicate 
succeeded"},
+    { N_("opt"),   DebugExpressionTree|DebugTreeOpt, "Show diagnostic 
information relating to optimisation"},
+    { N_("exec"),  DebugExec,  "Show diagnostic information relating to -exec, 
-execdir, -ok and -okdir"}
   };
 #define N_DEBUGASSOC (sizeof(debugassoc)/sizeof(debugassoc[0]))
 
@@ -149,19 +149,27 @@ show_valid_debug_options (FILE *fp, int full)
   int i;
   if (full)
     {
-      fprintf (fp, "Valid arguments for -D:\n");
+      fprintf (fp, _("Valid arguments for -D:\n"));
       for (i=0; i<N_DEBUGASSOC; ++i)
        {
-         fprintf (fp, "%-10s %s\n",
+         /* The format string does not need translation, since the
+            only thing to adjust in there is the width of the
+            left-hand column, and the left-hand column only contains
+            untranslated strings.
+
+            However, the docstring itself does need to be translated.
+         */
+         const char *translated_docstring = _(debugassoc[i].docstring);
+         fprintf (fp, N_("%-10s %s\n"),
                   debugassoc[i].name,
-                  debugassoc[i].docstring);
+                  translated_docstring);
        }
     }
   else
     {
       for (i=0; i<N_DEBUGASSOC; ++i)
        {
-         fprintf (fp, "%s%s", (i>0 ? "|" : ""), debugassoc[i].name);
+         fprintf (fp, N_("%s%s"), (i>0 ? "|" : ""), debugassoc[i].name);
        }
     }
 }
@@ -170,7 +178,7 @@ void
 usage (FILE *fp, int status, char *msg)
 {
   if (msg)
-    fprintf (fp, "%s: %s\n", program_name, msg);
+    fprintf (fp, N_("%s: %s\n"), program_name, msg);
 
   fprintf (fp, _("Usage: %s [-H] [-L] [-P] [-Olevel] [-D "), program_name);
   show_valid_debug_options (fp, 0);
@@ -323,12 +331,12 @@ check_nofollow (void)
       double (*conversion)(const char*) = atof;  /* avoid 
sc_prohibit_atoi_atof check. */
       release = conversion (uts.release);
 
-      if (0 == strcmp ("Linux", uts.sysname))
+      if (0 == strcmp (N_("Linux"), uts.sysname))
        {
          /* Linux kernels 2.1.126 and earlier ignore the O_NOFOLLOW flag. */
          return release >= 2.2; /* close enough */
        }
-      else if (0 == strcmp ("FreeBSD", uts.sysname))
+      else if (0 == strcmp (N_("FreeBSD"), uts.sysname))
        {
          /* FreeBSD 3.0-CURRENT and later support it */
          return release >= 3.1;
@@ -510,7 +518,7 @@ undangle_file_pointers (struct predicate *p)
 bool
 fd_leak_check_is_enabled (void)
 {
-  if (getenv ("GNU_FINDUTILS_FD_LEAK_CHECK"))
+  if (getenv (N_("GNU_FINDUTILS_FD_LEAK_CHECK")))
     return true;
   else
     return false;
@@ -544,7 +552,7 @@ cleanup (void)
     }
 
   if (fflush (stdout) == EOF)
-    nonfatal_nontarget_file_error (errno, "standard output");
+    nonfatal_nontarget_file_error (errno, _("standard output"));
 }
 
 
@@ -560,7 +568,8 @@ fallback_stat (const char *name, struct stat *p, int 
prev_rv)
     case ENOENT:
     case ENOTDIR:
       if (options.debug_options & DebugStat)
-       fprintf(stderr, "fallback_stat(): stat(%s) failed; falling back on 
lstat()\n", name);
+       error (0, 0, _("fallback_stat(): stat(%s) failed; falling back on 
lstat()\n"),
+              name);
       return fstatat(state.cwd_dir_fd, name, p, AT_SYMLINK_NOFOLLOW);
 
     case EACCES:
@@ -650,7 +659,7 @@ int
 debug_stat (const char *file, struct stat *bufp)
 {
   ++stat_count;
-  fprintf (stderr, "debug_stat (%s)\n", file);
+  fprintf (stderr, N_("debug_stat (%s)\n"), file);
 
   switch (options.symlink_handling)
     {
@@ -798,7 +807,7 @@ process_debug_options (char *arg)
 {
   const char *p;
   char *token_context = NULL;
-  const char delimiters[] = ",";
+  const char delimiters[] = N_(",");
   bool empty = true;
   size_t i;
 
@@ -900,33 +909,33 @@ process_leading_options (int argc, char *argv[])
 
   for (i=1; (end_of_leading_options = i) < argc; ++i)
     {
-      if (0 == strcmp ("-H", argv[i]))
+      if (0 == strcmp (N_("-H"), argv[i]))
        {
          /* Meaning: dereference symbolic links on command line, but nowhere 
else. */
          set_follow_state (SYMLINK_DEREF_ARGSONLY);
        }
-      else if (0 == strcmp ("-L", argv[i]))
+      else if (0 == strcmp (N_("-L"), argv[i]))
        {
          /* Meaning: dereference all symbolic links. */
          set_follow_state (SYMLINK_ALWAYS_DEREF);
        }
-      else if (0 == strcmp ("-P", argv[i]))
+      else if (0 == strcmp (N_("-P"), argv[i]))
        {
          /* Meaning: never dereference symbolic links (default). */
          set_follow_state (SYMLINK_NEVER_DEREF);
        }
-      else if (0 == strcmp ("--", argv[i]))
+      else if (0 == strcmp (N_("--"), argv[i]))
        {
          /* -- signifies the end of options. */
          end_of_leading_options = i+1; /* Next time start with the next option 
*/
          break;
        }
-      else if (0 == strcmp ("-D", argv[i]))
+      else if (0 == strcmp (N_("-D"), argv[i]))
        {
          process_debug_options (argv[i+1]);
          ++i;                  /* skip the argument too. */
        }
-      else if (0 == strncmp ("-O", argv[i], 2))
+      else if (0 == strncmp (N_("-O"), argv[i], 2))
        {
          process_optimisation_option (argv[i]+2);
        }
@@ -966,7 +975,7 @@ now(void)
 void
 set_option_defaults (struct options *p)
 {
-  if (getenv ("POSIXLY_CORRECT"))
+  if (getenv (N_("POSIXLY_CORRECT")))
     p->posixly_correct = true;
   else
     p->posixly_correct = false;
@@ -1020,7 +1029,7 @@ set_option_defaults (struct options *p)
   p->debug_options = 0uL;
   p->optimisation_level = 2;
 
-  if (getenv ("FIND_BLOCK_SIZE"))
+  if (getenv (N_("FIND_BLOCK_SIZE")))
     {
       error (EXIT_FAILURE, 0,
             _("The environment variable FIND_BLOCK_SIZE is not supported, the 
only thing that affects the block size is the POSIXLY_CORRECT environment 
variable"));
@@ -1109,7 +1118,8 @@ report_file_err(int exitval, int errno_value,
    */
   if (!is_target_file || !state.already_issued_stat_error_msg)
     {
-      error (exitval, errno_value, "%s", safely_quote_err_filename (0, name));
+      error (exitval, errno_value, N_("%s"),
+            safely_quote_err_filename (0, name));
       error_severity (1);
     }
   if (is_target_file)
-- 
1.7.2.5




reply via email to

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