X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c801d85f158c4cba50b588807daabdcbd0ed3853..d1427b705318677afe28b1291867f6930c8823a7:/src/common/intl.cpp diff --git a/src/common/intl.cpp b/src/common/intl.cpp index b5520e58b7..8943f15518 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -193,8 +193,8 @@ wxMsgCatalog::wxMsgCatalog() wxMsgCatalog::~wxMsgCatalog() { - DELETEA(m_pData); - DELETEA(m_pszName); + wxDELETEA(m_pData); + wxDELETEA(m_pszName); } class NoTransErr @@ -243,17 +243,17 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) // (we're using an object because we have several return paths) NoTransErr noTransErr; - wxLogVerbose("looking for catalog '%s' in path '%s'.", + wxLogVerbose(_("looking for catalog '%s' in path '%s'."), szName, strPath.c_str()); wxString strFullName; if ( !wxFindFileInPath(&strFullName, strPath, strFile) ) { - wxLogWarning("catalog file for domain '%s' not found.", szName); + wxLogWarning(_("catalog file for domain '%s' not found."), szName); return FALSE; } // open file - wxLogVerbose("using catalog '%s' from '%s'.", + wxLogVerbose(_("using catalog '%s' from '%s'."), szName, strFullName.c_str()); wxFile fileMsg(strFullName); @@ -262,14 +262,13 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) // get the file size off_t nSize = fileMsg.Length(); - if ( nSize == ofsInvalid ) + if ( nSize == wxInvalidOffset ) return FALSE; // read the whole file in memory m_pData = new uint8[nSize]; if ( fileMsg.Read(m_pData, nSize) != nSize ) { - DELETEA(m_pData); - m_pData = NULL; + wxDELETEA(m_pData); return FALSE; } @@ -289,10 +288,9 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) if ( !bValid ) { // it's either too short or has incorrect magic number - wxLogWarning("'%s' is not a valid message catalog.", strFullName.c_str()); + wxLogWarning(_("'%s' is not a valid message catalog."), strFullName.c_str()); - DELETEA(m_pData); - m_pData = NULL; + wxDELETEA(m_pData); return FALSE; } @@ -363,19 +361,27 @@ const char *wxMsgCatalog::GetString(const char *szOrig) const // wxLocale // ---------------------------------------------------------------------------- -// NB: ctor has (desired) side effect of changing current locale -wxLocale::wxLocale(const char *szName, - const char *szShort, - const char *szLocale, - bool bLoadDefault) - : m_strLocale(szName), m_strShort(szShort) +wxLocale::wxLocale() { + m_pszOldLocale = NULL; + m_pMsgCat = NULL; +} + +// NB: this function has (desired) side effect of changing current locale +bool wxLocale::Init(const char *szName, + const char *szShort, + const char *szLocale, + bool bLoadDefault) +{ + m_strLocale = szName; + m_strShort = szShort; + // change current locale (default: same as long name) if ( szLocale == NULL ) szLocale = szName; m_pszOldLocale = setlocale(LC_ALL, szLocale); if ( m_pszOldLocale == NULL ) - wxLogError("locale '%s' can not be set.", szLocale); + wxLogError(_("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 @@ -390,8 +396,11 @@ wxLocale::wxLocale(const char *szName, // load the default catalog with wxWindows standard messages m_pMsgCat = NULL; + bool bOk = TRUE; if ( bLoadDefault ) - AddCatalog("wxstd"); + bOk = AddCatalog("wxstd"); + + return bOk; } // clean up @@ -442,10 +451,10 @@ const char *wxLocale::GetString(const char *szOrigString, wxSuppressTransErrors(); if ( szDomain != NULL ) - wxLogWarning("string '%s' not found in domain '%s' for locale '%s'.", + wxLogWarning(_("string '%s' not found in domain '%s' for locale '%s'."), szOrigString, szDomain, m_strLocale.c_str()); else - wxLogWarning("string '%s' not found in locale '%s'.", + wxLogWarning(_("string '%s' not found in locale '%s'."), szOrigString, m_strLocale.c_str()); }