From 23fcecf7832c93d284505b0d0a51ea31f755ccb7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 3 Aug 1998 22:54:15 +0000 Subject: [PATCH] added wxLocale::Init() and ctor without arguments for convenience git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@424 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/intl.h | 10 +++++++++- src/common/intl.cpp | 25 ++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/include/wx/intl.h b/include/wx/intl.h index 6cbd5e2f21..d60fd47f90 100644 --- a/include/wx/intl.h +++ b/include/wx/intl.h @@ -57,11 +57,19 @@ class WXDLLEXPORT wxLocale { public: // ctor & dtor + // call Init() if you use this ctor + wxLocale(); // the ctor has a side effect of changing current locale wxLocale(const char *szName, // name (for messages) const char *szShort = NULL, // dir prefix (for msg files) const char *szLocale = NULL, // locale (for setlocale) - bool bLoadDefault = TRUE); // preload wxstd.mo? + bool bLoadDefault = TRUE) // preload wxstd.mo? + { Init(szName, szShort, szLocale, bLoadDefault); } + // the same as a function (returns TRUE on success) + bool Init(const char *szName, + const char *szShort = NULL, + const char *szLocale = NULL, + bool bLoadDefault = TRUE); // restores old locale ~wxLocale(); diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 9750b9d809..6f70f2fa3b 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -363,13 +363,21 @@ 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; @@ -390,8 +398,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 -- 2.45.2