[tepl] init: init i18n
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] init: init i18n
- Date: Fri, 8 May 2020 15:02:07 +0000 (UTC)
commit a5d3c46102e0ac2101cbf6d61279a0df60e08ad0
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri May 8 16:51:00 2020 +0200
init: init i18n
When Amtk was part of the same git repo, amtk_init() took care of this,
since it was the same GETTEXT_PACKAGE value.
But now that Amtk is in a separate repo we need to initialize i18n in
Tepl too.
meson.build | 2 ++
tepl/tepl-init.c | 38 ++++++++++++++++++++++++++++++++++++--
tepl/tepl-init.h | 1 +
3 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 8748bdd..a5dd0c5 100644
--- a/meson.build
+++ b/meson.build
@@ -57,6 +57,8 @@ TEPL_DEPS = [TEPL_PUBLIC_DEPS, TEPL_PRIVATE_DEPS]
config_data = configuration_data()
GETTEXT_PACKAGE_NAME = 'tepl-' + TEPL_API_VERSION
config_data.set_quoted('GETTEXT_PACKAGE', GETTEXT_PACKAGE_NAME)
+config_data.set_quoted('TEPL_LOCALEDIR', get_option('prefix') / get_option('localedir'))
+
configure_file(
output: 'config.h',
configuration: config_data
diff --git a/tepl/tepl-init.c b/tepl/tepl-init.c
index 3f87ba2..9396961 100644
--- a/tepl/tepl-init.c
+++ b/tepl/tepl-init.c
@@ -2,12 +2,31 @@
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
+#include "config.h"
#include "tepl-init.h"
+#include <glib/gi18n-lib.h>
#include <amtk/amtk.h>
#include <gtksourceview/gtksource.h>
#include "tepl-abstract-factory.h"
#include "tepl-metadata-manager.h"
+static gchar *
+get_locale_directory (void)
+{
+#ifdef G_OS_WIN32
+ gchar *base_dir;
+ gchar *locale_dir;
+
+ base_dir = g_win32_get_package_installation_directory_of_module (NULL);
+ locale_dir = g_build_filename (base_dir, "share", "locale", NULL);
+ g_free (base_dir);
+
+ return locale_dir;
+#else
+ return g_strdup (TEPL_LOCALEDIR);
+#endif
+}
+
/**
* tepl_init:
*
@@ -23,8 +42,23 @@
void
tepl_init (void)
{
- amtk_init ();
- gtk_source_init ();
+ static gboolean done = FALSE;
+
+ if (!done)
+ {
+ gchar *locale_dir;
+
+ amtk_init ();
+ gtk_source_init ();
+
+ locale_dir = get_locale_directory ();
+ bindtextdomain (GETTEXT_PACKAGE, locale_dir);
+ g_free (locale_dir);
+
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ done = TRUE;
+ }
}
/**
diff --git a/tepl/tepl-init.h b/tepl/tepl-init.h
index 1783b4f..e677aa6 100644
--- a/tepl/tepl-init.h
+++ b/tepl/tepl-init.h
@@ -16,6 +16,7 @@ G_BEGIN_DECLS
_TEPL_EXTERN
void tepl_init (void);
+
_TEPL_EXTERN
void tepl_finalize (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]