[glom/glom-1-20] Command-line utilities: Initialize gettext and the locale.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-20] Command-line utilities: Initialize gettext and the locale.
- Date: Tue, 10 Jan 2012 19:59:38 +0000 (UTC)
commit a75477422f0b045537caf94bcd44a8909e00889e
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Jan 9 11:23:12 2012 +0100
Command-line utilities: Initialize gettext and the locale.
* glom/glom_create_from_example.cc:
* glom/glom_test_connection.cc: This should make the translations be used.
Conflicts:
ChangeLog
glom/glom_export_po.cc
glom/glom_export_po_all.cc
ChangeLog | 7 +++++++
glom/glom_create_from_example.cc | 23 +++++++++++++++++++++++
glom/glom_test_connection.cc | 23 +++++++++++++++++++++++
3 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3fb8dd7..10746dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-01-09 Murray Cumming <murrayc murrayc com>
+
+ Command-line utilities: Initialize gettext and the locale.
+
+ * glom/glom_create_from_example.cc:
+ * glom/glom_test_connection.cc: This should make the translations be used.
+
2012-01-07 Murray Cumming <murrayc murrayc com>
test_document_load: Fix a typo.
diff --git a/glom/glom_create_from_example.cc b/glom/glom_create_from_example.cc
index b74af81..cc69008 100644
--- a/glom/glom_create_from_example.cc
+++ b/glom/glom_create_from_example.cc
@@ -36,6 +36,7 @@
#include <glibmm/convert.h>
#include <glibmm/miscutils.h>
#include <iostream>
+#include <stdexcept>
#include <glibmm/i18n.h>
@@ -200,6 +201,28 @@ static void cleanup()
int main(int argc, char* argv[])
{
+ bindtextdomain(GETTEXT_PACKAGE, GLOM_LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+
+ // Set the locale for any streams to the user's current locale,
+ // We should not rely on the default locale of
+ // any streams (we should always do an explicit imbue()),
+ // but this is maybe a good default in case we forget.
+ try
+ {
+ std::locale::global(std::locale(""));
+ }
+ catch(const std::runtime_error& ex)
+ {
+ //This has been known to throw an exception at least once:
+ //https://bugzilla.gnome.org/show_bug.cgi?id=619445
+ //This should tell us what the problem is:
+ std::cerr << G_STRFUNC << ": exception from std::locale::global(std::locale(\"\")): " << ex.what() << std::endl;
+ std::cerr << " This can happen if the locale is not properly installed or configured." << std::endl;
+ }
+
+
Glom::libglom_init();
Glib::OptionContext context;
diff --git a/glom/glom_test_connection.cc b/glom/glom_test_connection.cc
index 1603427..dadd725 100644
--- a/glom/glom_test_connection.cc
+++ b/glom/glom_test_connection.cc
@@ -32,6 +32,7 @@
#include <glibmm/optioncontext.h>
#include <glibmm/convert.h>
#include <iostream>
+#include <stdexcept>
#include <glibmm/i18n.h>
@@ -93,6 +94,28 @@ static void print_options_hint()
int main(int argc, char* argv[])
{
+ bindtextdomain(GETTEXT_PACKAGE, GLOM_LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+
+ // Set the locale for any streams to the user's current locale,
+ // We should not rely on the default locale of
+ // any streams (we should always do an explicit imbue()),
+ // but this is maybe a good default in case we forget.
+ try
+ {
+ std::locale::global(std::locale(""));
+ }
+ catch(const std::runtime_error& ex)
+ {
+ //This has been known to throw an exception at least once:
+ //https://bugzilla.gnome.org/show_bug.cgi?id=619445
+ //This should tell us what the problem is:
+ std::cerr << G_STRFUNC << ": exception from std::locale::global(std::locale(\"\")): " << ex.what() << std::endl;
+ std::cerr << " This can happen if the locale is not properly installed or configured." << std::endl;
+ }
+
+
Glom::libglom_init();
Glib::OptionContext context;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]