]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgcat, msgen, xgettext: Tweak processing order.
authorBruno Haible <bruno@clisp.org>
Thu, 3 Jul 2025 16:56:11 +0000 (18:56 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 3 Jul 2025 16:56:11 +0000 (18:56 +0200)
* gettext-tools/src/msgcat.c (main): Sort the list of messages as the last
processing step before writing the PO file.
* gettext-tools/src/msgen.c (main): Likewise.
* gettext-tools/src/xgettext.c (main): Likewise.

gettext-tools/src/msgcat.c
gettext-tools/src/msgen.c
gettext-tools/src/xgettext.c

index d438e99ea537a54a5ea5f8f68ce6c544e85ee362..de5b2aa7d41e42c811c50d9e40a730a8bacb6ce6 100644 (file)
@@ -340,16 +340,16 @@ There is NO WARRANTY, to the extent permitted by law.\n\
 
   string_list_free (file_list);
 
+  /* Set the Language field in the header.  */
+  if (catalogname != NULL)
+    msgdomain_list_set_header_field (result, "Language:", catalogname);
+
   /* Sorting the list of messages.  */
   if (sort_by_filepos)
     msgdomain_list_sort_by_filepos (result);
   else if (sort_by_msgid)
     msgdomain_list_sort_by_msgid (result);
 
-  /* Set the Language field in the header.  */
-  if (catalogname != NULL)
-    msgdomain_list_set_header_field (result, "Language:", catalogname);
-
   /* Write the PO file.  */
   msgdomain_list_print (result, output_file, output_syntax,
                         textmode_xerror_handler, force_po, false);
index f9d9b20a6c10ad8514d2a6651f25f38844b4969c..9fc6a36507caa9e6833151a4d7feb8f18c97cb0f 100644 (file)
@@ -284,16 +284,16 @@ There is NO WARRANTY, to the extent permitted by law.\n\
   /* Add English translations.  */
   result = msgdomain_list_english (result);
 
+  /* Set the Language field in the header.  */
+  if (catalogname != NULL)
+    msgdomain_list_set_header_field (result, "Language:", catalogname);
+
   /* Sort the results.  */
   if (sort_by_filepos)
     msgdomain_list_sort_by_filepos (result);
   else if (sort_by_msgid)
     msgdomain_list_sort_by_msgid (result);
 
-  /* Set the Language field in the header.  */
-  if (catalogname != NULL)
-    msgdomain_list_set_header_field (result, "Language:", catalogname);
-
   /* Write the merged message list out.  */
   msgdomain_list_print (result, output_file, output_syntax,
                         textmode_xerror_handler, force_po, false);
index e21813a08fa8fdbaa139b41ee46af592dfa7fe32..11a5c7c88eff5b236e68dad6a8aebaef5eb6fc8e 100644 (file)
@@ -1091,12 +1091,6 @@ xgettext cannot work without keywords to look for"));
     iconv_close (xgettext_global_source_iconv);
 #endif
 
-  /* Sorting the list of messages.  */
-  if (sort_by_filepos)
-    msgdomain_list_sort_by_filepos (mdlp);
-  else if (sort_by_msgid)
-    msgdomain_list_sort_by_msgid (mdlp);
-
   /* Check msgid and msgid_plural of messages.  */
   {
     int nerrors = 0;
@@ -1115,6 +1109,12 @@ xgettext cannot work without keywords to look for"));
              nerrors);
   }
 
+  /* Sorting the list of messages.  */
+  if (sort_by_filepos)
+    msgdomain_list_sort_by_filepos (mdlp);
+  else if (sort_by_msgid)
+    msgdomain_list_sort_by_msgid (mdlp);
+
   /* Write the PO file.  */
   msgdomain_list_print (mdlp, file_name, output_syntax, textmode_xerror_handler,
                         force_po, do_debug);