diff options
author | Hib Eris <hib@hiberis.nl> | 2010-05-17 09:38:16 (GMT) |
---|---|---|
committer | Hib Eris <hib@hiberis.nl> | 2010-05-25 12:23:03 (GMT) |
commit | 61c9b15fa57e40c9561ae8d5ca13228d4e7a897a (patch) | |
tree | 61c05c3ee7ad0e064a26338f159c3d803054370b /libdocument/ev-init.c | |
parent | 2085e3e413cc926551b9ba6ce91689f9b9e236ce (diff) |
[windows] Fix localization on Windows
Fixes bgo#610548
Diffstat (limited to 'libdocument/ev-init.c')
-rw-r--r-- | libdocument/ev-init.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/libdocument/ev-init.c b/libdocument/ev-init.c index 2b247eb..fb10ac5 100644 --- a/libdocument/ev-init.c +++ b/libdocument/ev-init.c @@ -21,6 +21,9 @@ #include <glib.h> #include <glib/gi18n-lib.h> +#ifdef G_OS_WIN32 +#include <windows.h> +#endif #include "ev-init.h" #include "ev-backends-manager.h" @@ -29,6 +32,54 @@ static int ev_init_count; +#ifdef G_OS_WIN32 + +static HMODULE evdocument_dll = NULL; + +#ifdef DLL_EXPORT +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + if (fdwReason == DLL_PROCESS_ATTACH) + evdocument_dll = hinstDLL; + + return TRUE; +} +#endif + +#endif + +static gchar * +_ev_get_locale_dir (void) +{ +#ifdef G_OS_WIN32 + gchar *install_dir = NULL, *locale_dir; + gchar *retval = NULL; + + if (evdocument_dll != NULL) + install_dir = g_win32_get_package_installation_directory_of_module (evdocument_dll); + + if (install_dir) { + locale_dir = g_build_filename (install_dir, + "share", "locale", NULL); + + retval = g_win32_locale_filename_from_utf8 (locale_dir); + + g_free (install_dir); + g_free (locale_dir); + } + + if (retval) + return retval; + else + return g_strdup (""); +#else + return g_strdup (GNOMELOCALEDIR); +#endif +} + /** * ev_init: * @@ -49,7 +100,9 @@ ev_init (void) return have_backends; /* set up translation catalog */ - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + gchar *tmp = _ev_get_locale_dir (); + bindtextdomain (GETTEXT_PACKAGE, tmp); + g_free (tmp); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); _ev_debug_init (); |