/////////////////////////////////////////////////////////////////////////////// // Name: src/msw/uilocale.cpp // Purpose: wxUILocale implementation for MSW // Author: Vadim Zeitlin // Created: 2021-07-31 // Copyright: (c) 2021 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// // ============================================================================ // declarations // ============================================================================ // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #if wxUSE_INTL #include "wx/uilocale.h" #include "wx/private/uilocale.h" #include "wx/msw/private/uilocale.h" #include "wx/dynlib.h" #ifndef LOCALE_NAME_USER_DEFAULT #define LOCALE_NAME_USER_DEFAULT NULL #endif #ifndef MUI_LANGUAGE_NAME #define MUI_LANGUAGE_NAME 8 #endif // ============================================================================ // implementation // ============================================================================ // ---------------------------------------------------------------------------- // helper functions // ---------------------------------------------------------------------------- namespace { // Trivial wrapper for ::SetThreadUILanguage(). // // TODO-XP: Drop this when we don't support XP any longer. static void wxMSWSetThreadUILanguage(LANGID langid) { // SetThreadUILanguage() is 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(langid); } } } // anonymous namespace void wxUseLCID(LCID lcid) { ::SetThreadLocale(lcid); wxMSWSetThreadUILanguage(LANGIDFROMLCID(lcid)); } // ---------------------------------------------------------------------------- // wxLocaleIdent::GetName() implementation for MSW // ---------------------------------------------------------------------------- wxString wxLocaleIdent::GetName() const { // Construct name in right format: // Windows: -