don't wxLogWarn() about missing strings, but just wxLogDebug() them
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7288 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -103,17 +103,33 @@ const size_t32 MSGCATALOG_MAGIC_SW = 0xde120495;
|
|||||||
// global functions
|
// global functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// suppress further error messages about missing translations
|
#ifdef __WXDEBUG__
|
||||||
// (if you don't have one catalog file, you wouldn't like to see the
|
|
||||||
// error message for each string in it, so normally it's given only
|
|
||||||
// once)
|
|
||||||
void wxSuppressTransErrors();
|
|
||||||
|
|
||||||
// restore the logging
|
// small class to suppress the translation erros until exit from current scope
|
||||||
void wxRestoreTransErrors();
|
class NoTransErr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NoTransErr() { ms_suppressCount++; }
|
||||||
|
~NoTransErr() { ms_suppressCount--; }
|
||||||
|
|
||||||
// get the current state
|
static bool Suppress() { return ms_suppressCount > 0; }
|
||||||
bool wxIsLoggingTransErrors();
|
|
||||||
|
private:
|
||||||
|
static size_t ms_suppressCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t NoTransErr::ms_suppressCount = 0;
|
||||||
|
|
||||||
|
#else // !Debug
|
||||||
|
|
||||||
|
class NoTransErr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NoTransErr() { }
|
||||||
|
~NoTransErr() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // Debug/!Debug
|
||||||
|
|
||||||
static wxLocale *wxSetLocale(wxLocale *pLocale);
|
static wxLocale *wxSetLocale(wxLocale *pLocale);
|
||||||
|
|
||||||
@@ -253,14 +269,6 @@ wxMsgCatalog::~wxMsgCatalog()
|
|||||||
wxDELETEA(m_pszName);
|
wxDELETEA(m_pszName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// small class to suppress the translation erros until exit from current scope
|
|
||||||
class NoTransErr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NoTransErr() { wxSuppressTransErrors(); }
|
|
||||||
~NoTransErr() { wxRestoreTransErrors(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// return all directories to search for given prefix
|
// return all directories to search for given prefix
|
||||||
static wxString GetAllMsgCatalogSubdirs(const wxChar *prefix,
|
static wxString GetAllMsgCatalogSubdirs(const wxChar *prefix,
|
||||||
const wxChar *lang)
|
const wxChar *lang)
|
||||||
@@ -617,29 +625,22 @@ const wxMB2WXbuf wxLocale::GetString(const wxChar *szOrigString,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( pszTrans == NULL ) {
|
if ( pszTrans == NULL ) {
|
||||||
if ( wxIsLoggingTransErrors() ) {
|
|
||||||
// suppress further error messages if we're not debugging: this avoids
|
|
||||||
// flooding the user with messages about each and every missing string if,
|
|
||||||
// for example, a whole catalog file is missing.
|
|
||||||
|
|
||||||
// do it before calling LogWarning to prevent infinite recursion!
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
if ( !NoTransErr::Suppress() ) {
|
||||||
NoTransErr noTransErr;
|
NoTransErr noTransErr;
|
||||||
#else // !debug
|
|
||||||
wxSuppressTransErrors();
|
|
||||||
#endif // debug/!debug
|
|
||||||
|
|
||||||
if ( szDomain != NULL )
|
if ( szDomain != NULL )
|
||||||
{
|
{
|
||||||
wxLogWarning(_("string '%s' not found in domain '%s' for locale '%s'."),
|
wxLogDebug(_T("string '%s' not found in domain '%s' for locale '%s'."),
|
||||||
szOrigString, szDomain, m_strLocale.c_str());
|
szOrigString, szDomain, m_strLocale.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogWarning(_("string '%s' not found in locale '%s'."),
|
wxLogDebug(_T("string '%s' not found in locale '%s'."),
|
||||||
szOrigString, m_strLocale.c_str());
|
szOrigString, m_strLocale.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // __WXDEBUG__
|
||||||
|
|
||||||
return (wxMB2WXbuf)(szOrigString);
|
return (wxMB2WXbuf)(szOrigString);
|
||||||
}
|
}
|
||||||
@@ -696,26 +697,6 @@ bool wxLocale::AddCatalog(const wxChar *szDomain)
|
|||||||
// global functions and variables
|
// global functions and variables
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// translation errors logging
|
|
||||||
// --------------------------
|
|
||||||
|
|
||||||
static bool gs_bGiveTransErrors = TRUE;
|
|
||||||
|
|
||||||
void wxSuppressTransErrors()
|
|
||||||
{
|
|
||||||
gs_bGiveTransErrors = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxRestoreTransErrors()
|
|
||||||
{
|
|
||||||
gs_bGiveTransErrors = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxIsLoggingTransErrors()
|
|
||||||
{
|
|
||||||
return gs_bGiveTransErrors;
|
|
||||||
}
|
|
||||||
|
|
||||||
// retrieve/change current locale
|
// retrieve/change current locale
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user