From c98227f1fc9f1b7b2f84c328ae18b574bac3de2b Mon Sep 17 00:00:00 2001 From: Edu_Amr Date: Sun, 5 Jan 2025 16:37:05 -0400 Subject: [PATCH 1/3] Fixed grammar and typos --- NetworkMgr/net_api.py | 2 +- README.md | 2 +- src/auto-switch.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NetworkMgr/net_api.py b/NetworkMgr/net_api.py index 770d52e..78108e7 100755 --- a/NetworkMgr/net_api.py +++ b/NetworkMgr/net_api.py @@ -39,7 +39,7 @@ def get_ssid(wificard): shell=True, stdout=PIPE, universal_newlines=True) # If there are quotation marks in the string, use that as a separator, # otherwise use the default whitespace. This is to handle ssid strings - # with spaces in them. These ssid strings will be double quoted by ifconfig + # with spaces in them. These ssid strings will be double-quoted by ifconfig temp = wlan.stdout.readlines()[0].rstrip() if '"' in temp: out = temp.split('"')[1] diff --git a/README.md b/README.md index d9cb6b5..c3a9305 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,6 @@ Users of NetworkMgr must be members of the _wheel_ group. To add a user: If the desktop environment supports XDG then you can simply log out, or restart the computer. NetworkMgr should start automatically at login time. -## For Development dicussion +## For Development discussion You can join us at [#networkmgr](irc://irc.libera.chat:6697/networkmgr) on irc.libera.chat:6697 diff --git a/src/auto-switch.py b/src/auto-switch.py index d36aae8..16dfa32 100755 --- a/src/auto-switch.py +++ b/src/auto-switch.py @@ -62,7 +62,7 @@ # Stop the interface if it's not active or associated. # This removes the interface from the default route. -# Restarting routing adds and nic if there is and other one that is active +# Restarting routing adds and nic if there is another one that is active # or associated. if not any(active_status): os.system(f'service netif stop {nic}') From b9dfad0346bf37406d29a22011b496460db2ecb7 Mon Sep 17 00:00:00 2001 From: Edu_Amr Date: Sun, 5 Jan 2025 16:39:50 -0400 Subject: [PATCH 2/3] Transitioned the way we create translations mirroring how we do in `update-station` --- README.md | 6 +++ po/networkmgr.pot | 113 ++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 70 ++++++++++++++++++++++++++-- 3 files changed, 184 insertions(+), 5 deletions(-) create mode 100644 po/networkmgr.pot diff --git a/README.md b/README.md index c3a9305..9a8f7d5 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ Users of NetworkMgr must be members of the _wheel_ group. To add a user: If the desktop environment supports XDG then you can simply log out, or restart the computer. NetworkMgr should start automatically at login time. +## Managing Translations +To create a translation file. +```shell +./setup.py create_translation --locale=fr +``` + ## For Development discussion You can join us at [#networkmgr](irc://irc.libera.chat:6697/networkmgr) on irc.libera.chat:6697 diff --git a/po/networkmgr.pot b/po/networkmgr.pot new file mode 100644 index 0000000..319dc7d --- /dev/null +++ b/po/networkmgr.pot @@ -0,0 +1,113 @@ +# 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 , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-08-29 15:54+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/trayicon.py:67 +msgid "Ethernet Network" +msgstr "" + +#: src/trayicon.py:78 +#, python-format +msgid "Wired %s Connected" +msgstr "" + +#: src/trayicon.py:81 +msgid "Disable" +msgstr "" + +#: src/trayicon.py:86 +#, python-format +msgid "Wired %s Disconnected" +msgstr "" + +#: src/trayicon.py:89 +msgid "Enable" +msgstr "" + +#: src/trayicon.py:93 +#, python-format +msgid "Wired %s Unplug" +msgstr "" + +#: src/trayicon.py:101 +#, python-format +msgid "WiFi %s Disabled" +msgstr "" + +#: src/trayicon.py:104 +#, python-format +msgid "Enable Wifi %s" +msgstr "" + +#: src/trayicon.py:109 +#, python-format +msgid "WiFi %s Disconnected" +msgstr "" + +#: src/trayicon.py:113 src/trayicon.py:131 +#, python-format +msgid "Disable Wifi %s" +msgstr "" + +#: src/trayicon.py:119 +#, python-format +msgid "WiFi %s Connected" +msgstr "" + +#: src/trayicon.py:125 +#, python-format +msgid "Disconnect from %s" +msgstr "" + +#: src/trayicon.py:139 +msgid "Enable Networking" +msgstr "" + +#: src/trayicon.py:143 +msgid "Disable Networking" +msgstr "" + +#: src/trayicon.py:148 +msgid "Close Network Manager" +msgstr "" + +#: src/trayicon.py:156 +msgid "Available Connections" +msgstr "" + +#: src/trayicon.py:364 +msgid "Wi-Fi Network Authentication Required" +msgstr "" + +#: src/trayicon.py:376 +#, python-brace-format +msgid "{ssid_info[0]} Wi-Fi Network Authentication failed" +msgstr "" + +#: src/trayicon.py:378 +#, python-brace-format +msgid "Authentication required by {ssid_info[0]} Wi-Fi Network" +msgstr "" + +#: src/trayicon.py:381 +msgid "Password:" +msgstr "" + +#: src/trayicon.py:384 +msgid "Show password" +msgstr "" diff --git a/setup.py b/setup.py index 598b4fe..8eeb8d7 100755 --- a/setup.py +++ b/setup.py @@ -4,17 +4,15 @@ import os import sys from platform import system -from setuptools import setup from subprocess import run +from setuptools import setup, Command, glob + __VERSION__ = '6.5' PROGRAM_VERSION = __VERSION__ prefix = '/usr/local' if system() == 'FreeBSD' else sys.prefix -# compiling translations -os.system("sh compile_translations.sh") - def datafilelist(installbase, sourcebase): datafileList = [] @@ -25,6 +23,64 @@ def datafilelist(installbase, sourcebase): datafileList.append((root.replace(sourcebase, installbase), fileList)) return datafileList +class UpdateTranslationsCommand(Command): + """Custom command to extract messages and update .po files.""" + + description = 'Extract messages to .pot and update .po' + user_options = [] # No custom options + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + # Define paths + pot_file = 'po/networkmgr.pot' + po_files = glob.glob('po/*.po') + # Step 1: Extract messages to .pot file + print("Extracting messages to .pot file...") + os.system(f'xgettext --from-code=UTF-8 -L Python -o {pot_file} networkmgr/*.py networkmgr') + # Step 2: Update .po files with the new .pot file + print("Updating .po files with new translations...") + for po_file in po_files: + print(f"Updating {po_file}...") + os.system(f'msgmerge -U {po_file} {pot_file}') + print("Translation update complete.") + +class CreateTranslationCommand(Command): + """Custom command to create a new .po file for a specific language.""" + locale = None + description = 'Create a new .po file for the specified language' + user_options = [ + ('locale=', 'l', 'Locale code for the new translation (e.g., fr, es)') + ] + + def initialize_options(self): + self.locale = None # Initialize the locale option to None + + def finalize_options(self): + if self.locale is None: + raise Exception("You must specify the locale code (e.g., --locale=fr)") + + def run(self): + # Define paths + pot_file = 'po/networkmgr.pot' + po_dir = 'po' + po_file = os.path.join(po_dir, f'{self.locale}.po') + # Check if the .pot file exists + if not os.path.exists(pot_file): + print("Extracting messages to .pot file...") + os.system(f'xgettext --from-code=UTF-8 -L Python -o {pot_file} networkmgr/*.py networkmgr') + # Create the new .po file + if not os.path.exists(po_file): + print(f"Creating new {po_file} for locale '{self.locale}'...") + os.makedirs(po_dir, exist_ok=True) + os.system(f'msginit --locale={self.locale} --input={pot_file} --output-file={po_file}') + else: + print(f"PO file for locale '{self.locale}' already exists: {po_file}") + networkmgr_share = [ 'src/auto-switch.py', @@ -58,7 +114,11 @@ def datafilelist(installbase, sourcebase): data_files=data_files, install_requires=['setuptools'], packages=['NetworkMgr'], - scripts=['networkmgr', 'networkmgr_configuration'] + scripts=['networkmgr', 'networkmgr_configuration'], + cmdclass={ + 'create_translation': CreateTranslationCommand, + 'update_translations': UpdateTranslationsCommand, + } ) run('gtk-update-icon-cache -f /usr/local/share/icons/hicolor', shell=True) From 8e707bebc9b7acda111d5256465a2f259e38e895 Mon Sep 17 00:00:00 2001 From: Edu_Amr Date: Sun, 5 Jan 2025 16:40:34 -0400 Subject: [PATCH 3/3] Added translation for Brazilian Portuguese --- po/pt_Br.po | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 po/pt_Br.po diff --git a/po/pt_Br.po b/po/pt_Br.po new file mode 100644 index 0000000..4a8a93c --- /dev/null +++ b/po/pt_Br.po @@ -0,0 +1,113 @@ +# Portuguese translations for PACKAGE package. +# Copyright (C) 2025 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Edu_Amr , 2025. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-08-29 15:54+0800\n" +"PO-Revision-Date: 2025-01-05 16:17-0400\n" +"Last-Translator: Edu_Amr \n" +"Language-Team: Portuguese \n" +"Language: pt_Br\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/trayicon.py:67 +msgid "Ethernet Network" +msgstr "Rede Ethernet" + +#: src/trayicon.py:78 +#, python-format +msgid "Wired %s Connected" +msgstr "Cabo %s Conectado" + +#: src/trayicon.py:81 +msgid "Disable" +msgstr "Desativar" + +#: src/trayicon.py:86 +#, python-format +msgid "Wired %s Disconnected" +msgstr "Cabo %s Desconectado" + +#: src/trayicon.py:89 +msgid "Enable" +msgstr "Ativar" + +#: src/trayicon.py:93 +#, python-format +msgid "Wired %s Unplug" +msgstr "Cabo %s Desconectado fisicamente" + +#: src/trayicon.py:101 +#, python-format +msgid "WiFi %s Disabled" +msgstr "Wi-Fi %s Desativado" + +#: src/trayicon.py:104 +#, python-format +msgid "Enable Wifi %s" +msgstr "Ativar Wi-Fi %s" + +#: src/trayicon.py:109 +#, python-format +msgid "WiFi %s Disconnected" +msgstr "Wi-Fi %s Desconectado" + +#: src/trayicon.py:113 src/trayicon.py:131 +#, python-format +msgid "Disable Wifi %s" +msgstr "Desativar Wi-Fi %s" + +#: src/trayicon.py:119 +#, python-format +msgid "WiFi %s Connected" +msgstr "Wi-Fi %s Conectado" + +#: src/trayicon.py:125 +#, python-format +msgid "Disconnect from %s" +msgstr "Desconectar de %s" + +#: src/trayicon.py:139 +msgid "Enable Networking" +msgstr "Ativar Rede" + +#: src/trayicon.py:143 +msgid "Disable Networking" +msgstr "Desativar Rede" + +#: src/trayicon.py:148 +msgid "Close Network Manager" +msgstr "Fechar Gerenciador de Rede" + +#: src/trayicon.py:156 +msgid "Available Connections" +msgstr "Conexões Disponíveis" + +#: src/trayicon.py:364 +msgid "Wi-Fi Network Authentication Required" +msgstr "Autenticação Necessária para a Rede Wi-Fi" + +#: src/trayicon.py:376 +#, python-brace-format +msgid "{ssid_info[0]} Wi-Fi Network Authentication failed" +msgstr "Autenticação falhou na rede Wi-Fi {ssid_info[0]}" + +#: src/trayicon.py:378 +#, python-brace-format +msgid "Authentication required by {ssid_info[0]} Wi-Fi Network" +msgstr "Autenticação requerida pela rede Wi-Fi {ssid_info[0]}" + +#: src/trayicon.py:381 +msgid "Password:" +msgstr "Senha:" + +#: src/trayicon.py:384 +msgid "Show password" +msgstr "Mostrar senha"