From a255c995a18e60ff48fd1b337b2ce0a13843421d Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 20 Sep 2013 17:27:59 +0000 Subject: [PATCH] Try loading even English translations if provided. Doing so has negligible cost and can be useful in some situations (e.g. when using symbolic msgids despite gettext best practices). Patch by tmsorensen. Fixes #15522. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74849 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/translation.h | 2 +- src/common/translation.cpp | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/wx/translation.h b/include/wx/translation.h index a5c0c9f75a..187caf366b 100644 --- a/include/wx/translation.h +++ b/include/wx/translation.h @@ -169,7 +169,7 @@ public: private: // perform loading of the catalog via m_loader - bool LoadCatalog(const wxString& domain, const wxString& lang); + bool LoadCatalog(const wxString& domain, const wxString& lang, const wxString& msgIdLang); // find catalog by name in a linked list, return NULL if !found wxMsgCatalog *FindCatalog(const wxString& domain) const; diff --git a/src/common/translation.cpp b/src/common/translation.cpp index e6f5373683..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 -- 2.45.2