[gtranslator] Check po file on save



commit a262f63c76411ef063dea6f86811de8c97b27db7
Author: Daniel GarcĂ­a Moreno <danigm wadobo com>
Date:   Mon Oct 15 10:10:24 2018 +0200

    Check po file on save
    
    Currently if there's some error a warning is shown, but we don't know
    where is the problem. We should parse the error and mark all wrong
    messages as wrong or something like that.
    
    See #5

 src/gtr-po.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/src/gtr-po.c b/src/gtr-po.c
index ac4fa21c..8a396a6b 100644
--- a/src/gtr-po.c
+++ b/src/gtr-po.c
@@ -740,6 +740,7 @@ gtr_po_save_file (GtrPo * po, GError ** error)
 {
   struct po_xerror_handler handler;
   gchar *filename;
+  gchar *msg_error;
   GtrHeader *header;
   GtrPoPrivate *priv = gtr_po_get_instance_private (po);
 
@@ -777,25 +778,25 @@ gtr_po_save_file (GtrPo * po, GError ** error)
       return;
     }
 
+  /* Save header fields into msg */
+  header = gtr_po_get_header (po);
+  gtr_header_update_header (header);
 
   /*
    * Check if the file is right
    */
-  /*msg_error = gtr_po_check_po_file (po);
-     if (msg_error != NULL)
-     {
-     g_set_error (error,
-     GTR_PO_ERROR,
-     GTR_PO_ERROR_GETTEXT,
-     _("There is an error in the PO file: %s"),
-     msg_error);
-     g_free (msg_error);
-     } */
-
-
-  /* Save header fields into msg */
-  header = gtr_po_get_header (po);
-  gtr_header_update_header (header);
+  msg_error = gtr_po_check_po_file (po);
+  if (msg_error != NULL)
+    {
+      g_set_error (error,
+                   GTR_PO_ERROR,
+                   GTR_PO_ERROR_GETTEXT,
+                   _("There is an error in the PO file: %s"),
+                   msg_error);
+      g_free (msg_error);
+      g_free (filename);
+      return;
+    }
 
   if (!po_file_write (gtr_po_get_po_file (po), filename, &handler))
     {
@@ -1318,6 +1319,7 @@ gtr_po_check_po_file (GtrPo * po)
   handler.xerror2 = &on_gettext_po_xerror2;
   message_error = NULL;
 
+  //TODO: handle error and mark wrong msgids
   po_file_check_all (priv->gettext_po_file, &handler);
 
   return message_error;


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