| @@ -29,6 +29,9 @@ ui_*.py | |||
| src/resources_rc.py | |||
| qrc_resources*.cpp | |||
| # Translation files | |||
| *.qm | |||
| # Binaries | |||
| c++/jackmeter/cadence-jackmeter | |||
| c++/xycontroller/cadence-xycontroller | |||
| @@ -10,6 +10,8 @@ DESTDIR = | |||
| LINK = ln -s | |||
| PYUIC ?= pyuic5 | |||
| PYRCC ?= pyrcc5 | |||
| PYLUPDATE ?= pylupdate5 | |||
| LRELEASE ?= lrelease | |||
| # Detect X11 rules dir | |||
| ifeq "$(wildcard /etc/X11/Xsession.d/ )" "" | |||
| @@ -19,8 +21,13 @@ else | |||
| endif | |||
| # ----------------------------------------------------------------------------------------------------------------------------------------- | |||
| # Internationalization | |||
| all: CPP RES UI | |||
| I18N_LANGUAGES := | |||
| # ----------------------------------------------------------------------------------------------------------------------------------------- | |||
| all: CPP RES QM UI | |||
| # ----------------------------------------------------------------------------------------------------------------------------------------- | |||
| # C++ code | |||
| @@ -41,6 +48,19 @@ RES: src/resources_rc.py | |||
| src/resources_rc.py: resources/resources.qrc | |||
| $(PYRCC) $< -o $@ | |||
| # ----------------------------------------------------------------------------------------------------------------------------------------- | |||
| # Translations | |||
| TS: $(patsubst %,resources/translations/cadence_%.ts,$(I18N_LANGUAGES)) | |||
| QM: $(patsubst %,resources/translations/cadence_%.qm,$(I18N_LANGUAGES)) | |||
| resources/translations/%.ts: | |||
| @install -d resources/translations | |||
| $(PYLUPDATE) src/*.py resources/ui/*.ui -ts $@ | |||
| resources/translations/%.qm: resources/translations/%.ts | |||
| $(LRELEASE) $< -qm $@ | |||
| # ----------------------------------------------------------------------------------------------------------------------------------------- | |||
| # UI code | |||
| @@ -74,7 +94,7 @@ src/ui_%.py: resources/ui/%.ui | |||
| clean: | |||
| $(MAKE) clean -C c++/jackmeter | |||
| $(MAKE) clean -C c++/xycontroller | |||
| rm -f *~ src/*~ src/*.pyc src/ui_*.py src/resources_rc.py | |||
| rm -f *~ src/*~ src/*.pyc src/ui_*.py src/resources_rc.py resources/translations/*.qm | |||
| # ----------------------------------------------------------------------------------------------------------------------------------------- | |||
| @@ -99,6 +119,7 @@ install: | |||
| install -d $(DESTDIR)$(PREFIX)/share/cadence/pulse2loopback/ | |||
| install -d $(DESTDIR)$(PREFIX)/share/cadence/icons/ | |||
| install -d $(DESTDIR)$(PREFIX)/share/cadence/templates/ | |||
| install -d $(DESTDIR)$(PREFIX)/share/cadence/translations/ | |||
| install -d $(X11_RC_DIR) | |||
| # Install script files and binaries | |||
| @@ -161,6 +182,11 @@ install: | |||
| # Install main code | |||
| install -m 644 src/*.py $(DESTDIR)$(PREFIX)/share/cadence/src/ | |||
| # Install translations | |||
| $(foreach l,$(I18N_LANGUAGES),install -m 644 \ | |||
| resources/translations/cadence_$(l).qm \ | |||
| $(DESTDIR)$(PREFIX)/share/cadence/translations/) | |||
| # Install addtional stuff for Cadence | |||
| install -m 644 data/pulse2jack/* $(DESTDIR)$(PREFIX)/share/cadence/pulse2jack/ | |||
| install -m 644 data/pulse2loopback/* $(DESTDIR)$(PREFIX)/share/cadence/pulse2loopback/ | |||
| @@ -41,6 +41,7 @@ import ui_cadence_rwait | |||
| from shared_cadence import * | |||
| from shared_canvasjack import * | |||
| from shared_settings import * | |||
| from shared_i18n import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Import getoutput | |||
| @@ -2362,6 +2363,7 @@ if __name__ == '__main__': | |||
| app.setApplicationVersion(VERSION) | |||
| app.setOrganizationName("Cadence") | |||
| app.setWindowIcon(QIcon(":/scalable/cadence.svg")) | |||
| setup_i18n() | |||
| if haveDBus: | |||
| gDBus.loop = DBusMainLoop(set_as_default=True) | |||
| @@ -42,6 +42,7 @@ import ui_catarina_connectports | |||
| import ui_catarina_disconnectports | |||
| from shared_canvasjack import * | |||
| from shared_settings import * | |||
| from shared_i18n import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Try Import OpenGL | |||
| @@ -1307,6 +1308,7 @@ if __name__ == '__main__': | |||
| app.setApplicationVersion(VERSION) | |||
| app.setOrganizationName("Cadence") | |||
| app.setWindowIcon(QIcon(":/scalable/catarina.svg")) | |||
| setup_i18n() | |||
| # Show GUI | |||
| gui = CatarinaMainW() | |||
| @@ -22,6 +22,7 @@ | |||
| import ui_catia | |||
| from shared_canvasjack import * | |||
| from shared_settings import * | |||
| from shared_i18n import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Try Import DBus | |||
| @@ -1384,6 +1385,7 @@ if __name__ == '__main__': | |||
| app.setApplicationVersion(VERSION) | |||
| app.setOrganizationName("Cadence") | |||
| app.setWindowIcon(QIcon(":/scalable/catia.svg")) | |||
| setup_i18n() | |||
| if jacklib is None: | |||
| QMessageBox.critical(None, app.translate("CatiaMainW", "Error"), app.translate("CatiaMainW", | |||
| @@ -42,6 +42,7 @@ import ui_claudia_projectproperties | |||
| import ui_claudia_runcustom | |||
| from shared_canvasjack import * | |||
| from shared_settings import * | |||
| from shared_i18n import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Try Import DBus | |||
| @@ -2742,6 +2743,7 @@ if __name__ == '__main__': | |||
| app.setApplicationVersion(VERSION) | |||
| app.setOrganizationName("Cadence") | |||
| app.setWindowIcon(QIcon(":/scalable/claudia.svg")) | |||
| setup_i18n() | |||
| if not haveDBus: | |||
| QMessageBox.critical(None, app.translate("ClaudiaMainW", "Error"), app.translate("ClaudiaMainW", | |||
| @@ -34,6 +34,7 @@ else: | |||
| import claudia_database as database | |||
| import ui_claudia_launcher | |||
| from shared import * | |||
| from shared_i18n import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Imports (Carla) | |||
| @@ -1357,6 +1358,7 @@ if __name__ == '__main__': | |||
| app.setApplicationVersion(VERSION) | |||
| app.setOrganizationName("Cadence") | |||
| app.setWindowIcon(QIcon(":/scalable/claudia-launcher.svg")) | |||
| setup_i18n() | |||
| # Do not close on SIGUSR1 | |||
| signal(SIGUSR1, SIG_IGN) | |||
| @@ -34,6 +34,7 @@ else: | |||
| # Imports (Custom Stuff) | |||
| import ui_settings_jack | |||
| from shared_i18n import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Try Import DBus | |||
| @@ -934,6 +935,7 @@ if __name__ == '__main__': | |||
| # App initialization | |||
| app = QApplication(sys_argv) | |||
| setup_i18n() | |||
| # Connect to DBus | |||
| if dbus: | |||
| @@ -33,6 +33,7 @@ else: | |||
| import ui_logs | |||
| from shared import * | |||
| from shared_i18n import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Fix log text output (get rid of terminal colors stuff) | |||
| @@ -451,6 +452,7 @@ if __name__ == '__main__': | |||
| app.setApplicationVersion(VERSION) | |||
| app.setOrganizationName("Cadence") | |||
| app.setWindowIcon(QIcon(":/scalable/cadence.svg")) | |||
| setup_i18n() | |||
| # Show GUI | |||
| gui = LogsW(None) | |||
| @@ -33,6 +33,7 @@ else: | |||
| import ui_render | |||
| from shared import * | |||
| from shared_i18n import * | |||
| from jacklib_helpers import * | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| @@ -442,6 +443,7 @@ if __name__ == '__main__': | |||
| app.setApplicationVersion(VERSION) | |||
| app.setOrganizationName("Cadence") | |||
| app.setWindowIcon(QIcon(":/scalable/cadence.svg")) | |||
| setup_i18n() | |||
| if jacklib is None: | |||
| QMessageBox.critical(None, app.translate("RenderW", "Error"), app.translate("RenderW", | |||
| @@ -0,0 +1,49 @@ | |||
| #!/usr/bin/env python3 | |||
| # -*- coding: utf-8 -*- | |||
| # Common/Shared code related to Internationalization | |||
| # Copyright (C) 2019 Filipe Coelho <falktx@falktx.com> | |||
| # | |||
| # This program is free software; you can redistribute it and/or modify | |||
| # it under the terms of the GNU General Public License as published by | |||
| # the Free Software Foundation; either version 2 of the License, or | |||
| # any later version. | |||
| # | |||
| # This program is distributed in the hope that it will be useful, | |||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| # GNU General Public License for more details. | |||
| # | |||
| # For a full copy of the GNU General Public License see the COPYING file | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Imports (Global) | |||
| import os, sys | |||
| if True: | |||
| from PyQt5.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo | |||
| else: | |||
| from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo | |||
| def setup_i18n(): | |||
| app = QCoreApplication.instance() | |||
| locale = QLocale() | |||
| syspath = sys.path[0] | |||
| qmpath = os.path.join(syspath, "..", "translations") | |||
| # Load translations from Cadence resources | |||
| translator = QTranslator() | |||
| if not translator.load(locale, "cadence", "_", qmpath): | |||
| return False | |||
| app.installTranslator(translator) | |||
| app.fAppTranslator = translator | |||
| # Load translations from Qt libraries | |||
| translator = QTranslator() | |||
| if not translator.load(locale, "qt", "_", qmpath): | |||
| translator.load(locale, "qt", "_", QLibraryInfo.location(QLibraryInfo.TranslationsPath)) | |||
| app.installTranslator(translator) | |||
| app.fSysTranslator = translator | |||
| return True | |||
| @@ -49,6 +49,8 @@ try: | |||
| except: | |||
| TrayEngine = "Qt" | |||
| from shared_i18n import * | |||
| print("Using Tray Engine '%s'" % TrayEngine) | |||
| iActNameId = 0 | |||
| @@ -680,6 +682,7 @@ if __name__ == '__main__': | |||
| QDialog.closeEvent(self, event) | |||
| app = QApplication(sys.argv) | |||
| setup_i18n() | |||
| gui = ExampleGUI() | |||
| gui.show() | |||
| sys.exit(gui.systray.exec_(app)) | |||