From c842c9c98b4e637f6ee29faf4c1ea4b1f0b83fc9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 18 Feb 2008 23:43:29 +0000 Subject: [PATCH] honour locale modifiers such a @valencia in system locale (patch 1896444) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@51897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/intl.cpp | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6f34d7a9bb..5fa092dc4a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -124,6 +124,7 @@ All (Unix): --enable-media; only wxMedia library depends on it now. - wxLaunchDefaultBrowser() now uses xdg-open if available. - Don't close UDP socket if an empty datagram is received (Mikkel S) +- Honour locale modifiers such a "@valencia" in system locale (Tim Kosse) wxMSW: diff --git a/src/common/intl.cpp b/src/common/intl.cpp index ef5fa8070b..c708955f9f 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1946,8 +1946,13 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix) // for now we don't use the encoding, although we probably should (doing // translations of the msg catalogs on the fly as required) (TODO) // - // we don't use the modifiers neither but we probably should translate - // "euro" into iso885915 + // we need the modified for languages like Valencian: ca_ES@valencia + // though, remember it + wxString modifier; + size_t posModifier = langFull.find_first_of(_T("@")); + if ( posModifier != wxString::npos ) + modifier = langFull.Mid(posModifier); + size_t posEndLang = langFull.find_first_of(_T("@.")); if ( posEndLang != wxString::npos ) { @@ -1993,11 +1998,24 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix) } // 1. Try to find the language either as is: - for ( i = 0; i < count; i++ ) + // a) With modifier if set + if ( !modifier.empty() ) { - if ( ms_languagesDB->Item(i).CanonicalName == langFull ) + wxString langFullWithModifier = langFull + modifier; + for ( i = 0; i < count; i++ ) { - break; + if ( ms_languagesDB->Item(i).CanonicalName == langFullWithModifier ) + break; + } + } + + // b) Without modifier + if ( modifier.empty() || i == count ) + { + for ( i = 0; i < count; i++ ) + { + if ( ms_languagesDB->Item(i).CanonicalName == langFull ) + break; } }