Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 28 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/ )" ""
Expand All @@ -19,8 +21,13 @@ else
endif

# -----------------------------------------------------------------------------------------------------------------------------------------
# Internationalization

all: CPP RES UI
I18N_LANGUAGES :=

# -----------------------------------------------------------------------------------------------------------------------------------------

all: CPP RES QM UI

# -----------------------------------------------------------------------------------------------------------------------------------------
# C++ code
Expand All @@ -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

Expand Down Expand Up @@ -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

# -----------------------------------------------------------------------------------------------------------------------------------------

Expand All @@ -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
Expand Down Expand Up @@ -161,6 +182,11 @@ install:
# Install main code
install -m 755 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/
Expand Down
2 changes: 2 additions & 0 deletions src/cadence.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from shared_cadence import *
from shared_canvasjack import *
from shared_settings import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Import getoutput
Expand Down Expand Up @@ -2383,6 +2384,7 @@ def taskInMainThread():
app.setApplicationVersion(VERSION)
app.setOrganizationName("Cadence")
app.setWindowIcon(QIcon(":/scalable/cadence.svg"))
setup_i18n()

if haveDBus:
gDBus.loop = DBusQtMainLoop(set_as_default=True)
Expand Down
2 changes: 2 additions & 0 deletions src/catarina.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import ui_catarina_disconnectports
from shared_canvasjack import *
from shared_settings import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Try Import OpenGL
Expand Down Expand Up @@ -1308,6 +1309,7 @@ def closeEvent(self, event):
app.setApplicationVersion(VERSION)
app.setOrganizationName("Cadence")
app.setWindowIcon(QIcon(":/scalable/catarina.svg"))
setup_i18n()

# Show GUI
gui = CatarinaMainW()
Expand Down
2 changes: 2 additions & 0 deletions src/catia.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ui_catia
from shared_canvasjack import *
from shared_settings import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Try Import DBus
Expand Down Expand Up @@ -1393,6 +1394,7 @@ def closeEvent(self, event):
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",
Expand Down
2 changes: 2 additions & 0 deletions src/claudia.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import ui_claudia_runcustom
from shared_canvasjack import *
from shared_settings import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Try Import DBus
Expand Down Expand Up @@ -2750,6 +2751,7 @@ def closeEvent(self, event):
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",
Expand Down
2 changes: 2 additions & 0 deletions src/claudia_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import claudia_database as database
import ui_claudia_launcher
from shared import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Imports (Carla)
Expand Down Expand Up @@ -1352,6 +1353,7 @@ def closeEvent(self, event):
app.setApplicationVersion(VERSION)
app.setOrganizationName("Cadence")
app.setWindowIcon(QIcon(":/scalable/claudia-launcher.svg"))
setup_i18n()

# Do not close on SIGUSR1
signal(SIGUSR1, SIG_IGN)
Expand Down
2 changes: 2 additions & 0 deletions src/jacksettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# Imports (Custom Stuff)

import ui_settings_jack
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Try Import DBus
Expand Down Expand Up @@ -924,6 +925,7 @@ def done(self, r):

# App initialization
app = QApplication(sys_argv)
setup_i18n()

# Connect to DBus
if dbus:
Expand Down
2 changes: 2 additions & 0 deletions src/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import ui_logs
from shared import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Fix log text output (get rid of terminal colors stuff)
Expand Down Expand Up @@ -451,6 +452,7 @@ def done(self, r):
app.setApplicationVersion(VERSION)
app.setOrganizationName("Cadence")
app.setWindowIcon(QIcon(":/scalable/cadence.svg"))
setup_i18n()

# Show GUI
gui = LogsW(None)
Expand Down
2 changes: 2 additions & 0 deletions src/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import ui_render
from shared import *
from shared_i18n import *
from jacklib_helpers import *

# ------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -442,6 +443,7 @@ def done(self, r):
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",
Expand Down
49 changes: 49 additions & 0 deletions src/shared_i18n.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions src/systray.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
except:
TrayEngine = "Qt"

from shared_i18n import *

print("Using Tray Engine '%s'" % TrayEngine)

iActNameId = 0
Expand Down Expand Up @@ -680,6 +682,7 @@ def closeEvent(self, event):
QDialog.closeEvent(self, event)

app = QApplication(sys.argv)
setup_i18n()
gui = ExampleGUI()
gui.show()
sys.exit(gui.systray.exec_(app))