add internationalization support

master
Hans P. Möller 4 years ago
parent 01401a60fc
commit af0e529044

@ -18,28 +18,31 @@
import sys import sys
from argparse import ArgumentParser from argparse import ArgumentParser
import gettext
from lubuntubreeze import breezeconfig from lubuntubreeze import breezeconfig
if __name__ == "__main__": if __name__ == "__main__":
localesApp ="lubuntu-breeze-config"
localesDir ="/usr/share/locale"
gettext.bindtextdomain(localesApp, localesDir)
gettext.textdomain(localesApp)
_ = gettext.gettext
parser = ArgumentParser() parser = ArgumentParser()
parser.add_argument('--version', parser.add_argument('--version',
action='version', action='version',
version='%(prog)s 0.1') version='%(prog)s 0.1')
parser.add_argument("--data-dir", parser.add_argument("--data-dir",
dest="datadir", dest="datadir",
default="/usr/share/lubuntu-breeze-config", # modificar al final default="/usr/share/lubuntu-breeze-config",
help="data directory for UI files") help=_("data directory for UI files, default "
"/usr/share/lubuntu-breeze-config"))
parser.add_argument("--bin-dir", parser.add_argument("--bin-dir",
dest="bindir", dest="bindir",
default="/bin", # modificar al final default="/bin",
help="directory where this script is, default /bin") help=_("directory where this script is, default /bin"))
options = parser.parse_args() options = parser.parse_args()
# TODO translations replace gettext with _ ???
# localesApp="lubuntu-breeze"
# localesDir="/usr/share/locale"
# gettext.bindtextdomain(localesApp, localesDir)
# gettext.textdomain(localesApp)
# to test run as "./breeze-config --data-dir data --bin-dir ." # to test run as "./breeze-config --data-dir data --bin-dir ."
breezeconfig.main(sys.argv, options) breezeconfig.main(sys.argv, options)

3
debian/control vendored

@ -6,7 +6,8 @@ Build-Depends: debhelper-compat (= 12),
dh-python, dh-python,
python3-all, python3-all,
python3-setuptools, python3-setuptools,
xvfb xvfb,
gettext
Standards-Version: 4.5.0 Standards-Version: 4.5.0
Rules-Requires-Root: no Rules-Requires-Root: no
Testsuite: autopkgtest-pkg-python Testsuite: autopkgtest-pkg-python

@ -1,2 +1 @@
# data/breeze-color.desktop /usr/share/applications/breeze-color.desktop # usr/share/locale/*
# data/designer /usr/share/lubuntu-breeze-color/designer

@ -25,7 +25,6 @@ from PyQt5.QtWidgets import (QWidget, QApplication, QDialogButtonBox)
from PyQt5.QtCore import (QDir, qDebug, QSettings) from PyQt5.QtCore import (QDir, qDebug, QSettings)
from PyQt5 import uic from PyQt5 import uic
from gettext import gettext as _ from gettext import gettext as _
# better than in main "_ = gettext.gettext" for testing
class MainWindow(QWidget): class MainWindow(QWidget):
@ -52,13 +51,15 @@ class MainWindow(QWidget):
self.label3b.setText(_("Opaque")) self.label3b.setText(_("Opaque"))
t = _("Applications need to be restarted for changes to take effect.") t = _("Applications need to be restarted for changes to take effect.")
t += "<br/>" t += "<br/>"
t += _("In case of pcmanfm-qt, since it handles the desktop, ") t += _("In case of pcmanfm-qt, since it handles the desktop, "
t += _("a restart of the desktop is needed") + "<br/>" "a restart of the desktop is needed")
t += "<br/>"
t += _("Easier, restart session.") t += _("Easier, restart session.")
t += "<br/>" t += "<br/>"
t += _("Best results if a matching GTK Theme is selected.") t += _("Best results if a matching GTK Theme is selected.")
t += "<br/>" t += "<br/>"
t += _("A compositor (Compton) needs to be enabled for transparency.") t += _("Compton (or other compositor) needs to be enabled "
"for transparency.")
self.note.setText('<font size="-1">' + t + '</font>') self.note.setText('<font size="-1">' + t + '</font>')
sDir = QDir(self.schemeDir) sDir = QDir(self.schemeDir)
@ -152,5 +153,4 @@ class App(QApplication):
def main(args, options): def main(args, options):
global app global app
app = App(options, args) app = App(options, args)
# app.setWindowIcon(QIcon.fromTheme("preferences-desktop-color"))
app.exec_() app.exec_()

@ -0,0 +1,75 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-11 12:36-0300\n"
"PO-Revision-Date: 2020-09-11 13:04-0300\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: de\n"
#: lubuntubreeze/breezeconfig.py:48
msgid "Select Color Scheme for Breeze Qt Style:"
msgstr "Wählen Sie das Farbschema für Breeze Qt Style:"
#: lubuntubreeze/breezeconfig.py:49
msgid "Menu Transparency"
msgstr "Menü Transparenz"
#: lubuntubreeze/breezeconfig.py:50
msgid "Transparent"
msgstr "Transparent"
#: lubuntubreeze/breezeconfig.py:51
msgid "Opaque"
msgstr "Undurchsichtig"
#: lubuntubreeze/breezeconfig.py:52
msgid "Applications need to be restarted for changes to take effect."
msgstr ""
"Anwendungen müssen neu gestartet werden, damit Änderungen wirksam werden."
#: lubuntubreeze/breezeconfig.py:54
msgid ""
"In case of pcmanfm-qt, since it handles the desktop, a restart of the "
"desktop is needed"
msgstr ""
"Im Fall von pcmanfm-qt ist ein Neustart des Desktops erforderlich, da "
"dieser den Desktop verwaltet"
#: lubuntubreeze/breezeconfig.py:57
msgid "Easier, restart session."
msgstr "Einfachere, Sitzung neu starten."
#: lubuntubreeze/breezeconfig.py:59
msgid "Best results if a matching GTK Theme is selected."
msgstr "Beste Ergebnisse, wenn ein passendes GTK-Thema ausgewählt ist."
#: lubuntubreeze/breezeconfig.py:61
msgid "Compton (or other compositor) needs to be enabled for transparency."
msgstr ""
"Compton (oder ein anderer Compositor) muss für Transparenz aktiviert sein."
#: lubuntubreeze/breezeconfig.py:68
msgid "None"
msgstr "Keiner"
#: breeze-config:39
msgid "data directory for UI files, default /usr/share/lubuntu-breeze-config"
msgstr ""
"Datenverzeichnis für UI-Dateien, Standard / usr / share / lubuntu-windze-"
"config"
#: breeze-config:44
msgid "directory where this script is, default /bin"
msgstr "Verzeichnis, in dem sich dieses Skript befindet, Standard / bin"

@ -1,37 +1,74 @@
# SOME DESCRIPTIVE TITLE. # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: \n"
"POT-Creation-Date: 2020-03-02 20:52-0300\n" "Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "POT-Creation-Date: 2020-09-11 12:36-0300\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "PO-Revision-Date: 2020-09-11 12:44-0300\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n" "X-Generator: Poedit 2.3\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: es\n"
#: lubuntubreeze/breezeconfig.py:48
#: lubuntuBreeze.py:39
msgid "Select Color Scheme for Breeze Qt Style:" msgid "Select Color Scheme for Breeze Qt Style:"
msgstr "Selecciona el Esquema de Color de Breeze para el estilo Qt" msgstr "Selecciona el Esquema de Color de Breeze para el estilo Qt:"
#: lubuntubreeze/breezeconfig.py:49
msgid "Menu Transparency"
msgstr "Transparencia de Menú"
#: lubuntubreeze/breezeconfig.py:50
msgid "Transparent"
msgstr "Transparente"
#: lubuntuBreeze.py:40 #: lubuntubreeze/breezeconfig.py:51
msgid "Opaque"
msgstr "Opaco"
#: lubuntubreeze/breezeconfig.py:52
msgid "Applications need to be restarted for changes to take effect." msgid "Applications need to be restarted for changes to take effect."
msgstr "Las aplicaciones se deben reiniciar para que los cambios tengan efecto." msgstr ""
"Las aplicaciones se deben reiniciar para que los cambios tengan efecto."
#: lubuntuBreeze.py:42 #: lubuntubreeze/breezeconfig.py:54
msgid "In case of pcmanfm-qt, since it handles the desktop, a restart of the desktop is needed" msgid ""
msgstr "En caso de pcmanfm-qt, dado que maneja el escritorio, un reinicio del escritorio es necesario" "In case of pcmanfm-qt, since it handles the desktop, a restart of the "
"desktop is needed"
msgstr ""
"En caso de pcmanfm-qt, dado que maneja el escritorio, un reinicio del "
"escritorio es necesario"
#: lubuntuBreeze.py:44 #: lubuntubreeze/breezeconfig.py:57
msgid "Easier, restart session." msgid "Easier, restart session."
msgstr "Más fácil es reiniciar la sesión" msgstr "Más fácil es reiniciar la sesión."
#: lubuntuBreeze.py:46 #: lubuntubreeze/breezeconfig.py:59
msgid "Best results if a matching GTK Theme is selected." msgid "Best results if a matching GTK Theme is selected."
msgstr "Mejores resultados si se ocupa un tema GTK que se asemeje." msgstr "Mejores resultados si se ocupa un tema GTK que se asemeje."
#: lubuntubreeze/breezeconfig.py:61
msgid "Compton (or other compositor) needs to be enabled for transparency."
msgstr "Compton (u otro compositor) debe estar activo para transparencias."
#: lubuntubreeze/breezeconfig.py:68
msgid "None"
msgstr "Ninguno"
#: breeze-config:39
msgid "data directory for UI files, default /usr/share/lubuntu-breeze-config"
msgstr ""
"directorio de datos para archivos UI, por defecto /usr/share/lubuntu-"
"breeze-config"
#: breeze-config:44
msgid "directory where this script is, default /bin"
msgstr "directorio donde está este script, por defecto /bin"

@ -1,37 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2020-03-02 20:52-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: lubuntuBreeze.py:39
msgid "Select Color Scheme for Breeze Qt Style:"
msgstr ""
#: lubuntuBreeze.py:40
msgid "Applications need to be restarted for changes to take effect."
msgstr ""
#: lubuntuBreeze.py:42
msgid "In case of pcmanfm-qt, since it handles the desktop, a restart of the desktop is needed"
msgstr ""
#: lubuntuBreeze.py:44
msgid "Easier, restart session."
msgstr ""
#: lubuntuBreeze.py:46
msgid "Best results if a matching GTK Theme is selected."
msgstr ""

@ -0,0 +1,68 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-11 12:36-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: lubuntubreeze/breezeconfig.py:48
msgid "Select Color Scheme for Breeze Qt Style:"
msgstr ""
#: lubuntubreeze/breezeconfig.py:49
msgid "Menu Transparency"
msgstr ""
#: lubuntubreeze/breezeconfig.py:50
msgid "Transparent"
msgstr ""
#: lubuntubreeze/breezeconfig.py:51
msgid "Opaque"
msgstr ""
#: lubuntubreeze/breezeconfig.py:52
msgid "Applications need to be restarted for changes to take effect."
msgstr ""
#: lubuntubreeze/breezeconfig.py:54
msgid ""
"In case of pcmanfm-qt, since it handles the desktop, a restart of the "
"desktop is needed"
msgstr ""
#: lubuntubreeze/breezeconfig.py:57
msgid "Easier, restart session."
msgstr ""
#: lubuntubreeze/breezeconfig.py:59
msgid "Best results if a matching GTK Theme is selected."
msgstr ""
#: lubuntubreeze/breezeconfig.py:61
msgid "Compton (or other compositor) needs to be enabled for transparency."
msgstr ""
#: lubuntubreeze/breezeconfig.py:68
msgid "None"
msgstr ""
#: breeze-config:39
msgid "data directory for UI files, default /usr/share/lubuntu-breeze-config"
msgstr ""
#: breeze-config:44
msgid "directory where this script is, default /bin"
msgstr ""

@ -1,2 +1,5 @@
[build_i18n]
domain=lubuntu-breeze-config
[sdist] [sdist]
formats = bztar formats = bztar

@ -17,14 +17,50 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup from setuptools import setup
import subprocess
import os
from distutils.command.clean import clean
class MyClean(clean):
def run(self):
# Execute the classic clean command
super().run()
# Custom clean
print("Removing translations")
subprocess.run(['rm', '-rf', 'translations'])
def add_mo_files(data_files):
app_name = 'lubuntu-breeze-config'
mo = ''
subprocess.run(['mkdir', 'translations/'])
for f in os.listdir('po'):
loc, ext = os.path.splitext(f)
if ext == '.po':
mo = app_name + '.mo'
subprocess.run(['mkdir', 'translations/' + loc])
subprocess.run(['msgfmt', '-o', 'translations/' + loc + '/' + mo,
'po/' + f], check=True)
data_files.append(('share/locale/' + loc + '/LC_MESSAGES/',
['translations/' + loc + '/' + mo]))
return data_files
data_files = [('share/applications/', ['data/breeze-config.desktop']),
('share/lubuntu-breeze-config/designer/',
['data/designer/main.ui'])]
setup( setup(
name="lubuntu-breeze-config", name="lubuntu-breeze-config",
version="0.1.dev0", version="0.1.dev0",
packages=['lubuntubreeze'], packages=['lubuntubreeze'],
scripts=['breeze-config'], scripts=['breeze-config'],
data_files=[('share/applications/', ['data/breeze-config.desktop']), data_files=add_mo_files(data_files),
('share/lubuntu-breeze-config/designer/',
['data/designer/main.ui'])],
test_suite="tests", test_suite="tests",
cmdclass={'clean': MyClean}
) )

@ -0,0 +1,2 @@
xgettext lubuntubreeze/breezeconfig.py breeze-config --language=Python
mv messages.po po/lubuntu-breeze-config.pot
Loading…
Cancel
Save