2015-11-14 03:32:09 +03:00
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
#include <windows.h>
|
|
|
|
@LC_WIN32_INCLUDES@
|
|
|
|
#elif defined(linux) || defined(UNIX) || defined(__unix__)
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
@LC_UNIX_INCLUDES@
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@LC_COMMON_INCLUDES@
|
|
|
|
|
|
|
|
#include "gettext-config.h"
|
|
|
|
|
2016-06-21 13:31:12 +03:00
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2016-07-16 00:57:43 +03:00
|
|
|
static HINSTANCE hCurrentModuleInstance;
|
2016-06-21 13:31:12 +03:00
|
|
|
#endif
|
2015-11-14 03:32:09 +03:00
|
|
|
|
|
|
|
@LC_GLOB_VARS@
|
|
|
|
|
2016-06-21 13:31:12 +03:00
|
|
|
gboolean get_library_path (gchar *so_path, void *addr)
|
|
|
|
{
|
|
|
|
gboolean ret;
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
ret = 0 != GetModuleFileName (hCurrentModuleInstance, so_path, FILENAME_MAX);
|
|
|
|
#elif defined(linux) || defined(UNIX) || defined(__unix__)
|
|
|
|
Dl_info dl_info;
|
|
|
|
ret = 0 != dladdr(addr, &dl_info);
|
|
|
|
strcpy (so_path, dl_info.dli_fname);
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-11-14 03:32:09 +03:00
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
|
|
|
#elif defined(linux) || defined(UNIX) || defined(__unix__)
|
|
|
|
void __attribute__ ((constructor)) load_library (void)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
gchar *soDir, *localePath;
|
|
|
|
@LC_VARS@
|
|
|
|
|
2016-06-21 13:31:12 +03:00
|
|
|
gchar *so_path = g_new (gchar, FILENAME_MAX);
|
2015-11-14 03:32:09 +03:00
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2016-06-21 13:31:12 +03:00
|
|
|
hCurrentModuleInstance = hInstance;
|
2016-07-16 00:57:43 +03:00
|
|
|
get_library_path (so_path, NULL);
|
2015-11-14 03:32:09 +03:00
|
|
|
@LC_WIN32_CODE@
|
|
|
|
#elif defined(linux) || defined(UNIX) || defined(__unix__)
|
2016-06-21 13:31:12 +03:00
|
|
|
get_library_path (so_path, load_library);
|
2015-11-14 03:32:09 +03:00
|
|
|
@LC_UNIX_CODE@
|
|
|
|
#endif
|
|
|
|
|
2016-06-21 13:31:12 +03:00
|
|
|
soDir = g_path_get_dirname (so_path);
|
|
|
|
g_free (so_path);
|
2015-11-14 03:32:09 +03:00
|
|
|
localePath = g_build_filename (soDir, "@LC_RELATIVE_PREFIX@/share/locale", NULL);
|
|
|
|
g_free (soDir);
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE, localePath);
|
2015-11-14 10:25:54 +03:00
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
2015-11-14 03:32:09 +03:00
|
|
|
g_free (localePath);
|
|
|
|
|
|
|
|
@LC_COMMON_CODE@
|
|
|
|
}
|