From 3df27d38ed01084a7a745507a6c34fcdd4cc95d3 Mon Sep 17 00:00:00 2001 From: trigg Date: Fri, 17 May 2024 12:35:47 +0100 Subject: [PATCH 01/13] - Add gettext translation to systray - Add right-click-menu with two options - - Update - - Exit - Added blank translation keys --- po/arch-update.pot | 8 ++++++++ po/fr.po | 8 ++++++++ src/script/arch-update-tray.py | 25 +++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index ad0dd13..31d9fdf 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -457,3 +457,11 @@ msgstr "" #, sh-format msgid "The '${config_file}' configuration file has been generated" msgstr "" + +#: src/script/arch-update-tray.py:111 +msgid "Update" +msgstr "" + +#: src/scripts/arch-update-tray.py:112 +msgid "Exit" +msgstr "" \ No newline at end of file diff --git a/po/fr.po b/po/fr.po index d3b435e..b65f6e6 100644 --- a/po/fr.po +++ b/po/fr.po @@ -491,3 +491,11 @@ msgstr "" #, sh-format msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" + +#: src/script/arch-update-tray.py:111 +msgid "Update" +msgstr "" + +#: src/scripts/arch-update-tray.py:112 +msgid "Exit" +msgstr "" \ No newline at end of file diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index fc75967..96c6c47 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -1,11 +1,12 @@ #!/usr/bin/env python3 """Arch-Update System Tray.""" +import gettext import logging import os import sys import subprocess -from PyQt6.QtGui import QIcon -from PyQt6.QtWidgets import QApplication, QSystemTrayIcon +from PyQt6.QtGui import QIcon, QAction +from PyQt6.QtWidgets import QApplication, QSystemTrayIcon, QMenu from PyQt6.QtCore import QFileSystemWatcher # Create logger @@ -22,6 +23,10 @@ log.error("Statefile does not exist: %s", STATE_FILE) sys.exit(1) +# Find translations +t = gettext.translation('Arch-Update', fallback=True) +_ = t.gettext + def arch_update(): """ Launch with desktop file """ @@ -67,6 +72,10 @@ def update(self): """ Start arch-update """ arch_update() + def exit(self): + """ Close systray process """ + sys.exit(0) + def __init__(self, statefile): """ Start Qt6 System Tray """ @@ -83,6 +92,18 @@ def __init__(self, statefile): self.tray.setVisible(True) self.tray.activated.connect(self.update) + # Menu + menu = QMenu() + menu_launch = QAction(_("Update")) + menu_exit = QAction(_("Exit")) + menu.addAction(menu_launch) + menu.addAction(menu_exit) + + menu_exit.triggered.connect(self.exit) + menu_launch.triggered.connect(self.update) + + self.tray.setContextMenu(menu) + # File Watcher self.watcher = QFileSystemWatcher([self.statefile]) self.watcher.fileChanged.connect(self.file_changed) From e8cab493adab8d2de2fce6faa3a4a338afb004d5 Mon Sep 17 00:00:00 2001 From: trigg Date: Fri, 17 May 2024 12:37:21 +0100 Subject: [PATCH 02/13] - readd newline on end of file --- po/arch-update.pot | 2 +- po/fr.po | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index 31d9fdf..bc3e8e7 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -464,4 +464,4 @@ msgstr "" #: src/scripts/arch-update-tray.py:112 msgid "Exit" -msgstr "" \ No newline at end of file +msgstr "" diff --git a/po/fr.po b/po/fr.po index b65f6e6..01c615a 100644 --- a/po/fr.po +++ b/po/fr.po @@ -498,4 +498,4 @@ msgstr "" #: src/scripts/arch-update-tray.py:112 msgid "Exit" -msgstr "" \ No newline at end of file +msgstr "" From 2d0cb28f116a1d227a4cd6791fd75d6c041d8b3d Mon Sep 17 00:00:00 2001 From: trigg Date: Fri, 17 May 2024 12:57:20 +0100 Subject: [PATCH 03/13] - rename 'update' to 'run' --- src/script/arch-update-tray.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index 96c6c47..d6da287 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -68,7 +68,7 @@ def file_changed(self): icon = QIcon.fromTheme(contents) self.tray.setIcon(icon) - def update(self): + def run(self): """ Start arch-update """ arch_update() @@ -90,7 +90,7 @@ def __init__(self, statefile): self.tray = QSystemTrayIcon() self.file_changed() self.tray.setVisible(True) - self.tray.activated.connect(self.update) + self.tray.activated.connect(self.run) # Menu menu = QMenu() @@ -100,7 +100,7 @@ def __init__(self, statefile): menu.addAction(menu_exit) menu_exit.triggered.connect(self.exit) - menu_launch.triggered.connect(self.update) + menu_launch.triggered.connect(self.run) self.tray.setContextMenu(menu) From 90e2271ab31545f72bd8205a72966838ec7abf40 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Fri, 17 May 2024 14:05:45 +0200 Subject: [PATCH 04/13] Use a more descriptive menu entry --- po/arch-update.pot | 2 +- po/fr.po | 2 +- src/script/arch-update-tray.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index bc3e8e7..785bd47 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -459,7 +459,7 @@ msgid "The '${config_file}' configuration file has been generated" msgstr "" #: src/script/arch-update-tray.py:111 -msgid "Update" +msgid "Run Arch-Update" msgstr "" #: src/scripts/arch-update-tray.py:112 diff --git a/po/fr.po b/po/fr.po index 01c615a..92cea1e 100644 --- a/po/fr.po +++ b/po/fr.po @@ -493,7 +493,7 @@ msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" #: src/script/arch-update-tray.py:111 -msgid "Update" +msgid "Run Arch-Update" msgstr "" #: src/scripts/arch-update-tray.py:112 diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index d6da287..ff77198 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -94,7 +94,7 @@ def __init__(self, statefile): # Menu menu = QMenu() - menu_launch = QAction(_("Update")) + menu_launch = QAction(_("Run Arch-Update")) menu_exit = QAction(_("Exit")) menu.addAction(menu_launch) menu.addAction(menu_exit) From 999abbd59a7c507b14b739d9979250e1009bff8e Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Fri, 17 May 2024 14:11:25 +0200 Subject: [PATCH 05/13] Add FR translation --- po/arch-update.pot | 4 ++-- po/fr.po | 8 ++++---- src/script/arch-update-tray.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index 785bd47..f4cd139 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -458,10 +458,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "" -#: src/script/arch-update-tray.py:111 +#: src/script/arch-update-tray.py:97 msgid "Run Arch-Update" msgstr "" -#: src/scripts/arch-update-tray.py:112 +#: src/script/arch-update-tray.py:98 msgid "Exit" msgstr "" diff --git a/po/fr.po b/po/fr.po index 92cea1e..f8c2dac 100644 --- a/po/fr.po +++ b/po/fr.po @@ -492,10 +492,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" -#: src/script/arch-update-tray.py:111 +#: src/script/arch-update-tray.py:97 msgid "Run Arch-Update" -msgstr "" +msgstr "Lancer Arch-Update" -#: src/scripts/arch-update-tray.py:112 +#: src/script/arch-update-tray.py:98 msgid "Exit" -msgstr "" +msgstr "Quitter" diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index ff77198..faea214 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -99,8 +99,8 @@ def __init__(self, statefile): menu.addAction(menu_launch) menu.addAction(menu_exit) - menu_exit.triggered.connect(self.exit) menu_launch.triggered.connect(self.run) + menu_exit.triggered.connect(self.exit) self.tray.setContextMenu(menu) From bfa7253eec13e46283b697679b1972ef3c670058 Mon Sep 17 00:00:00 2001 From: trigg Date: Fri, 17 May 2024 15:53:35 +0100 Subject: [PATCH 06/13] -Try all XDG path for translations --- src/script/arch-update-tray.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index faea214..f5d1109 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -24,8 +24,23 @@ sys.exit(1) # Find translations -t = gettext.translation('Arch-Update', fallback=True) -_ = t.gettext +paths = [] +if 'XDG_DATA_DIRS' in os.environ: + paths.extend(os.environ['XDG_DATA_DIRS'].split(":")) +if 'XDG_DATA_HOME' in os.environ: + paths.extend(os.environ['XDG_DATA_HOME'].split(":")) +_ = None +for path in paths: + french_translation_file = os.path.join( + path, "locale", "fr", "LC_MESSAGES", "Arch-Update.mo") + if os.path.isfile(french_translation_file): + t = gettext.translation('Arch-Update', localedir=path, fallback=True) + _ = t.gettext + break +if not _: + t = gettext.translation('Arch-Update', fallback=True) + _ = t.gettext + log.error("No translations found") def arch_update(): From a08b8c74a371e09518eb8f754fedde99cc2879de Mon Sep 17 00:00:00 2001 From: trigg Date: Fri, 17 May 2024 16:24:35 +0100 Subject: [PATCH 07/13] - enforce fallback to /usr and /usr/local --- src/script/arch-update-tray.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index f5d1109..8da4c8c 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -29,6 +29,7 @@ paths.extend(os.environ['XDG_DATA_DIRS'].split(":")) if 'XDG_DATA_HOME' in os.environ: paths.extend(os.environ['XDG_DATA_HOME'].split(":")) +paths.extend(['/usr/share', '/usr/local/share']) _ = None for path in paths: french_translation_file = os.path.join( From 5b8dfbd28aa80b91a088970372ea825c3f504584 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sat, 18 May 2024 10:31:39 +0200 Subject: [PATCH 08/13] Update po files --- po/arch-update.pot | 4 ++-- po/fr.po | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index f4cd139..169e540 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -458,10 +458,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "" -#: src/script/arch-update-tray.py:97 +#: src/script/arch-update-tray.py:113 msgid "Run Arch-Update" msgstr "" -#: src/script/arch-update-tray.py:98 +#: src/script/arch-update-tray.py:114 msgid "Exit" msgstr "" diff --git a/po/fr.po b/po/fr.po index f8c2dac..940b50e 100644 --- a/po/fr.po +++ b/po/fr.po @@ -492,10 +492,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" -#: src/script/arch-update-tray.py:97 +#: src/script/arch-update-tray.py:113 msgid "Run Arch-Update" msgstr "Lancer Arch-Update" -#: src/script/arch-update-tray.py:98 +#: src/script/arch-update-tray.py:114 msgid "Exit" msgstr "Quitter" From 30d0ea6441b8826250547a17ee966e128f5c1597 Mon Sep 17 00:00:00 2001 From: trigg Date: Sun, 19 May 2024 19:59:52 +0100 Subject: [PATCH 09/13] - postfix 'locale' subdirectory to fix translation issues --- src/script/arch-update-tray.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index 8da4c8c..382f602 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -35,6 +35,7 @@ french_translation_file = os.path.join( path, "locale", "fr", "LC_MESSAGES", "Arch-Update.mo") if os.path.isfile(french_translation_file): + path = os.path.join(path, 'locale') t = gettext.translation('Arch-Update', localedir=path, fallback=True) _ = t.gettext break From 5f4209bcda29d945529a19497f9efdc299b89bf8 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 21:12:54 +0200 Subject: [PATCH 10/13] Add $HOME/.local/share as possible prefix/path for translation files --- src/script/arch-update-tray.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index 382f602..e806f67 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -29,6 +29,8 @@ paths.extend(os.environ['XDG_DATA_DIRS'].split(":")) if 'XDG_DATA_HOME' in os.environ: paths.extend(os.environ['XDG_DATA_HOME'].split(":")) +if 'HOME' in os.environ: + paths.extend(os.environ['HOME'], '.local', 'share'.split(":")) paths.extend(['/usr/share', '/usr/local/share']) _ = None for path in paths: From 3ea5e5c15606d1dc674f34338d36d241d73d84f1 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 21:17:02 +0200 Subject: [PATCH 11/13] Update translation files --- po/arch-update.pot | 4 ++-- po/fr.po | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index 169e540..9ec980f 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -458,10 +458,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "" -#: src/script/arch-update-tray.py:113 +#: src/script/arch-update-tray.py:116 msgid "Run Arch-Update" msgstr "" -#: src/script/arch-update-tray.py:114 +#: src/script/arch-update-tray.py:117 msgid "Exit" msgstr "" diff --git a/po/fr.po b/po/fr.po index 940b50e..3143280 100644 --- a/po/fr.po +++ b/po/fr.po @@ -492,10 +492,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" -#: src/script/arch-update-tray.py:113 +#: src/script/arch-update-tray.py:116 msgid "Run Arch-Update" msgstr "Lancer Arch-Update" -#: src/script/arch-update-tray.py:114 +#: src/script/arch-update-tray.py:117 msgid "Exit" msgstr "Quitter" From 339cb6eda47fdde74b317508b91c62a61f919fb4 Mon Sep 17 00:00:00 2001 From: trigg Date: Sun, 19 May 2024 20:17:02 +0100 Subject: [PATCH 12/13] - append home local --- src/script/arch-update-tray.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/arch-update-tray.py b/src/script/arch-update-tray.py index e806f67..16ea7d1 100755 --- a/src/script/arch-update-tray.py +++ b/src/script/arch-update-tray.py @@ -30,7 +30,8 @@ if 'XDG_DATA_HOME' in os.environ: paths.extend(os.environ['XDG_DATA_HOME'].split(":")) if 'HOME' in os.environ: - paths.extend(os.environ['HOME'], '.local', 'share'.split(":")) + paths.append(os.path.join( + os.environ['HOME'], '.local', 'share')) paths.extend(['/usr/share', '/usr/local/share']) _ = None for path in paths: From 83ca46e7b0823c4a5ff0859d732ef62d82cc2866 Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Sun, 19 May 2024 21:20:58 +0200 Subject: [PATCH 13/13] Update translation files --- po/arch-update.pot | 4 ++-- po/fr.po | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/po/arch-update.pot b/po/arch-update.pot index 9ec980f..6419e7d 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -458,10 +458,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "" -#: src/script/arch-update-tray.py:116 +#: src/script/arch-update-tray.py:117 msgid "Run Arch-Update" msgstr "" -#: src/script/arch-update-tray.py:117 +#: src/script/arch-update-tray.py:118 msgid "Exit" msgstr "" diff --git a/po/fr.po b/po/fr.po index 3143280..14210cd 100644 --- a/po/fr.po +++ b/po/fr.po @@ -492,10 +492,10 @@ msgstr "" msgid "The '${config_file}' configuration file has been generated" msgstr "Le fichier de configuration '${config_file}' a été généré" -#: src/script/arch-update-tray.py:116 +#: src/script/arch-update-tray.py:117 msgid "Run Arch-Update" msgstr "Lancer Arch-Update" -#: src/script/arch-update-tray.py:117 +#: src/script/arch-update-tray.py:118 msgid "Exit" msgstr "Quitter"