From 33ae58e4576ed936f7d3ea7a5640762befa60596 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 3 Aug 2021 01:41:27 +0200 Subject: [PATCH] Allow using wxLOCALE_CAT_DEFAULT for numeric or money locale info Make GetInfo() return information for numbers by default in the Unix version too instead of asserting, as this is more consistent with the MSW and Mac versions and also seems more useful. --- interface/wx/intl.h | 6 ++++++ src/common/intl.cpp | 32 ++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/interface/wx/intl.h b/interface/wx/intl.h index 92902c1b7d..7cd5ab6964 100644 --- a/interface/wx/intl.h +++ b/interface/wx/intl.h @@ -116,6 +116,9 @@ enum wxLocaleInfo This value can be used with either wxLOCALE_CAT_NUMBER or wxLOCALE_CAT_MONEY categories. + + By default, i.e. when wxLOCALE_CAT_DEFAULT is used, the separator for + numbers is returned. */ wxLOCALE_THOUSANDS_SEP, @@ -124,6 +127,9 @@ enum wxLocaleInfo This value can be used with either wxLOCALE_CAT_NUMBER or wxLOCALE_CAT_MONEY categories. + + By default, i.e. when wxLOCALE_CAT_DEFAULT is used, the decimal point + for numbers is returned. */ wxLOCALE_DECIMAL_POINT, diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 6dc41e4b05..d9b166557d 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1935,22 +1935,34 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) switch ( index ) { case wxLOCALE_THOUSANDS_SEP: - if ( cat == wxLOCALE_CAT_NUMBER ) - return lc->thousands_sep; - else if ( cat == wxLOCALE_CAT_MONEY ) - return lc->mon_thousands_sep; + switch ( cat ) + { + case wxLOCALE_CAT_DEFAULT: + case wxLOCALE_CAT_NUMBER: + return lc->thousands_sep; - wxFAIL_MSG( "invalid wxLocaleCategory" ); + case wxLOCALE_CAT_MONEY: + return lc->mon_thousands_sep; + + default: + wxFAIL_MSG( "invalid wxLocaleCategory" ); + } break; case wxLOCALE_DECIMAL_POINT: - if ( cat == wxLOCALE_CAT_NUMBER ) - return lc->decimal_point; - else if ( cat == wxLOCALE_CAT_MONEY ) - return lc->mon_decimal_point; + switch ( cat ) + { + case wxLOCALE_CAT_DEFAULT: + case wxLOCALE_CAT_NUMBER: + return lc->decimal_point; - wxFAIL_MSG( "invalid wxLocaleCategory" ); + case wxLOCALE_CAT_MONEY: + return lc->mon_decimal_point; + + default: + wxFAIL_MSG( "invalid wxLocaleCategory" ); + } break; case wxLOCALE_SHORT_DATE_FMT: