Browse Source

make translation process works with jpcima patch https://github.com/falkTX/Cadence/pull/249

pull/362/head
Houston4444 2 years ago
parent
commit
70705e569c
17 changed files with 10516 additions and 2 deletions
  1. +3
    -0
      .gitignore
  2. +33
    -2
      Makefile
  3. +4987
    -0
      locale/cadence_en.ts
  4. +4988
    -0
      locale/cadence_fr.ts
  5. +49
    -0
      locale/raysession.pro
  6. +40
    -0
      locale/update_pro.sh
  7. +2
    -0
      src/cadence.py
  8. +2
    -0
      src/catarina.py
  9. +2
    -0
      src/catia.py
  10. +2
    -0
      src/claudia.py
  11. +2
    -0
      src/claudia_launcher.py
  12. +2
    -0
      src/jacksettings.py
  13. +2
    -0
      src/logs.py
  14. +2
    -0
      src/render.py
  15. +49
    -0
      src/shared_i18n.py
  16. +3
    -0
      src/systray.py
  17. +348
    -0
      translate_jpcima.patch

+ 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


+ 33
- 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 UI locale

# -----------------------------------------------------------------------------------------------------------------------------------------
# C++ code
@@ -41,6 +48,24 @@ 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 $@

locale: locale/cadence_en.qm locale/cadence_fr.qm
locale/%.qm: locale/%.ts
$(LRELEASE) $< -qm $@

# -----------------------------------------------------------------------------------------------------------------------------------------
# UI code

@@ -74,7 +99,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 +124,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 +187,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/


+ 4987
- 0
locale/cadence_en.ts
File diff suppressed because it is too large
View File


+ 4988
- 0
locale/cadence_fr.ts
File diff suppressed because it is too large
View File


+ 49
- 0
locale/raysession.pro View File

@@ -0,0 +1,49 @@
FORMS += ../resources/ui/cadence_rwait.ui
FORMS += ../resources/ui/cadence_tb_a2j.ui
FORMS += ../resources/ui/cadence_tb_alsa.ui
FORMS += ../resources/ui/cadence_tb_jack.ui
FORMS += ../resources/ui/cadence_tb_pa.ui
FORMS += ../resources/ui/cadence.ui
FORMS += ../resources/ui/catarina_addgroup.ui
FORMS += ../resources/ui/catarina_addport.ui
FORMS += ../resources/ui/catarina_connectports.ui
FORMS += ../resources/ui/catarina_disconnectports.ui
FORMS += ../resources/ui/catarina_removegroup.ui
FORMS += ../resources/ui/catarina_removeport.ui
FORMS += ../resources/ui/catarina_renamegroup.ui
FORMS += ../resources/ui/catarina_renameport.ui
FORMS += ../resources/ui/catarina.ui
FORMS += ../resources/ui/catia.ui
FORMS += ../resources/ui/claudia_createroom.ui
FORMS += ../resources/ui/claudia_launcher_app.ui
FORMS += ../resources/ui/claudia_launcher.ui
FORMS += ../resources/ui/claudia_projectname.ui
FORMS += ../resources/ui/claudia_projectproperties.ui
FORMS += ../resources/ui/claudia_runcustom.ui
FORMS += ../resources/ui/claudia_studiolist.ui
FORMS += ../resources/ui/claudia_studioname.ui
FORMS += ../resources/ui/claudia.ui
FORMS += ../resources/ui/logs.ui
FORMS += ../resources/ui/render.ui
FORMS += ../resources/ui/settings_app.ui
FORMS += ../resources/ui/settings_jack.ui
FORMS += ../resources/ui/xycontroller.ui
SOURCES += ../src/cadence.py
SOURCES += ../src/cadence_session_start.py
SOURCES += ../src/catarina.py
SOURCES += ../src/catia.py
SOURCES += ../src/claudia_launcher.py
SOURCES += ../src/claudia.py
SOURCES += ../src/jacklib_helpers.py
SOURCES += ../src/jacklib.py
SOURCES += ../src/jacksettings.py
SOURCES += ../src/patchcanvas.py
SOURCES += ../src/render.py
SOURCES += ../src/shared_cadence.py
SOURCES += ../src/shared_canvasjack.py
SOURCES += ../src/shared.py
SOURCES += ../src/systray.py

TRANSLATIONS += cadence_en.ts
TRANSLATIONS += cadence_fr.ts


+ 40
- 0
locale/update_pro.sh View File

@@ -0,0 +1,40 @@
#!/bin/bash

# This is a little script for refresh raysession.pro and update .ts files.
# TRANSLATOR: You don't need to run it !

contents=""

this_script=`realpath "$0"`
locale_root=`dirname "$this_script"`
code_root=`dirname "$locale_root"`
cd "$code_root/resources/ui/"

for file in *.ui;do
contents+="FORMS += ../resources/ui/$file
"
done


# for dir in daemon gui gui/patchcanvas shared;do
cd "$code_root/src"
for file in *.py;do
[[ "$file" =~ ^ui_ ]] && continue
if cat "$file"|grep -q ".tr(";then
contents+="SOURCES += ../src/${file}
"
fi
done
# done

contents+="
TRANSLATIONS += cadence_en.ts
TRANSLATIONS += cadence_fr.ts
"

echo "$contents" > "$locale_root/raysession.pro"

pylupdate5 "$locale_root/raysession.pro"


+ 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
@@ -2418,6 +2419,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
@@ -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",


+ 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
@@ -2741,6 +2742,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)
@@ -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)


+ 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
@@ -934,6 +935,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, "..", "locale")

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

+ 348
- 0
translate_jpcima.patch View File

@@ -0,0 +1,348 @@
From 888ab07e42f37b650db7fe0dba866cf13854ce18 Mon Sep 17 00:00:00 2001
From: JP Cimalando <jp-dev@inbox.ru>
Date: Fri, 22 Mar 2019 15:17:16 +0100
Subject: [PATCH] Build, install and load translation files

---
.gitignore | 3 +++
Makefile | 30 +++++++++++++++++++++++--
src/cadence.py | 2 ++
src/catarina.py | 2 ++
src/catia.py | 2 ++
src/claudia.py | 2 ++
src/claudia_launcher.py | 2 ++
src/jacksettings.py | 2 ++
src/logs.py | 2 ++
src/render.py | 2 ++
src/shared_i18n.py | 49 +++++++++++++++++++++++++++++++++++++++++
src/systray.py | 3 +++
12 files changed, 99 insertions(+), 2 deletions(-)
create mode 100644 src/shared_i18n.py

diff --git a/.gitignore b/.gitignore
index 326ed27f..99634a3d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile b/Makefile
index 337ef96b..33983fc7 100644
--- a/Makefile
+++ b/Makefile
@@ -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/
diff --git a/src/cadence.py b/src/cadence.py
index 88816d93..b3beebf9 100755
--- a/src/cadence.py
+++ b/src/cadence.py
@@ -41,6 +41,7 @@
from shared_cadence import *
from shared_canvasjack import *
from shared_settings import *
+from shared_i18n import *
# ------------------------------------------------------------------------------------------------------------
# Import getoutput
@@ -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)
diff --git a/src/catarina.py b/src/catarina.py
index c5b375c6..d75c9733 100755
--- a/src/catarina.py
+++ b/src/catarina.py
@@ -42,6 +42,7 @@
import ui_catarina_disconnectports
from shared_canvasjack import *
from shared_settings import *
+from shared_i18n import *
# ------------------------------------------------------------------------------------------------------------
# Try Import OpenGL
@@ -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()
diff --git a/src/catia.py b/src/catia.py
index 8101d601..13d07190 100755
--- a/src/catia.py
+++ b/src/catia.py
@@ -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 @@ 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",
diff --git a/src/claudia.py b/src/claudia.py
index 9e5bb9e1..d6bbad28 100755
--- a/src/claudia.py
+++ b/src/claudia.py
@@ -42,6 +42,7 @@
import ui_claudia_runcustom
from shared_canvasjack import *
from shared_settings import *
+from shared_i18n import *
# ------------------------------------------------------------------------------------------------------------
# Try Import DBus
@@ -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",
diff --git a/src/claudia_launcher.py b/src/claudia_launcher.py
index dc060585..2812f4c0 100755
--- a/src/claudia_launcher.py
+++ b/src/claudia_launcher.py
@@ -34,6 +34,7 @@
import claudia_database as database
import ui_claudia_launcher
from shared import *
+from shared_i18n import *
# ------------------------------------------------------------------------------------------------------------
# Imports (Carla)
@@ -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)
diff --git a/src/jacksettings.py b/src/jacksettings.py
index 69e9f759..3e73194c 100755
--- a/src/jacksettings.py
+++ b/src/jacksettings.py
@@ -34,6 +34,7 @@
# Imports (Custom Stuff)
import ui_settings_jack
+from shared_i18n import *
# ------------------------------------------------------------------------------------------------------------
# Try Import DBus
@@ -924,6 +925,7 @@ def done(self, r):
# App initialization
app = QApplication(sys_argv)
+ setup_i18n()
# Connect to DBus
if dbus:
diff --git a/src/logs.py b/src/logs.py
index 06982a4b..bfb425e8 100755
--- a/src/logs.py
+++ b/src/logs.py
@@ -33,6 +33,7 @@
import ui_logs
from shared import *
+from shared_i18n import *
# ------------------------------------------------------------------------------------------------------------
# Fix log text output (get rid of terminal colors stuff)
@@ -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)
diff --git a/src/render.py b/src/render.py
index ff1af791..e52b6b53 100755
--- a/src/render.py
+++ b/src/render.py
@@ -33,6 +33,7 @@
import ui_render
from shared import *
+from shared_i18n import *
from jacklib_helpers import *
# ------------------------------------------------------------------------------------------------------------
@@ -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",
diff --git a/src/shared_i18n.py b/src/shared_i18n.py
new file mode 100644
index 00000000..e0c1d90b
--- /dev/null
+++ b/src/shared_i18n.py
@@ -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
diff --git a/src/systray.py b/src/systray.py
index 5a3fb593..34dcc3d5 100755
--- a/src/systray.py
+++ b/src/systray.py
@@ -49,6 +49,8 @@
except:
TrayEngine = "Qt"
+from shared_i18n import *
+
print("Using Tray Engine '%s'" % TrayEngine)
iActNameId = 0
@@ -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))

Loading…
Cancel
Save