diff --git a/autoZoomer/Messages.sh b/autoZoomer/Messages.sh new file mode 100644 index 0000000..f3ee58a --- /dev/null +++ b/autoZoomer/Messages.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +XGETTEXT_FLAGS_PYTHON="\ +--copyright-holder=This_file_is_part_of_KDE \ +--msgid-bugs-address=http://bugs.kde.org \ +--from-code=UTF-8 \ +-L Python \ +-ki18n:1 -ki18np:1,2 \ +" + +$XGETTEXT_PROGRAM $XGETTEXT_FLAGS_PYTHON `find . -name '*.py'` -o $podir/autoZoomer.pot diff --git a/autoZoomer/button.py b/autoZoomer/button.py index 4adb5e1..55ba8ac 100644 --- a/autoZoomer/button.py +++ b/autoZoomer/button.py @@ -19,6 +19,7 @@ import Falkon import os from PySide2 import QtGui +from autoZoomer.i18n import i18n class AutoZoomerButton(Falkon.AbstractButtonInterface): @@ -29,8 +30,8 @@ class AutoZoomerButton(Falkon.AbstractButtonInterface): self.manager = manager self.setIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), "icon.svg"))) - self.setTitle("Auto Zoomer") - self.setToolTip("Save current zoom level") + self.setTitle(i18n("Auto Zoomer")) + self.setToolTip(i18n("Save current zoom level")) self.clicked.connect(self.onClicked) diff --git a/autoZoomer/i18n.py b/autoZoomer/i18n.py new file mode 100644 index 0000000..5c0bdbb --- /dev/null +++ b/autoZoomer/i18n.py @@ -0,0 +1,40 @@ +# ============================================================ +# Falkon - Qt web browser +# Copyright (C) 2018 David Rosca +# Copyright (C) 2019 Juraj Oravec +# +# 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 3 of the License, or +# (at your option) 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# ============================================================ +import gettext +import os +from PySide2 import QtCore + +locale = QtCore.QLocale.system() +languages = [ + locale.name(), + locale.bcp47Name() +] +i = locale.name().find('_') +if i > 0: + languages.append(locale.name()[:i]) + +localedir = QtCore.QStandardPaths.locate( + QtCore.QStandardPaths.GenericDataLocation, + os.path.join(os.path.dirname(__file__), "locale"), + QtCore.QStandardPaths.LocateDirectory +) + +t = gettext.translation('falkon_' + __package__, localedir, languages, fallback=True) +i18n = t.gettext +i18np = t.ngettext diff --git a/autoZoomer/settingsDialog.py b/autoZoomer/settingsDialog.py index 0180925..e35d383 100644 --- a/autoZoomer/settingsDialog.py +++ b/autoZoomer/settingsDialog.py @@ -19,6 +19,7 @@ import os from PySide2 import QtCore, QtWidgets, QtUiTools from autoZoomer.listItem import ListItem +from autoZoomer.i18n import i18n class SettingsDialog(QtWidgets.QDialog): @@ -45,6 +46,8 @@ class SettingsDialog(QtWidgets.QDialog): layout.addWidget(self.ui) self.setLayout(layout) + self.translations() + self.ui.checkBoxEnableAutoZoomer.setChecked(self.config["active"]) self.ui.checkBoxDefaultZoom.setChecked(self.config["defaultZoom"]) @@ -64,6 +67,13 @@ class SettingsDialog(QtWidgets.QDialog): self.ui.buttonBoxConfirm.accepted.connect(self.accept) self.ui.buttonBoxConfirm.rejected.connect(self.reject) + def translations(self): + self.setWindowTitle(i18n("Auto Zoomer Settings")) + self.ui.pushButtonAdd.setText(i18n("Add")) + self.ui.pushButtonRemove.setText(i18n("Remove")) + self.ui.checkBoxEnableAutoZoomer.setText(i18n("Enable Auto Zoomer")) + self.ui.checkBoxDefaultZoom.setText(i18n("On unknown host zoom to default zoom level")) + def addListItem(self, host, zoom=6, active=True): if not host: return