X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/84f858e94cc2f5256530ad9dfc7687310dc3556a..d7a7bd6d27cf2d3bb23c5ceeccbcbe74cf83b4ec:/src/common/intl.cpp diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 20f1925725..3f592d7881 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 @@ -307,15 +307,20 @@ static wxString GetFullSearchPath(const wxChar *lang) wxGetWorkingDirectory( cwd , sizeof( cwd ) ) ; searchPath << GetAllMsgCatalogSubdirs(cwd, lang); // generic search paths could be somewhere in the system folder preferences -#else +#else // !Mac searchPath << GetAllMsgCatalogSubdirs(wxT("."), lang); +#ifdef __UNIX__ // and finally add some standard ones searchPath + << GetAllMsgCatalogSubdirs(wxString(wxGetInstallPrefix()) + wxT("/share/locale"), lang) << GetAllMsgCatalogSubdirs(wxT("/usr/share/locale"), lang) << GetAllMsgCatalogSubdirs(wxT("/usr/lib/locale"), lang) << GetAllMsgCatalogSubdirs(wxT("/usr/local/share/locale"), lang); -#endif +#endif // __UNIX__ + +#endif // platform + return searchPath; } @@ -430,7 +435,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 @@ -444,7 +449,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons if ( convertEncoding ) { wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM; - wxFontEncoding enc = wxTheFontMapper->CharsetToEncoding(charset, FALSE); + wxFontEncoding enc = wxFontMapper::Get()->CharsetToEncoding(charset, FALSE); if ( enc == wxFONTENCODING_SYSTEM ) { convertEncoding = FALSE; // unknown encoding @@ -457,7 +462,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, bool convertEncoding) cons 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; @@ -473,7 +478,7 @@ 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))); } } @@ -495,7 +500,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 +512,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,13 +532,13 @@ 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); @@ -678,7 +683,7 @@ bool wxLocale::Init(int language, int flags) const wxChar *retloc; // Set the locale: -#ifdef __UNIX__ +#if defined(__UNIX__) && !defined(__WXMAC__) if (language == wxLANGUAGE_DEFAULT) locale = wxEmptyString; else @@ -789,7 +794,7 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix) size_t i = 0, count = ms_languagesDB->GetCount(); -#if defined(__UNIX__) +#if defined(__UNIX__) && !defined(__WXMAC__) // first get the string identifying the language from the environment wxString langFull; if (!wxGetEnv(wxT("LC_ALL"), &langFull) && @@ -912,7 +917,7 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix) } } #elif defined(__WXMAC__) - char* lc = NULL ; + const char* lc = NULL ; long lang = GetScriptVariable( smSystemScript, smScriptLang) ; switch( GetScriptManagerVariable( smRegionCode ) ) { case verUS : @@ -1196,7 +1201,7 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix) break; } } - + #elif defined(__WIN32__) LCID lcid = GetUserDefaultLCID(); if ( lcid != 0 ) @@ -1340,7 +1345,7 @@ wxFontEncoding wxLocale::GetSystemEncoding() wxString encname = GetSystemEncodingName(); if ( !encname.empty() ) { - wxFontEncoding enc = wxTheFontMapper-> + wxFontEncoding enc = wxFontMapper::Get()-> CharsetToEncoding(encname, FALSE /* not interactive */); // this should probably be considered as a bug in CharsetToEncoding(): @@ -1397,7 +1402,7 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString, const wxChar *pszTrans = NULL; wxMsgCatalog *pMsgCat; - if ( szDomain != NULL ) + if ( szDomain != NULL ) { pMsgCat = FindCatalog(szDomain); @@ -1405,10 +1410,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 @@ -1416,21 +1421,23 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString, } } - if ( pszTrans == NULL ) + if ( pszTrans == NULL ) { #ifdef __WXDEBUG__ - if ( !NoTransErr::Suppress() ) + if ( !NoTransErr::Suppress() ) { NoTransErr noTransErr; if ( szDomain != NULL ) { - wxLogDebug(_T("string '%s' not found in domain '%s' for locale '%s'."), - szOrigString, szDomain, m_strLocale.c_str()); + wxLogTrace(_T("i18n"), + _T("string '%s' not found in domain '%s' for locale '%s'."), + szOrigString, szDomain, m_strLocale.c_str()); } else { - wxLogDebug(_T("string '%s' not found in locale '%s'."), + wxLogTrace(_T("i18n"), + _T("string '%s' not found in locale '%s'."), szOrigString, m_strLocale.c_str()); } } @@ -1447,7 +1454,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; @@ -2321,7 +2328,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