X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3def4c633be33f44285f64a40c69e08be9161e9..0d53638f7147c18153f63fdfc096b17be6e22a27:/src/common/translation.cpp?ds=sidebyside diff --git a/src/common/translation.cpp b/src/common/translation.cpp index 00350928a5..8816c08013 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -5,7 +5,6 @@ // Michael N. Filippov // (2003/09/30 - PluralForms support) // Created: 2010-04-23 -// RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -101,6 +100,13 @@ void LogTraceArray(const char *prefix, const wxArrayString& arr) wxLogTrace(TRACE_I18N, "%s: [%s]", prefix, wxJoin(arr, ',')); } +void LogTraceLargeArray(const wxString& prefix, const wxArrayString& arr) +{ + wxLogTrace(TRACE_I18N, "%s:", prefix); + for ( wxArrayString::const_iterator i = arr.begin(); i != arr.end(); ++i ) + wxLogTrace(TRACE_I18N, " %s", *i); +} + // Use locale-based detection as a fallback wxString GetPreferredUILanguageFallback(const wxArrayString& WXUNUSED(available)) { @@ -1754,7 +1760,7 @@ wxArrayString gs_searchPrefixes; wxString GetMsgCatalogSubdirs(const wxString& prefix, const wxString& lang) { // Search first in Unix-standard prefix/lang/LC_MESSAGES, then in - // prefix/lang and finally in just prefix. + // prefix/lang. // // Note that we use LC_MESSAGES on all platforms and not just Unix, because // it doesn't cost much to look into one more directory and doing it this @@ -1768,9 +1774,15 @@ wxString GetMsgCatalogSubdirs(const wxString& prefix, const wxString& lang) wxString searchPath; searchPath.reserve(4*prefixAndLang.length()); - searchPath << prefixAndLang << wxFILE_SEP_PATH << "LC_MESSAGES" << wxPATH_SEP + + searchPath +#ifdef __WXOSX__ + << prefixAndLang << ".lproj/LC_MESSAGES" << wxPATH_SEP + << prefixAndLang << ".lproj" << wxPATH_SEP +#endif + << prefixAndLang << wxFILE_SEP_PATH << "LC_MESSAGES" << wxPATH_SEP << prefixAndLang << wxPATH_SEP - << prefix; + ; return searchPath; } @@ -1783,7 +1795,7 @@ bool HasMsgCatalogInDir(const wxString& dir, const wxString& domain) // get prefixes to locale directories; if lang is empty, don't point to // OSX's .lproj bundles -wxArrayString GetSearchPrefixes(const wxString& lang = wxString()) +wxArrayString GetSearchPrefixes() { wxArrayString paths; @@ -1793,15 +1805,7 @@ wxArrayString GetSearchPrefixes(const wxString& lang = wxString()) #if wxUSE_STDPATHS // then look in the standard location wxString stdp; - if ( lang.empty() ) - { - stdp = wxStandardPaths::Get().GetResourcesDir(); - } - else - { - stdp = wxStandardPaths::Get(). - GetLocalizedResourcesDir(lang, wxStandardPaths::ResourceCat_Messages); - } + stdp = wxStandardPaths::Get().GetResourcesDir(); if ( paths.Index(stdp) == wxNOT_FOUND ) paths.Add(stdp); #endif // wxUSE_STDPATHS @@ -1837,7 +1841,7 @@ wxString GetFullSearchPath(const wxString& lang) wxString searchPath; searchPath.reserve(500); - const wxArrayString prefixes = GetSearchPrefixes(lang); + const wxArrayString prefixes = GetSearchPrefixes(); for ( wxArrayString::const_iterator i = prefixes.begin(); i != prefixes.end(); @@ -1871,8 +1875,11 @@ wxMsgCatalog *wxFileTranslationsLoader::LoadCatalog(const wxString& domain, { wxString searchPath = GetFullSearchPath(lang); - wxLogTrace(TRACE_I18N, wxS("Looking for \"%s.mo\" in search path \"%s\""), - domain, searchPath); + LogTraceLargeArray + ( + wxString::Format("looking for \"%s.mo\" in search path", domain), + wxSplit(searchPath, wxPATH_SEP[0]) + ); wxFileName fn(domain); fn.SetExt(wxS("mo")); @@ -1894,9 +1901,11 @@ wxArrayString wxFileTranslationsLoader::GetAvailableTranslations(const wxString& wxArrayString langs; const wxArrayString prefixes = GetSearchPrefixes(); - wxLogTrace(TRACE_I18N, - "looking for available translations of \"%s\" in search path \"%s\"", - domain, wxJoin(prefixes, wxPATH_SEP[0])); + LogTraceLargeArray + ( + wxString::Format("looking for available translations of \"%s\" in search path", domain), + prefixes + ); for ( wxArrayString::const_iterator i = prefixes.begin(); i != prefixes.end(); @@ -1923,7 +1932,8 @@ wxArrayString wxFileTranslationsLoader::GetAvailableTranslations(const wxString& #endif // __WXOSX__ wxLogTrace(TRACE_I18N, - "found %s translation of \"%s\"", lang, domain); + "found %s translation of \"%s\" in %s", + lang, domain, langdir); langs.push_back(lang); } }