[libpeas/meson.msvc: 5/7] Python Loader: Do not hardcode localedir on Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas/meson.msvc: 5/7] Python Loader: Do not hardcode localedir on Windows
- Date: Mon, 8 Jun 2020 10:19:10 +0000 (UTC)
commit 15fa285938cbc23f0586bd8914bb530106cca61c
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Oct 15 14:46:38 2018 +0800
Python Loader: Do not hardcode localedir on Windows
We construct them dynamically according to the path that the libpeas DLL
is in, so that they can be relocated easily on Windows, which is often
the case there.
loaders/python/peas-python-internal.c | 4 ++++
loaders/python/peas-python-internal.py | 7 ++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/loaders/python/peas-python-internal.c b/loaders/python/peas-python-internal.c
index 5889188..f15b941 100644
--- a/loaders/python/peas-python-internal.c
+++ b/loaders/python/peas-python-internal.c
@@ -68,6 +68,7 @@ peas_python_internal_setup (gboolean already_initialized)
PyObject *builtins_module, *globals, *result;
PyObject *code = NULL, *failed_method = NULL;
gboolean success = FALSE;
+ char *localedir = NULL;
#define goto_error_if_failed(cond) \
G_STMT_START { \
@@ -128,8 +129,11 @@ peas_python_internal_setup (gboolean already_initialized)
prgname) == 0);
goto_error_if_failed (PyModule_AddStringMacro (internal_module,
GETTEXT_PACKAGE) == 0);
+
+#ifndef G_OS_WIN32
goto_error_if_failed (PyModule_AddStringMacro (internal_module,
PEAS_LOCALEDIR) == 0);
+#endif
globals = PyModule_GetDict (internal_module);
result = PyEval_EvalCode ((gpointer) code, globals, globals);
diff --git a/loaders/python/peas-python-internal.py b/loaders/python/peas-python-internal.py
index 1a0a745..86360b3 100644
--- a/loaders/python/peas-python-internal.py
+++ b/loaders/python/peas-python-internal.py
@@ -43,7 +43,12 @@ class Hooks(object):
sys.argv = [PRGNAME]
- gettext.install(GETTEXT_PACKAGE, PEAS_LOCALEDIR)
+ if os.name == 'nt':
+ basedir = GLib.win32_get_package_installation_directory_of_module(None)
+ peas_locale_dir = os.path.join (basedir, 'share', 'locale')
+ gettext.install(GETTEXT_PACKAGE, peas_locale_dir)
+ else:
+ gettext.install(GETTEXT_PACKAGE, PEAS_LOCALEDIR)
self.__module_cache = {}
self.__extension_cache = {}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]