Skip to content

Commit

Permalink
feat: initialization for translation support
Browse files Browse the repository at this point in the history
  • Loading branch information
koebi authored and TheGreatRefrigerator committed Jul 25, 2023
1 parent 5221045 commit a0fa23e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ docs/wiki/OSMtools.wiki/
./LICENSE.md
./apikey.txt
*.pyc
i18n/
test/
.spyproject/
dist/
Expand Down
19 changes: 19 additions & 0 deletions ORStools/ORStoolsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"""

from qgis.core import QgsApplication
from PyQt5.QtCore import QTranslator, QSettings, qVersion, QCoreApplication
import os.path

from .gui import ORStoolsDialog
from .proc import provider
Expand All @@ -48,6 +50,23 @@ def __init__(self, iface):
self.dialog = ORStoolsDialog.ORStoolsDialogMain(iface)
self.provider = provider.ORStoolsProvider()

# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)

# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'orstools_{}.qm'.format(locale))

if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)

if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)

def initGui(self):
"""Create the menu entries and toolbar icons inside the QGIS GUI."""

Expand Down
Binary file added ORStools/i18n/symbology-style.db
Binary file not shown.
15 changes: 15 additions & 0 deletions ORStools/i18n/translate.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FORMS = ../gui/ORStoolsDialogConfigUI.ui \
../gui/ORStoolsDialogUI.ui

SOURCES = ../common/directions_core.py \
../proc/base_processing_algorithm.py \
../proc/directions_lines_proc.py \
../proc/directions_points_layer_proc.py \
../proc/directions_points_layers_proc.py \
../proc/isochrones_layer_proc.py \
../proc/isochrones_point_proc.py \
../proc/matrix_proc.py \
../gui/ORStoolsDialog.py \
../gui/ORStoolsDialogConfig.py

TRANSLATIONS = orstools_de.ts

0 comments on commit a0fa23e

Please sign in to comment.