From fd08f641aebb45d00660fa49b951879d3bfc4641 Mon Sep 17 00:00:00 2001 From: Vaclav Slavik Date: Wed, 10 Jun 2015 18:32:49 +0200 Subject: [PATCH] Call SetThreadUILanguage() on Windows Starting with Vista, SetThreadLocale() does basically nothing and does not affect UI language. We need to call SetThreadUILanguage() as well from wxLocale::Init() to have the locale reflected in e.g. standard dialogs. --- src/common/intl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 7c77e16b98..e7849ea58c 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -55,6 +55,7 @@ #endif #ifdef __WIN32__ + #include "wx/dynlib.h" #include "wx/msw/private.h" #endif @@ -480,6 +481,18 @@ bool wxLocale::Init(int language, int flags) // change locale used by Windows functions ::SetThreadLocale(lcid); + + // SetThreadUILanguage() may be available on XP, but with unclear + // behavior, so avoid calling it there. + if ( wxGetWinVersion() >= wxWinVersion_Vista ) + { + wxLoadedDLL dllKernel32(wxS("kernel32.dll")); + typedef LANGID(WINAPI *SetThreadUILanguage_t)(LANGID); + SetThreadUILanguage_t pfnSetThreadUILanguage = NULL; + wxDL_INIT_FUNC(pfn, SetThreadUILanguage, dllKernel32); + if (pfnSetThreadUILanguage) + pfnSetThreadUILanguage(LANGIDFROMLCID(lcid)); + } #endif // and also call setlocale() to change locale used by the CRT