X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/400c9be132b2dfaa62c697811423d6c0e56d7559..f3ba93c1f025870aeda36082acecc87ab277ab7d:/src/common/intl.cpp diff --git a/src/common/intl.cpp b/src/common/intl.cpp index a7da0ed972..168c333343 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -147,7 +147,7 @@ static inline wxString ExtractNotLang(const wxString& langFull) // This is a "low-level" class and is used only by wxMsgCatalog // ---------------------------------------------------------------------------- -WX_DECLARE_STRING_HASH_MAP(wxString, wxMessagesHash) +WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxString, wxMessagesHash) class wxMsgCatalogFile { @@ -194,7 +194,7 @@ private: const char *StringAtOfs(wxMsgTableEntry *pTable, size_t32 index) const { return (const char *)(m_pData + Swap(pTable[index].ofsString)); } - + wxString GetCharset() const; // utility functions @@ -420,7 +420,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons if ( !!charset ) csConv = new wxCSConv(charset); - wxMBConv& inputConv = csConv ? *csConv : *wxConvCurrent; + wxMBConv& inputConv = csConv ? *((wxMBConv*)csConv) : *wxConvCurrent; for (size_t i = 0; i < m_numStrings; i++) { @@ -430,7 +430,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons hash[key] = wxString(StringAtOfs(m_pTransTable, i), inputConv); #else if ( convertEncoding ) - hash[key] = + hash[key] = wxString(inputConv.cMB2WC(StringAtOfs(m_pTransTable, i)), wxConvLocal); else @@ -443,6 +443,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons #if wxUSE_FONTMAP if ( convertEncoding ) { + wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM; wxFontEncoding enc = wxTheFontMapper->CharsetToEncoding(charset, FALSE); if ( enc == wxFONTENCODING_SYSTEM ) { @@ -450,13 +451,13 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons } else { - wxFontEncoding targetEnc = wxLocale::GetSystemEncoding(); + targetEnc = wxLocale::GetSystemEncoding(); if (targetEnc == wxFONTENCODING_SYSTEM) { wxFontEncodingArray a = wxEncodingConverter::GetPlatformEquivalents(enc); if (a[0] == enc) // no conversion needed, locale uses native encoding - convertEncoding = FALSE; + convertEncoding = FALSE; if (a.GetCount() == 0) // we don't know common equiv. under this platform convertEncoding = FALSE; @@ -472,14 +473,14 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons for (size_t i = 0; i < m_numStrings; i++) { wxString key(StringAtOfs(m_pOrigTable, i)); - hash[key] = + hash[key] = converter.Convert(wxString(StringAtOfs(m_pTransTable, i))); } } } if ( !convertEncoding ) - #else // !wxUSE_FONTMAP + #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP { for (size_t i = 0; i < m_numStrings; i++) { @@ -487,7 +488,6 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons hash[key] = StringAtOfs(m_pTransTable, i); } } - #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T } @@ -495,7 +495,7 @@ wxString wxMsgCatalogFile::GetCharset() const { // first, find encoding header: const char *hdr = StringAtOfs(m_pOrigTable, 0); - if ( hdr == NULL || hdr[0] != 0 ) + if ( hdr == NULL || hdr[0] != 0 ) { // not supported by this catalog, does not have correct header return wxEmptyString; @@ -507,19 +507,19 @@ wxString wxMsgCatalogFile::GetCharset() const if ( pos == wxNOT_FOUND ) { // incorrectly filled Content-Type header - return wxEmptyString; + return wxEmptyString; } size_t n = pos + 34; /*strlen("Content-Type: text/plain; charset=")*/ while ( header[n] != wxT('\n') ) charset << header[n++]; - + if ( charset == wxT("CHARSET") ) { // "CHARSET" is not valid charset, but lazy translator return wxEmptyString; } - + return charset; } @@ -527,20 +527,20 @@ wxString wxMsgCatalogFile::GetCharset() const // wxMsgCatalog class // ---------------------------------------------------------------------------- -bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName, +bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName, bool bConvertEncoding) { wxMsgCatalogFile file; - + m_name = szName; - + if ( file.Load(szDirPrefix, szName) ) { file.FillHash(m_messages, bConvertEncoding); return TRUE; } - else - return FALSE; + + return FALSE; } const wxChar *wxMsgCatalog::GetString(const wxChar *sz) const @@ -1196,7 +1196,7 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix) break; } } - + #elif defined(__WIN32__) LCID lcid = GetUserDefaultLCID(); if ( lcid != 0 ) @@ -1253,18 +1253,23 @@ wxString wxLocale::GetSystemEncodingName() char *alang = nl_langinfo(CODESET); setlocale(LC_CTYPE, oldLocale); free(oldLocale); - if (alang) + + if ( alang ) { -#ifdef __SOLARIS__ + // 7 bit ASCII encoding has several alternative names which we should + // recognize to avoid warnings about unrecognized encoding on each + // program startup + // nl_langinfo() under Solaris returns 646 by default which stands for - // ISO-646, i.e. 7 bit ASCII and we should recognize it to avoid - // warnings about unrecognized encoding on each program startup - if ( strcmp(alang, "646") == 0 ) + // ISO-646, i.e. 7 bit ASCII + // + // and recent glibc call it ANSI_X3.4-1968... + if ( strcmp(alang, "646") == 0 || + strcmp(alang, "ANSI_X3.4-1968") == 0 ) { encname = _T("US-ASCII"); } else -#endif // __SOLARIS__ { encname = wxConvLibc.cMB2WX(alang); } @@ -1392,7 +1397,7 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString, const wxChar *pszTrans = NULL; wxMsgCatalog *pMsgCat; - if ( szDomain != NULL ) + if ( szDomain != NULL ) { pMsgCat = FindCatalog(szDomain); @@ -1400,10 +1405,10 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString, if ( pMsgCat != NULL ) pszTrans = pMsgCat->GetString(szOrigString); } - else + else { // search in all domains - for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) + for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) { pszTrans = pMsgCat->GetString(szOrigString); if ( pszTrans != NULL ) // take the first found @@ -1411,10 +1416,10 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString, } } - if ( pszTrans == NULL ) + if ( pszTrans == NULL ) { #ifdef __WXDEBUG__ - if ( !NoTransErr::Suppress() ) + if ( !NoTransErr::Suppress() ) { NoTransErr noTransErr; @@ -1442,7 +1447,7 @@ wxMsgCatalog *wxLocale::FindCatalog(const wxChar *szDomain) const { // linear search in the linked list wxMsgCatalog *pMsgCat; - for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) + for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext ) { if ( wxStricmp(pMsgCat->GetName(), szDomain) == 0 ) return pMsgCat; @@ -2316,7 +2321,7 @@ void wxLocale::InitLanguagesDB() LNG(wxLANGUAGE_YORUBA, "yo" , 0 , 0 , "Yoruba") LNG(wxLANGUAGE_ZHUANG, "za" , 0 , 0 , "Zhuang") LNG(wxLANGUAGE_ZULU, "zu" , 0 , 0 , "Zulu") - + }; #undef LNG