X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2740de55efc52e8dc9270c0e17db921a379a049..931d6a47c32a5b4c283243cb553ce71ee2b535d5:/src/common/translation.cpp diff --git a/src/common/translation.cpp b/src/common/translation.cpp index e4bee82b3d..455fb315d0 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -1506,17 +1506,11 @@ bool wxTranslations::AddCatalog(const wxString& domain, wxS("adding '%s' translation for domain '%s' (msgid language '%s')"), domain_lang, domain, msgIdLang); - // It is OK to not load catalog if the msgid language and m_language match, - // in which case we can directly display the texts embedded in program's - // source code: - if ( msgIdLang == domain_lang ) - return true; - - return LoadCatalog(domain, domain_lang); + return LoadCatalog(domain, domain_lang, msgIdLang); } -bool wxTranslations::LoadCatalog(const wxString& domain, const wxString& lang) +bool wxTranslations::LoadCatalog(const wxString& domain, const wxString& lang, const wxString& msgIdLang) { wxCHECK_MSG( m_loader, false, "loader can't be NULL" ); @@ -1553,6 +1547,15 @@ bool wxTranslations::LoadCatalog(const wxString& domain, const wxString& lang) cat = m_loader->LoadCatalog(domain, baselang); } + if ( !cat ) + { + // It is OK to not load catalog if the msgid language and m_language match, + // in which case we can directly display the texts embedded in program's + // source code: + if ( msgIdLang == lang ) + return true; + } + if ( cat ) { // add it to the head of the list so that in GetString it will @@ -1618,19 +1621,18 @@ const wxString& wxTranslations::GetUntranslatedString(const wxString& str) } -const wxString& wxTranslations::GetString(const wxString& origString, - const wxString& domain) const +const wxString *wxTranslations::GetTranslatedString(const wxString& origString, + const wxString& domain) const { - return GetString(origString, origString, UINT_MAX, domain); + return GetTranslatedString(origString, UINT_MAX, domain); } -const wxString& wxTranslations::GetString(const wxString& origString, - const wxString& origString2, - unsigned n, - const wxString& domain) const +const wxString *wxTranslations::GetTranslatedString(const wxString& origString, + unsigned n, + const wxString& domain) const { if ( origString.empty() ) - return GetUntranslatedString(origString); + return NULL; const wxString *trans = NULL; wxMsgCatalog *pMsgCat; @@ -1665,14 +1667,9 @@ const wxString& wxTranslations::GetString(const wxString& origString, (!domain.empty() ? wxString::Format("domain '%s' ", domain) : wxString()), m_lang ); - - if (n == UINT_MAX) - return GetUntranslatedString(origString); - else - return GetUntranslatedString(n == 1 ? origString : origString2); } - return *trans; + return trans; }