diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2018-10-15 14:46:38 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-10-09 09:32:27 +0800 |
commit | 861cb1c34e12c1e35cb1c6beabce59a123cc3772 (patch) | |
tree | f10169a138bd96d8a96ecf2ad344d7dc102a936b /loaders/python | |
parent | 58b749f9bfe00bdd63f82db8f45228d9f841a83b (diff) | |
download | libpeas-861cb1c34e12c1e35cb1c6beabce59a123cc3772.tar.gz |
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.
Diffstat (limited to 'loaders/python')
-rw-r--r-- | loaders/python/peas-python-internal.c | 4 | ||||
-rw-r--r-- | loaders/python/peas-python-internal.py | 7 |
2 files changed, 10 insertions, 1 deletions
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 = {} |