Don't look for catalogs in AddCatalogLookupPathPrefix() path directly.
Previously, the prefix directory itself for searched for catalogs, in addition to prefix/lang/LC_MESSAGES and prefix/lang. This never made much sense, because only one catalog could be in such place, instead of multiple catalogs for more languages. It also prevented successful identification of catalog's language and didn't work with GetAvailableLanguages(). Remove this misfeature and update the documentation accordingly. Update OS X-specific code so that it continues to work (it previously depended on this behavior). As a side effect, *.lproj directories are now recognized in all search prefixes, not just in Resources. See #12498, #15253. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -338,9 +338,10 @@ public:
|
|||||||
wxTranslations::SetLoader().
|
wxTranslations::SetLoader().
|
||||||
|
|
||||||
Catalogs are searched for in standard places (system locales directory,
|
Catalogs are searched for in standard places (system locales directory,
|
||||||
`LC_PATH` on Unix systems, Resources folder on OS X, executable's directory
|
`LC_PATH` on Unix systems, Resources subdirectory of the application bundle
|
||||||
on Windows), but you may also prepend additional directories to the search
|
on OS X, executable's directory on Windows), but you may also prepend
|
||||||
path with AddCatalogLookupPathPrefix().
|
additional directories to the search path with
|
||||||
|
AddCatalogLookupPathPrefix().
|
||||||
|
|
||||||
@since 2.9.1
|
@since 2.9.1
|
||||||
*/
|
*/
|
||||||
@@ -349,7 +350,7 @@ class wxFileTranslationsLoader : public wxTranslationsLoader
|
|||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Add a prefix to the catalog lookup path: the message catalog files will
|
Add a prefix to the catalog lookup path: the message catalog files will
|
||||||
be looked up under prefix/lang/LC_MESSAGES, prefix/lang and prefix
|
be looked up under prefix/lang/LC_MESSAGES and prefix/lang directories
|
||||||
(in this order).
|
(in this order).
|
||||||
|
|
||||||
This only applies to subsequent invocations of
|
This only applies to subsequent invocations of
|
||||||
|
@@ -1761,7 +1761,7 @@ wxArrayString gs_searchPrefixes;
|
|||||||
wxString GetMsgCatalogSubdirs(const wxString& prefix, const wxString& lang)
|
wxString GetMsgCatalogSubdirs(const wxString& prefix, const wxString& lang)
|
||||||
{
|
{
|
||||||
// Search first in Unix-standard prefix/lang/LC_MESSAGES, then in
|
// 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
|
// 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
|
// it doesn't cost much to look into one more directory and doing it this
|
||||||
@@ -1775,9 +1775,15 @@ wxString GetMsgCatalogSubdirs(const wxString& prefix, const wxString& lang)
|
|||||||
|
|
||||||
wxString searchPath;
|
wxString searchPath;
|
||||||
searchPath.reserve(4*prefixAndLang.length());
|
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
|
<< prefixAndLang << wxPATH_SEP
|
||||||
<< prefix;
|
;
|
||||||
|
|
||||||
return searchPath;
|
return searchPath;
|
||||||
}
|
}
|
||||||
@@ -1790,7 +1796,7 @@ bool HasMsgCatalogInDir(const wxString& dir, const wxString& domain)
|
|||||||
|
|
||||||
// get prefixes to locale directories; if lang is empty, don't point to
|
// get prefixes to locale directories; if lang is empty, don't point to
|
||||||
// OSX's .lproj bundles
|
// OSX's .lproj bundles
|
||||||
wxArrayString GetSearchPrefixes(const wxString& lang = wxString())
|
wxArrayString GetSearchPrefixes()
|
||||||
{
|
{
|
||||||
wxArrayString paths;
|
wxArrayString paths;
|
||||||
|
|
||||||
@@ -1800,15 +1806,7 @@ wxArrayString GetSearchPrefixes(const wxString& lang = wxString())
|
|||||||
#if wxUSE_STDPATHS
|
#if wxUSE_STDPATHS
|
||||||
// then look in the standard location
|
// then look in the standard location
|
||||||
wxString stdp;
|
wxString stdp;
|
||||||
if ( lang.empty() )
|
stdp = wxStandardPaths::Get().GetResourcesDir();
|
||||||
{
|
|
||||||
stdp = wxStandardPaths::Get().GetResourcesDir();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stdp = wxStandardPaths::Get().
|
|
||||||
GetLocalizedResourcesDir(lang, wxStandardPaths::ResourceCat_Messages);
|
|
||||||
}
|
|
||||||
if ( paths.Index(stdp) == wxNOT_FOUND )
|
if ( paths.Index(stdp) == wxNOT_FOUND )
|
||||||
paths.Add(stdp);
|
paths.Add(stdp);
|
||||||
#endif // wxUSE_STDPATHS
|
#endif // wxUSE_STDPATHS
|
||||||
@@ -1844,7 +1842,7 @@ wxString GetFullSearchPath(const wxString& lang)
|
|||||||
wxString searchPath;
|
wxString searchPath;
|
||||||
searchPath.reserve(500);
|
searchPath.reserve(500);
|
||||||
|
|
||||||
const wxArrayString prefixes = GetSearchPrefixes(lang);
|
const wxArrayString prefixes = GetSearchPrefixes();
|
||||||
|
|
||||||
for ( wxArrayString::const_iterator i = prefixes.begin();
|
for ( wxArrayString::const_iterator i = prefixes.begin();
|
||||||
i != prefixes.end();
|
i != prefixes.end();
|
||||||
|
Reference in New Issue
Block a user