[glom] glom_export_po: Let the user choose the locale ID.



commit 20a36f0bc899b1af129cfdc405fc7c129e94cb93
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Jan 8 23:03:01 2012 +0100

    glom_export_po: Let the user choose the locale ID.
    
    * glom/glom_export_po.cc: Add, and use, a --locale-id (-l) option
    instead of just hard-coding de_DE.

 ChangeLog              |    7 +++++++
 glom/glom_export_po.cc |   16 +++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b4ad77b..61f91f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 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
+	instead of just hard-coding de_DE.
+
+2012-01-08  Murray Cumming  <murrayc murrayc com>
+
 	Export to po file: Write a po file header.
 
 	* glom/libglom/translations_po.[h|cc]: write_translations_to_po_file():
diff --git a/glom/glom_export_po.cc b/glom/glom_export_po.cc
index 06443a3..1e17266 100644
--- a/glom/glom_export_po.cc
+++ b/glom/glom_export_po.cc
@@ -41,6 +41,7 @@ public:
   //These instances should live as long as the OptionGroup to which they are added,
   //and as long as the OptionContext to which those OptionGroups are added.
   std::string m_arg_filepath_output;
+  Glib::ustring m_arg_locale_id;
   bool m_arg_version;
 };
 
@@ -53,6 +54,12 @@ GlomCreateOptionGroup::GlomCreateOptionGroup()
   entry.set_short_name('o');
   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."));
+  add_entry(entry, m_arg_locale_id);
   
   entry.set_long_name("version");
   entry.set_short_name('V');
@@ -108,6 +115,13 @@ int main(int argc, char* argv[])
     std::cerr << std::endl << context.get_help() << std::endl;
     return EXIT_FAILURE;
   }
+
+  if(group.m_arg_locale_id.empty())
+  {
+    std::cerr << "Please specify a locale ID." << std::endl;
+    std::cerr << std::endl << context.get_help() << std::endl;
+    return EXIT_FAILURE;
+  }
   
   //Get a URI (file://something) from the filepath:
   Glib::RefPtr<Gio::File> file_input = Gio::File::create_for_commandline_arg(input_uri);
@@ -168,7 +182,7 @@ int main(int argc, char* argv[])
   }
 
   const bool succeeded = 
-    Glom::write_translations_to_po_file(&document, ouput_uri, "de_DE");
+    Glom::write_translations_to_po_file(&document, ouput_uri, group.m_arg_locale_id);
   if(!succeeded)
   {
     std::cerr << "Po file creation failed." << std::endl;



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