From ded4da5ce50f6072fcf1a4021d860cd5706d2e89 Mon Sep 17 00:00:00 2001 From: Andriy Byelikov Date: Sun, 7 Feb 2021 20:17:24 +0100 Subject: [PATCH] Add version suffix to gettext message catalog files Change "make install" to install catalog files with version suffix and modify the sources to look for suffixed catalog first, while still falling back to just the base name if the variant with the version is not found, because the message catalogs are copied manually in practice under MSW/macOS systems and so won't have the version suffix there. This allows to make message catalogs installed by different wxWidgets versions to coexist on the same system, see https://groups.google.com/g/wx-users/c/L9gC8UgrO6Y Closes https://github.com/wxWidgets/wxWidgets/pull/2219 Co-Authored-By: Vadim Zeitlin --- Makefile.in | 6 +++--- build/bakefiles/wx.bkl | 2 +- src/common/translation.cpp | 14 +++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Makefile.in b/Makefile.in index d21458bc93..b9c14d553a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14778,14 +14778,14 @@ locale_install: $(INSTALL_DIR) $(DESTDIR)$(datadir)/locale/$$l ; \ $(INSTALL_DIR) $(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES ; \ if test -f $(srcdir)/locale/$$l.mo ; then \ - $(INSTALL_DATA) $(srcdir)/locale/$$l.mo $(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES/wxstd.mo ; \ + $(INSTALL_DATA) $(srcdir)/locale/$$l.mo $(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES/wxstd-$(WX_RELEASE).mo ; \ fi ; \ done locale_uninstall: for l in $(LOCALE_LINGUAS) ; do \ - if test -f $(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES/wxstd.mo ; then \ - rm -f $(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES/wxstd.mo ; \ + if test -f $(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES/wxstd-$(WX_RELEASE).mo ; then \ + rm -f $(DESTDIR)$(datadir)/locale/$$l/LC_MESSAGES/wxstd-$(WX_RELEASE).mo ; \ fi ; \ done diff --git a/build/bakefiles/wx.bkl b/build/bakefiles/wx.bkl index 4165e1a849..8107a99d4a 100644 --- a/build/bakefiles/wx.bkl +++ b/build/bakefiles/wx.bkl @@ -137,7 +137,7 @@ $(SRCDIR)/locale - wxstd + wxstd-$(WX_RELEASE) ca cs da de el es fi fr hu id it ja nl pl ru sl sv tr uk zh zh_CN zh_TW diff --git a/src/common/translation.cpp b/src/common/translation.cpp index d1fc7f5c1f..dc06114bdc 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -45,6 +45,7 @@ #include "wx/fontmap.h" #include "wx/scopedptr.h" #include "wx/stdpaths.h" +#include "wx/version.h" #include "wx/private/threadinfo.h" #ifdef __WINDOWS__ @@ -1519,10 +1520,17 @@ wxArrayString wxTranslations::GetAvailableTranslations(const wxString& domain) c bool wxTranslations::AddStdCatalog() { - if ( !AddCatalog(wxS("wxstd")) ) - return false; + // Try loading the message catalog for this version first, but fall back to + // the name without the version if it's not found, as message catalogs + // typically won't have the version in their names under non-Unix platforms + // (i.e. where they're not installed by our own "make install"). + if ( AddCatalog("wxstd-" wxSTRINGIZE(wxMAJOR_VERSION) "." wxSTRINGIZE(wxMINOR_VERSION)) ) + return true; - return true; + if ( AddCatalog(wxS("wxstd")) ) + return true; + + return false; } #if !wxUSE_UNICODE