diff options
| author | Werner Koch <[email protected]> | 2025-11-26 12:08:45 +0100 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2025-11-26 12:08:45 +0100 |
| commit | cb7f580639cc7cc43cf279b0755e8261882b9f93 (patch) | |
| tree | d4485b9b0b5eef10ee9ddbcc98df75568494a4e4 /src | |
| parent | Use UI language instead of locale for translations (diff) | |
| download | libgpg-error-cb7f580639cc7cc43cf279b0755e8261882b9f93.tar.gz libgpg-error-cb7f580639cc7cc43cf279b0755e8261882b9f93.zip | |
Dynload GetThreadUILanguage to keep support for Windows XP
* src/w32-gettext.c (get_thread_ui_language): New func ptr.
(module_init): Initialize it.
(my_nl_locale_name): Use it instead of a direct call.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32-gettext.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/w32-gettext.c b/src/w32-gettext.c index eb65424..980d905 100644 --- a/src/w32-gettext.c +++ b/src/w32-gettext.c @@ -61,6 +61,8 @@ static struct char name[28]; } override_locale; +/* This is the dynloaded GetThreadUILanguage() or NULL. */ +static LANGID (WINAPI *get_thread_ui_language)(void); @@ -648,8 +650,10 @@ my_nl_locale_name (const char *categoryname) if (retval != NULL && retval[0] != '\0') return retval; - /* Use native Win32 API language ID. */ - lcid = GetThreadUILanguage (); + /* Use native Win32 API language ID or use GetThreadLocale on XP */ + lcid = get_thread_ui_language? get_thread_ui_language () + : GetThreadLocale (); + /* Strip off the sorting rules, keep only the language part. */ langid = LANGIDFROMLCID (lcid); } @@ -1154,6 +1158,7 @@ static CRITICAL_SECTION domainlist_access_cs; static char *current_domainname; + /* Constructor for this module. This can only be used if we are a DLL. If used as a static lib we can't control the process set; for @@ -1166,10 +1171,16 @@ static void module_init (void) { static int init_done; + HMODULE hkernel32; if (!init_done) { InitializeCriticalSection (&domainlist_access_cs); + + hkernel32 = GetModuleHandle ("kernel32.dll"); + if (hkernel32) + get_thread_ui_language = (void*)GetProcAddress (hkernel32, + "GetThreadUILanguage"); init_done = 1; } } |
