Skip to content

Commit

Permalink
Add version suffix to gettext message catalog files
Browse files Browse the repository at this point in the history
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 #2219

Co-Authored-By: Vadim Zeitlin <vadim@wxwidgets.org>
  • Loading branch information
andriybyelikov and vadz committed Feb 15, 2021
1 parent 62a760c commit ded4da5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Makefile.in
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion build/bakefiles/wx.bkl
Expand Up @@ -137,7 +137,7 @@
<using module="gettext"/>
<gettext-catalogs id="locale">
<srcdir>$(SRCDIR)/locale</srcdir>
<catalog-name>wxstd</catalog-name>
<catalog-name>wxstd-$(WX_RELEASE)</catalog-name>
<linguas>
ca cs da de el es fi fr hu id it ja nl pl ru sl sv tr uk
zh zh_CN zh_TW
Expand Down
14 changes: 11 additions & 3 deletions src/common/translation.cpp
Expand Up @@ -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__
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ded4da5

Please sign in to comment.