From 1f2af40943207bb2d46cdc6835c1f0b6d10612e4 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Thu, 15 May 2025 09:14:14 +0200 Subject: [PATCH] Translation preparation and some webgui code --- INSTALL | 11 +++++- Makefile | 10 ++++++ locale/de.po | 73 ++++++++++++++++++++++++++++++++++++++++ webgui/config.inc-sample | 3 +- webgui/globals.inc | 31 +++++++++++++++-- webgui/locale/de_DE.po | 4 +-- ymsgui.py | 8 +++-- 7 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 Makefile create mode 100644 locale/de.po diff --git a/INSTALL b/INSTALL index 733b242..d1f41a1 100644 --- a/INSTALL +++ b/INSTALL @@ -7,6 +7,7 @@ YMS Installation - Python 3 - python3-bcrypt - optional + - gettext - mupdf-tools for extended pdf file management 1.2 Native GUI @@ -20,7 +21,6 @@ YMS Installation - php-mysql - php-xml - 2. Create database Create a database for YMS on your server, as well as a MariaDB user who has @@ -39,6 +39,15 @@ Import the mariadb.sql file into your database, which will create the tables mariadb yms < mariadb.sql +According to your desired language import minimal required dataset into your +new database. For german use + + mariadb yms < minimal.sql + +or alternatively for english language + + mariadb yms < minimal_en.sql + Optional import some sample data mariadb yms < mariadb_sample.sql diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3536e40 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +# Translation helper + +prepare: ymsgui.py yms/*.py yms/ui/*.ui + xgettext -L Python -o locale/program.pot ymsgui.py yms/*.py + xgettext -L Glade -o locale/ui.pot yms/ui/*.ui + msgcat -o locale/combined.pot locale/program.pot locale/ui.pot + msgmerge -U locale/de.po locale/combined.pot + +translation: locale/de.po + msgfmt locale/de.po -o locale/de/LC_MESSAGES/ymsgui.mo diff --git a/locale/de.po b/locale/de.po new file mode 100644 index 0000000..2b00994 --- /dev/null +++ b/locale/de.po @@ -0,0 +1,73 @@ +# YMS - Yacht Management System +# Copyright (C) 2025 Thomas Hooge +# This file is distributed under the same license as the YMS package. +# Thomas Hooge , 2025. +# +msgid "" +msgstr "" +"Project-Id-Version: YMS 0.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-05-15 09:05+0200\n" +"PO-Revision-Date: 2025-05-15 09:05+0200\n" +"Last-Translator: Thomas Hooge \n" +"Language-Team: de \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ymsgui.py:98 +msgid "Configuration file not found" +msgstr "Konfigurationsdatei nicht gefunden" + +#: ymsgui.py:110 +msgid "Database connection cannot be established" +msgstr "Datenbankverbindung kann nicht hergestellt werden" + +#: yms/ui/main.ui:7 +msgid "YMS" +msgstr "" + +#: yms/ui/main.ui:27 +msgid "empty" +msgstr "leer" + +#: yms/ui/main.ui:55 +msgid "Name" +msgstr "" + +#: yms/ui/main.ui:76 +msgid "Model" +msgstr "Modell" + +#: yms/ui/main.ui:109 +msgid "Vessel" +msgstr "Boot" + +#: yms/ui/main.ui:138 +msgid "Lists" +msgstr "Listen" + +#: yms/ui/main.ui:173 +msgid "Ok" +msgstr "" + +#: yms/ui/main.ui:194 +msgid "User" +msgstr "Benutzer" + +#: yms/ui/main.ui:207 +msgid "Base data" +msgstr "Basisdaten" + +#: yms/ui/main.ui:217 yms/ui/main.ui:238 +msgid "label" +msgstr "" + +#: yms/ui/main.ui:227 +msgid "Equipment" +msgstr "Ausrüstung" + +#: yms/ui/main.ui:248 +msgid "Inventory" +msgstr "Inventar" diff --git a/webgui/config.inc-sample b/webgui/config.inc-sample index 404ec15..1d4d5ac 100644 --- a/webgui/config.inc-sample +++ b/webgui/config.inc-sample @@ -21,6 +21,7 @@ $g_db_password = 'changeme!'; $g_db_schema = 'yms'; // mail settings +$g_mail_enable = FALSE; $g_mailto = 'captain@example.com'; $g_mailto_webmaster = 'webmaster@example.com'; @@ -34,7 +35,7 @@ $g_shapedir = 'shapes'; // documents and images $g_doc_basepath = '/var/local/yms'; -$g_doc_maxsize = 1024*1024*16; // 16 MB +$g_doc_maxsize = 1024*1024*16; // 16 MB, please adjust php.ini accordingly! $g_doc_typemap = array( 'generic' => 'doc', 'manual' => 'doc', diff --git a/webgui/globals.inc b/webgui/globals.inc index 4b9148a..c4c9b62 100644 --- a/webgui/globals.inc +++ b/webgui/globals.inc @@ -1,7 +1,7 @@ '; - print_r($e); + switch ($e->getCode()) { + case 2002: + echo "Unable to connect to database, perhaps host info is wrong.\n"; + break; + case 1044: + case 1045: + // access denied to db or generic access denied + echo "Unable to connect to database, perhaps username or password is wrong.\n"; + break; + case 1049: + echo "Unable to connect to database, perhaps database name is wrong.\n"; + break; + default: + print_r($e); + } echo ''; + exit(1); } $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); # $pdo->query("SET lc_time_names='de_DE'"); -$sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=0"); +try { + $sth = $pdo->query("SELECT valint FROM settings WHERE userid=0 AND sno=0"); +} catch (PDOException $e) { + if ($e->getCode() == 1146) { + echo '
';
+        echo 'Settings table not found! Perhaps database is not initialized';
+        echo '
'; + exit(1) + } +} $g_db_scheme_version = $sth->fetchColumn(); +// TODO Check version $user = User::GetInstance(); // There can be only one if ($g_scriptname != 'login.php') { diff --git a/webgui/locale/de_DE.po b/webgui/locale/de_DE.po index 2f83360..33a7f20 100644 --- a/webgui/locale/de_DE.po +++ b/webgui/locale/de_DE.po @@ -1,5 +1,5 @@ # YMS - Yacht Management System -# Copyright (C) 2024 Thomas Hooge +# Copyright (C) 2024-2025 Thomas Hooge # This file is distributed under the same license as the YMS package. # Thomas Hooge , 2024. # @@ -10,7 +10,7 @@ msgstr "" "POT-Creation-Date: 2024-04-10 17:14+0200\n" "PO-Revision-Date: 2024-03-15 13:50+0100\n" "Last-Translator: Thomas Hooge \n" -"Language-Team: LANGUAGE \n" +"Language-Team: de \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" diff --git a/ymsgui.py b/ymsgui.py index 7bd5b7c..ec109a0 100755 --- a/ymsgui.py +++ b/ymsgui.py @@ -14,6 +14,7 @@ Configuration file located at ~/.config/ymsgui.conf: import os import sys import locale +import gettext import configparser import gi @@ -89,9 +90,12 @@ def messagebox(messagetext, symbol=None, title=None, parent=None): if __name__ == "__main__": locale.setlocale(locale.LC_ALL, '') + gettext.bindtextdomain('ymsgui', 'locale') + gettext.textdomain('ymsgui') + _ = gettext.gettext config = configparser.ConfigParser() if not config.read(os.path.expanduser(cfg['cfgfile'])): - messagebox("Configuration file not found", title="YMS") + messagebox(_("Configuration file not found"), title="YMS") else: cfg['host'] = config.get('DB', 'host') cfg['db'] = config.get('DB', 'db') @@ -103,6 +107,6 @@ if __name__ == "__main__": app.run() db.disconnect() else: - messagebox("Database connection cannot be established", title="YMS") + messagebox(_("Database connection cannot be established"), title="YMS") # Another fine product of the sirius cybernetics corporation