From 529e125df4ed888c2adb614f2e451578a0eca0e0 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 9 Jan 2008 15:55:32 +0000 Subject: [PATCH] Fixed GetInfo to use the current language. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51136 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/intl.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index cb897a2458..c74b6fbb21 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -77,9 +77,9 @@ #endif #if defined(__DARWIN__) - #include "wx/mac/corefoundation/cfref.h" - #include - #include "wx/mac/corefoundation/cfstring.h" + #include "wx/mac/corefoundation/cfref.h" + #include + #include "wx/mac/corefoundation/cfstring.h" #endif // ---------------------------------------------------------------------------- @@ -1935,10 +1935,10 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix) wxString langFull; #ifdef __WXMAC__ wxCFRef userLocaleRef(CFLocaleCopyCurrent()); - - // because the locale identifier (kCFLocaleIdentifier) is formatted a little bit differently, eg + + // because the locale identifier (kCFLocaleIdentifier) is formatted a little bit differently, eg // az_Cyrl_AZ@calendar=buddhist;currency=JPY we just recreate the base info as expected by wx here - + wxCFStringRef str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode))); langFull = str.AsString()+"_"; str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode))); @@ -2590,6 +2590,18 @@ bool wxLocale::AddCatalog(const wxString& szDomain, /* static */ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat)) { + wxUint32 lcid = LOCALE_USER_DEFAULT; + + if (wxGetLocale()) + { + const wxLanguageInfo *info = GetLanguageInfo(wxGetLocale()->GetLanguage()); + if (info) + { ; + lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang), + SORT_DEFAULT); + } + } + wxString str; wxChar buffer[256]; size_t count; @@ -2597,7 +2609,7 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat)) switch (index) { case wxLOCALE_DECIMAL_POINT: - count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256); + count = ::GetLocaleInfo(lcid, LOCALE_SDECIMAL, buffer, 256); if (!count) str << wxS("."); else @@ -2605,14 +2617,14 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat)) break; #if 0 case wxSYS_LIST_SEPARATOR: - count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256); + count = ::GetLocaleInfo(lcid, LOCALE_SLIST, buffer, 256); if (!count) str << wxS(","); else str << buffer; break; case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero - count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256); + count = ::GetLocaleInfo(lcid, LOCALE_ILZERO, buffer, 256); if (!count) str << wxS("0"); else -- 2.47.2