From 9c7719831a88fa214431ae1814b82fdf141a8df2 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Thu, 22 Oct 2020 07:44:54 +0200 Subject: [PATCH] Use gettext for generated GUI code Instead of using the Qt system. So I can use one single way for everything Also join all the targets into one single target. --- Makefile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 9066e20..c8a9315 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,19 @@ .PHONY: gui gui: relational_gui/survey.py relational_gui/maingui.py relational_gui/rel_edit.py relational_gui/resources.py -relational_gui/survey.py: - pyuic5 relational_gui/survey.ui > relational_gui/survey.py - -relational_gui/maingui.py: - pyuic5 relational_gui/maingui.ui > relational_gui/maingui.py - sed -i 's/QtWidgets.QPlainTextEdit/editor.Editor/g' relational_gui/maingui.py - echo 'from . import editor' >> relational_gui/maingui.py - -relational_gui/rel_edit.py: - pyuic5 relational_gui/rel_edit.ui > relational_gui/rel_edit.py +relational_gui/maingui.py relational_gui/survey.py relational_gui/rel_edit.py: + # Create .py file + pyuic5 $(basename $@).ui > $@ + # Use my custom editor class + sed -i 's/QtWidgets.QPlainTextEdit/editor.Editor/g' $@ + echo 'from . import editor' >> $@ + # Use gettext instead of Qt translations + echo 'from gettext import gettext as _' >> $@ + sed -i \ + -e 's/_translate("MainWindow", /_(/g' \ + -e 's/_translate("Dialog", /_(/g' \ + -e 's/_translate("Form", /_(/g' \ + $@ relational_gui/resources.py: pyrcc5 relational_gui/resources.qrc > relational_gui/resources.py