Browse Source

Build, install and load translation files

pull/249/head
JP Cimalando 5 years ago
parent
commit
888ab07e42
12 changed files with 99 additions and 2 deletions
  1. +3
    -0
      .gitignore
  2. +28
    -2
      Makefile
  3. +2
    -0
      src/cadence.py
  4. +2
    -0
      src/catarina.py
  5. +2
    -0
      src/catia.py
  6. +2
    -0
      src/claudia.py
  7. +2
    -0
      src/claudia_launcher.py
  8. +2
    -0
      src/jacksettings.py
  9. +2
    -0
      src/logs.py
  10. +2
    -0
      src/render.py
  11. +49
    -0
      src/shared_i18n.py
  12. +3
    -0
      src/systray.py

+ 3
- 0
.gitignore View File

@@ -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


+ 28
- 2
Makefile View File

@@ -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 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/


+ 2
- 0
src/cadence.py View File

@@ -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
@@ -2383,6 +2384,7 @@ if __name__ == '__main__':
app.setApplicationVersion(VERSION)
app.setOrganizationName("Cadence")
app.setWindowIcon(QIcon(":/scalable/cadence.svg"))
setup_i18n()

if haveDBus:
gDBus.loop = DBusQtMainLoop(set_as_default=True)


+ 2
- 0
src/catarina.py View File

@@ -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
@@ -1308,6 +1309,7 @@ if __name__ == '__main__':
app.setApplicationVersion(VERSION)
app.setOrganizationName("Cadence")
app.setWindowIcon(QIcon(":/scalable/catarina.svg"))
setup_i18n()

# Show GUI
gui = CatarinaMainW()


+ 2
- 0
src/catia.py View File

@@ -22,6 +22,7 @@
import ui_catia
from shared_canvasjack import *
from shared_settings import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Try Import DBus
@@ -1393,6 +1394,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",


+ 2
- 0
src/claudia.py View File

@@ -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
@@ -2750,6 +2751,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",


+ 2
- 0
src/claudia_launcher.py View File

@@ -34,6 +34,7 @@ else:
import claudia_database as database
import ui_claudia_launcher
from shared import *
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Imports (Carla)
@@ -1352,6 +1353,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)


+ 2
- 0
src/jacksettings.py View File

@@ -34,6 +34,7 @@ else:
# Imports (Custom Stuff)

import ui_settings_jack
from shared_i18n import *

# ------------------------------------------------------------------------------------------------------------
# Try Import DBus
@@ -924,6 +925,7 @@ if __name__ == '__main__':

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

# Connect to DBus
if dbus:


+ 2
- 0
src/logs.py View File

@@ -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)


+ 2
- 0
src/render.py View File

@@ -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",


+ 49
- 0
src/shared_i18n.py View File

@@ -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
- 0
src/systray.py View File

@@ -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))

Loading…
Cancel
Save