[glom] test_document_export_po: Use msgfmt -c to test the exported .po file.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] test_document_export_po: Use msgfmt -c to test the exported .po file.
- Date: Sun, 8 Jan 2012 22:36:56 +0000 (UTC)
commit 24b66137c94b7d4f44e128b55b33a8c5cb9f2157
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Jan 8 23:36:50 2012 +0100
test_document_export_po: Use msgfmt -c to test the exported .po file.
* configure.ac: Get the path for msgfmt.
* tests/translations_po/test_document_export_po.cc: Use msgfmt -c to
check the new .po file.
ChangeLog | 8 ++++
configure.ac | 5 +++
glom/glom_export_po.cc | 1 -
glom/libglom/filelist.am | 2 +-
tests/translations_po/test_document_export_po.cc | 40 +++++++++++++++++++++-
5 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 61f91f5..2fcadad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2012-01-08 Murray Cumming <murrayc murrayc com>
+ test_document_export_po: Use msgfmt -c to test the exported .po file.
+
+ * configure.ac: Get the path for msgfmt.
+ * tests/translations_po/test_document_export_po.cc: Use msgfmt -c to
+ check the new .po file.
+
+2012-01-08 Murray Cumming <murrayc murrayc com>
+
glom_export_po: Let the user choose the locale ID.
* glom/glom_export_po.cc: Add, and use, a --locale-id (-l) option
diff --git a/configure.ac b/configure.ac
index 736fef5..140a26e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -270,6 +270,11 @@ AC_CHECK_PROG([GLOM_GZIP], [gzip], [yes], [no])
AS_IF([test "$GLOM_GZIP" = no],
[AC_MSG_ERROR([gzip not found. Glom needs this to create backup files.])])
+AC_PATH_PROG([GLOM_MSGFMT], [msgfmt], [no])
+AS_IF([test "$GLOM_MSGFMT" = no],
+ [AC_MSG_ERROR([msgfmt not found. Glom needs this to test exported .po (gettext) files.])])
+AC_DEFINE_UNQUOTED([GLOM_MSGFMT], ["$GLOM_MSGFMT"],
+ [Define to the location of the msgfmt gettext utility.])
# Code testing coverage with gcov
AC_MSG_CHECKING(whether to build with gcov testing)
diff --git a/glom/glom_export_po.cc b/glom/glom_export_po.cc
index 1e17266..487f492 100644
--- a/glom/glom_export_po.cc
+++ b/glom/glom_export_po.cc
@@ -55,7 +55,6 @@ GlomCreateOptionGroup::GlomCreateOptionGroup()
entry.set_description(_("The path at which to save the created .po file, such as /home/someuser/somefile.po ."));
add_entry_filename(entry, m_arg_filepath_output);
- entry;
entry.set_long_name("locale-id");
entry.set_short_name('l');
entry.set_description(_("The locale whose translations should be written to the .po file, such as de_DE."));
diff --git a/glom/libglom/filelist.am b/glom/libglom/filelist.am
index 3ecc651..16298f2 100644
--- a/glom/libglom/filelist.am
+++ b/glom/libglom/filelist.am
@@ -121,7 +121,7 @@ libglom_sources = \
glom/libglom/xsl_utils.h \
glom/libglom/connectionpool_backends/backend.cc \
glom/libglom/connectionpool_backends/backend.h \
- glom/libglom/data_structure/choicevalue.cc \
+ glom/libglom/data_structure/choicevalue.cc \
glom/libglom/data_structure/field.cc \
glom/libglom/data_structure/fieldtypes.cc \
glom/libglom/data_structure/foundset.cc \
diff --git a/tests/translations_po/test_document_export_po.cc b/tests/translations_po/test_document_export_po.cc
index fd60105..b6c0bb3 100644
--- a/tests/translations_po/test_document_export_po.cc
+++ b/tests/translations_po/test_document_export_po.cc
@@ -18,6 +18,8 @@
* Boston, MA 02111-1307, USA.
*/
+#include <config.h> //For GLOM_MSGFMT
+
#include <libglom/document/document.h>
#include <libglom/translations_po.h>
#include <libglom/init.h>
@@ -26,10 +28,42 @@
#include <glibmm/convert.h>
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
+#include <glibmm/shell.h>
+#include <glibmm/spawn.h>
#include <iostream>
-
+static bool check_po_file(const std::string& filepath)
+{
+ if(filepath.empty())
+ return false;
+
+ //We could use the gettext-po po_file_check_all() function to check
+ //the file, but the gettext-po error handling is very awkward,
+ //so let's keep it simple:
+ int return_status = EXIT_FAILURE;
+ std::string stdout_output;
+ const Glib::ustring command = Glib::ustring::compose(GLOM_MSGFMT " %1",
+ Glib::shell_quote(filepath));
+ try
+ {
+ Glib::spawn_command_line_sync(command, &stdout_output, 0, &return_status);
+ //std::cout << " debug: output=" << stdout_output << std::endl;
+ }
+ catch(const Glib::Error& ex)
+ {
+ std::cerr << "Exception caught: " << ex.what() << std::endl;
+ }
+
+ if(return_status != EXIT_SUCCESS)
+ {
+ std::cout << stdout_output << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
int main()
{
Glom::libglom_init();
@@ -112,6 +146,10 @@ int main()
(data.find("Stabliste") != std::string::npos);
g_assert(text_found);
+
+ //Check that the .po file is valid:
+ check_po_file(po_file_path);
+
//TODO: Remove po_file_uri
Glom::libglom_deinit();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]