]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add --previous option.
authorPavel Kharitonov <ineiev@gnu.org>
Mon, 20 May 2013 14:24:12 +0000 (10:24 -0400)
committerDaiki Ueno <ueno@gnu.org>
Tue, 21 May 2013 01:58:09 +0000 (10:58 +0900)
ChangeLog
NEWS
gettext-tools/doc/ChangeLog
gettext-tools/doc/msgattrib.texi
gettext-tools/src/ChangeLog
gettext-tools/src/msgattrib.c

index 247a12b64b3e11a106513d0659c0324d62bfdcdd..22e1dc675b57fc37fe945318c24ffe4d6e075177 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-05-20  Pavel Kharitonov  <ineiev@gnu.org>  (tiny change)
+
+       Add --previous option to msgattrib.
+       * NEWS: Mention --previous msgattrib option.
+
 2013-05-13  Daiki Ueno  <ueno@gnu.org>
 
        Fix bootstrap error on Mac OS X.
diff --git a/NEWS b/NEWS
index 20a8d4ca80b5c7716ef150053bff9b6774b5ad58..de2b61d4394719965c9a1799b12b8a43e9cd8fcf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,9 @@ Version 0.18.3 - unreleased
     xgettext and msgfmt's format string checking now recognize Python
     format string in braced syntax (PEP 3101).
 
+* msgattrib now has --previous option to keep previous msgid when
+  making messages fuzzy, similar to msgmerge --previous.
+
 \f
 Version 0.18.2 - December 2012
 
index 5cf3278b94bf86ee8c38f4c1cd60968c179f71c8..e5e75291697ae47d2ee8a48f2bb54f88609a19ec 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-20  Pavel Kharitonov  <ineiev@gnu.org>  (tiny change)
+
+       Add --previous option to msgattrib.
+       * msgattrib.texi: Document --previous.
+
 2013-04-26  Daiki Ueno  <ueno@gnu.org>
 
        Support for Python brace format.
index 39fe7eebd59227f0dea9cf8f7027ad4121e17b25..0f2749be5b6fac35cfb7fe8d11ba19104a251e5b 100644 (file)
@@ -122,6 +122,17 @@ Set all messages obsolete.
 @opindex --clear-obsolete@r{, @code{msgattrib} option}
 Set all messages non-obsolete.
 
+@item --previous
+@opindex --previous@r{, @code{msgattrib} option}
+When setting
+@ifhtml
+‘fuzzy’
+@end ifhtml
+@ifnothtml
+`fuzzy'
+@end ifnothtml
+mark, keep ``previous msgid'' of translated messages.
+
 @item --clear-previous
 @opindex --clear-previous@r{, @code{msgattrib} option}
 Remove the ``previous msgid'' (@samp{#|}) comments from all messages.
index d329dfc0ca74dcebf59c61e17d574a3294ce0dfe..42fc54d6eeab0f684bc1691037e912d7e0599f67 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-20  Pavel Kharitonov  <ineiev@gnu.org>  (tiny change)
+
+       Add --previous option to msgattrib.
+       * msgattrib.c (long_options, main, process_message_list):
+       (usage): Add --previous option.
+
 2013-05-12  Daiki Ueno  <ueno@gnu.org>
 
        Fix end-of-string handling in JavaScript scanner.
index 75a9785257a2cf0cf423963a4e85dc2aa397f839..77323156329c418a2e6410fdc7577672316b93b8 100644 (file)
@@ -44,6 +44,7 @@
 #include "write-stringtable.h"
 #include "color.h"
 #include "propername.h"
+#include "xalloc.h"
 #include "gettext.h"
 
 #define _(str) gettext (str)
@@ -71,7 +72,8 @@ enum
   RESET_FUZZY           = 1 << 1,
   SET_OBSOLETE          = 1 << 2,
   RESET_OBSOLETE        = 1 << 3,
-  REMOVE_PREV           = 1 << 4
+  REMOVE_PREV           = 1 << 4,
+  ADD_PREV              = 1 << 5
 };
 static int to_change;
 
@@ -100,6 +102,7 @@ static const struct option long_options[] =
   { "only-fuzzy", no_argument, NULL, CHAR_MAX + 4 },
   { "only-obsolete", no_argument, NULL, CHAR_MAX + 6 },
   { "output-file", required_argument, NULL, 'o' },
+  { "previous", no_argument, NULL, CHAR_MAX + 21 },
   { "properties-input", no_argument, NULL, 'P' },
   { "properties-output", no_argument, NULL, 'p' },
   { "set-fuzzy", no_argument, NULL, CHAR_MAX + 7 },
@@ -324,6 +327,10 @@ main (int argc, char **argv)
         handle_style_option (optarg);
         break;
 
+      case CHAR_MAX + 21: /* --previous */
+        to_change |= ADD_PREV;
+        break;
+
       default:
         usage (EXIT_FAILURE);
         /* NOTREACHED */
@@ -459,6 +466,9 @@ Attribute manipulation:\n"));
       printf (_("\
       --clear-obsolete        set all messages non-obsolete\n"));
       printf (_("\
+      --previous              when setting 'fuzzy', keep previous msgids\n\
+                              of translated messages.\n"));
+      printf (_("\
       --clear-previous        remove the \"previous msgid\" from all messages\n"));
       printf (_("\
       --only-file=FILE.po     manipulate only entries listed in FILE.po\n"));
@@ -587,7 +597,22 @@ process_message_list (message_list_ty *mlp,
                   : true))
             {
               if (to_change & SET_FUZZY)
-                mp->is_fuzzy = true;
+                {
+                  if ((to_change & ADD_PREV) && !is_header (mp)
+                      && !mp->is_fuzzy && mp->msgstr[0] != '\0')
+                    {
+                      mp->prev_msgctxt =
+                        (mp->msgctxt != NULL ? xstrdup (mp->msgctxt) : NULL);
+                      mp->prev_msgid =
+                        (mp->msgid != NULL ? xstrdup (mp->msgid) : NULL);
+                      mp->prev_msgid_plural =
+                        (mp->msgid_plural != NULL
+                         ? xstrdup (mp->msgid_plural)
+                         : NULL);
+                    }
+                  mp->is_fuzzy = true;
+                }
+
               if (to_change & RESET_FUZZY)
                 mp->is_fuzzy = false;
               /* Always keep the header entry non-obsolete.  */