[libpeas/wip/chergert/fix-i18n: 2/2] demo: setup gettext during startup



commit 75838845ee4c868b3c9db1f596c37ba122979147
Author: Christian Hergert <chergert redhat com>
Date:   Sun Jan 19 17:23:02 2020 -0800

    demo: setup gettext during startup
    
    The peas-demo app needs to call setlocale(), bind_textdomain_codeset(),
    and textdomain() like a normal application to improve testing of
    translations.
    
    Related !24
    
    Fixes #35

 peas-demo/peas-demo.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/peas-demo/peas-demo.c b/peas-demo/peas-demo.c
index 1ac08c6..47ac005 100644
--- a/peas-demo/peas-demo.c
+++ b/peas-demo/peas-demo.c
@@ -106,6 +106,15 @@ main (int    argc,
   gchar *plugin_dir;
   PeasEngine *engine;
 
+  setlocale (LC_ALL, "");
+  /* Normally, we'd need to call bindtextdomain() here. But that would require
+   * access to the dynamic peas_dirs_get_locale_dir() which is not available
+   * via the ABI. However, libpeas has a static constructor for it so we do
+   * not need to call it anyway.
+   */
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
   option_context = g_option_context_new (_("— libpeas demo application"));
   g_option_context_add_main_entries (option_context, demo_args, GETTEXT_PACKAGE);
   g_option_context_add_group (option_context, gtk_get_option_group (TRUE));


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