From a198ebda98e92cc79254e3198ce4045ed16bf351 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 10 Aug 2000 14:40:06 +0000 Subject: [PATCH] made error "locale couldn't be set" a verbose message instead, use WXDIR to find wxstd.mo git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/locale.tex | 6 +++++- src/common/intl.cpp | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/latex/wx/locale.tex b/docs/latex/wx/locale.tex index a22041f817..187556a1eb 100644 --- a/docs/latex/wx/locale.tex +++ b/docs/latex/wx/locale.tex @@ -51,7 +51,11 @@ understand: first of all, the application locale is changed - note that this will affect many of standard C library functions such as printf() or strftime(). Second, this wxLocale object becomes the new current global locale for the application and so all subsequent calls to wxGetTranslation() will try to -translate the messages using the message catalogs for this locale. +translate the messages using the message catalogs for this locale. Finally, +unless bLoadDefault parameter is FALSE, the method also loads the wxstd.mo +catalog (which is looked for in all the usual places and, additionally, under +the location specified bythe environment variable WXDIR if it is set) which +will allow to translate all the messages generated by the library itself. \membersection{wxLocale::\destruct{wxLocale}}\label{wxlocaledtor} diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 272d7f3f63..25cdf7aa36 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -308,11 +308,13 @@ static wxString GetFullSearchPath(const wxChar *lang) // FIXME it should be the directory of the executable searchPath << GetAllMsgCatalogSubdirs(wxT("."), lang); +#ifdef __UNIX_LIKE__ // and finally add some standard ones searchPath << GetAllMsgCatalogSubdirs(wxT("/usr/share/locale"), lang) << GetAllMsgCatalogSubdirs(wxT("/usr/lib/locale"), lang) << GetAllMsgCatalogSubdirs(wxT("/usr/local/share/locale"), lang); +#endif // __UNIX_LIKE__ return searchPath; } @@ -329,6 +331,21 @@ bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName0, bool b szName = szName.Left(szName.Find(wxT('.'))); wxString searchPath = GetFullSearchPath(szDirPrefix); + +#ifdef __UNIX_LIKE__ + if ( szName == _("wxstd") ) + { + // WXDIR is the env var holding the installation directory of wxWindows + const wxChar *pszWxDir = wxGetenv(wxT("WXDIR")); + if ( pszWxDir ) + { + wxString strWxLoc; + strWxLoc << pszWxDir << wxFILE_SEP_PATH << wxT("share/locale"); + searchPath << GetAllMsgCatalogSubdirs(strWxLoc, szDirPrefix); + } + } +#endif // __UNIX_LIKE__ + const wxChar *sublocale = wxStrchr(szDirPrefix, wxT('_')); if ( sublocale ) { @@ -546,7 +563,11 @@ bool wxLocale::Init(const wxChar *szName, } m_pszOldLocale = wxSetlocale(LC_ALL, szLocale); if ( m_pszOldLocale == NULL ) - wxLogError(_("locale '%s' can not be set."), szLocale); + { + // this is not an error as most systems don't support anything but "C" + // anyhow + wxLogVerbose(_("locale '%s' can not be set."), szLocale); + } // the short name will be used to look for catalog files as well, // so we need something here