diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index e1fcdbc87..77dc90412 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -971,36 +971,24 @@ wxLanguageInfo userLangs[] = void AudacityApp::InitLang( const wxString & lang ) { - if( mLocale ) + if (mLocale) delete mLocale; - wxString canon = lang; - #if defined(__WXMAC__) // This should be reviewed again during the wx3 conversion. - // On OSX, the eventual call to setlocale() will fail to completely - // set the locale causing printf() and kin to still use the period - // as the decimal separator when the locale specifies something - // else. - const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang); - if (info) { - canon = info->CanonicalName; - } - // On OSX, if the LANG environment variable isn't set when // using a language like Japanese, an assertion will trigger // because conversion to Japanese from "?" doesn't return a // valid length, so make OSX happy by defining/overriding - // the LANG environment variable with what the user has - // chosen. - wxSetEnv(wxT("LANG"), canon); + // the LANG environment variable with U.S. English for now. + wxSetEnv(wxT("LANG"), wxT("en_US.UTF-8")); #endif #if wxCHECK_VERSION(3,0,0) - mLocale = new wxLocale(wxT(""), canon, wxT(""), true); + mLocale = new wxLocale(wxT(""), lang, wxT(""), true); #else - mLocale = new wxLocale(wxT(""), canon, wxT(""), true, true); + mLocale = new wxLocale(wxT(""), lang, wxT(""), true, true); #endif for(unsigned int i=0; idecimal_point) : wxT("."); + if (s.empty()) + { + // We really must have something for decimal separator, so fall + // back to the C locale default. + s = wxT("."); + } - // Remember the locale which was current when we initialized, we must redo - // the initialization if the locale changed. - static LocaleId s_localeUsedForInit; - - if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) - { - const wxString - s = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); - if ( s.empty() ) - { - // We really must have something for decimal separator, so fall - // back to the C locale default. - s_decimalSeparator = '.'; - } - else - { - // To the best of my knowledge there are no locales like this. - wxASSERT_MSG( s.length() == 1, - wxT("Multi-character decimal separator?") ); - - s_decimalSeparator = s[0]; - } - } - - return s_decimalSeparator; + return s[0]; #else // !wxUSE_INTL - return wxT('.'); + return wxT('.'); #endif // wxUSE_INTL/!wxUSE_INTL } bool NumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep) { #if wxUSE_INTL - static wxChar s_thousandsSeparator = 0; - static LocaleId s_localeUsedForInit; + struct lconv *info = localeconv(); + wxString s = info ? wxString::FromUTF8(info->thousands_sep) : wxT(""); - if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) - { -#if defined(__WXMSW__) - wxUint32 lcid = LOCALE_USER_DEFAULT; + if (s.IsEmpty()) + { + return false; + } - if (wxGetLocale()) - { - const wxLanguageInfo *info = wxLocale::GetLanguageInfo(wxGetLocale()->GetLanguage()); - if (info) - { ; - lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang), - SORT_DEFAULT); - } - } - - wxString s; - wxChar buffer[256]; - buffer[0] = wxT('\0'); - size_t count = GetLocaleInfo(lcid, LOCALE_STHOUSAND, buffer, 256); - if (!count) - s << wxT(","); - else - s << buffer; -#else - wxString - s = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER); -#endif - if ( !s.empty() ) - { - wxASSERT_MSG( s.length() == 1, - wxT("Multi-character thousands separator?") ); - - s_thousandsSeparator = s[0]; - } - //else: Unlike above it's perfectly fine for the thousands separator to - // be empty if grouping is not used, so just leave it as 0. - } - - if ( !s_thousandsSeparator ) - return false; - - if ( sep ) - *sep = s_thousandsSeparator; - - return true; + *sep = s[0]; + return true; #else // !wxUSE_INTL wxUnusedVar(sep); return false;