Translation preparation and some webgui code

This commit is contained in:
2025-05-15 09:14:14 +02:00
parent fb93c83388
commit 1f2af40943
7 changed files with 131 additions and 9 deletions
+10 -1
View File
@@ -7,6 +7,7 @@ YMS Installation
- Python 3 - Python 3
- python3-bcrypt - python3-bcrypt
- optional - optional
- gettext
- mupdf-tools for extended pdf file management - mupdf-tools for extended pdf file management
1.2 Native GUI 1.2 Native GUI
@@ -20,7 +21,6 @@ YMS Installation
- php-mysql - php-mysql
- php-xml - php-xml
2. Create database 2. Create database
Create a database for YMS on your server, as well as a MariaDB user who has 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 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 Optional import some sample data
mariadb yms < mariadb_sample.sql mariadb yms < mariadb_sample.sql
+10
View File
@@ -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
+73
View File
@@ -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 <thomas@hoogi.de>, 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 <thomas@hoogi.de>\n"
"Language-Team: de <thomas@hoogi.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"
+2 -1
View File
@@ -21,6 +21,7 @@ $g_db_password = 'changeme!';
$g_db_schema = 'yms'; $g_db_schema = 'yms';
// mail settings // mail settings
$g_mail_enable = FALSE;
$g_mailto = 'captain@example.com'; $g_mailto = 'captain@example.com';
$g_mailto_webmaster = 'webmaster@example.com'; $g_mailto_webmaster = 'webmaster@example.com';
@@ -34,7 +35,7 @@ $g_shapedir = 'shapes';
// documents and images // documents and images
$g_doc_basepath = '/var/local/yms'; $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( $g_doc_typemap = array(
'generic' => 'doc', 'generic' => 'doc',
'manual' => 'doc', 'manual' => 'doc',
+27 -2
View File
@@ -1,7 +1,7 @@
<?php <?php
/****************************************************************************** /******************************************************************************
* YMS - Yacht Management Software * YMS - Yacht Management Software
* Copyright (C) 2024 Thomas Hooge * Copyright (C) 2024-2025 Thomas Hooge
* *
* SPDX-License-Identifier: WTFPL * SPDX-License-Identifier: WTFPL
****************************************************************************** ******************************************************************************
@@ -72,14 +72,39 @@ try {
$pdo = new PDO("mysql:host=$g_db_host;dbname=$g_db_schema;charset=utf8mb4", $g_db_username, $g_db_password); $pdo = new PDO("mysql:host=$g_db_host;dbname=$g_db_schema;charset=utf8mb4", $g_db_username, $g_db_password);
} catch (PDOException $e) { } catch (PDOException $e) {
echo '<pre>'; echo '<pre>';
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); print_r($e);
}
echo '</pre>'; echo '</pre>';
exit(1);
} }
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
# $pdo->query("SET lc_time_names='de_DE'"); # $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 '<pre>';
echo 'Settings table not found! Perhaps database is not initialized';
echo '</pre>';
exit(1)
}
}
$g_db_scheme_version = $sth->fetchColumn(); $g_db_scheme_version = $sth->fetchColumn();
// TODO Check version
$user = User::GetInstance(); // There can be only one $user = User::GetInstance(); // There can be only one
if ($g_scriptname != 'login.php') { if ($g_scriptname != 'login.php') {
+2 -2
View File
@@ -1,5 +1,5 @@
# YMS - Yacht Management System # 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. # This file is distributed under the same license as the YMS package.
# Thomas Hooge <thomas@hoogi.de>, 2024. # Thomas Hooge <thomas@hoogi.de>, 2024.
# #
@@ -10,7 +10,7 @@ msgstr ""
"POT-Creation-Date: 2024-04-10 17:14+0200\n" "POT-Creation-Date: 2024-04-10 17:14+0200\n"
"PO-Revision-Date: 2024-03-15 13:50+0100\n" "PO-Revision-Date: 2024-03-15 13:50+0100\n"
"Last-Translator: Thomas Hooge <thomas@hoogi.de>\n" "Last-Translator: Thomas Hooge <thomas@hoogi.de>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: de <thomas@hoogi.de>\n"
"Language: de\n" "Language: de\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"
+6 -2
View File
@@ -14,6 +14,7 @@ Configuration file located at ~/.config/ymsgui.conf:
import os import os
import sys import sys
import locale import locale
import gettext
import configparser import configparser
import gi import gi
@@ -89,9 +90,12 @@ def messagebox(messagetext, symbol=None, title=None, parent=None):
if __name__ == "__main__": if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
gettext.bindtextdomain('ymsgui', 'locale')
gettext.textdomain('ymsgui')
_ = gettext.gettext
config = configparser.ConfigParser() config = configparser.ConfigParser()
if not config.read(os.path.expanduser(cfg['cfgfile'])): if not config.read(os.path.expanduser(cfg['cfgfile'])):
messagebox("Configuration file not found", title="YMS") messagebox(_("Configuration file not found"), title="YMS")
else: else:
cfg['host'] = config.get('DB', 'host') cfg['host'] = config.get('DB', 'host')
cfg['db'] = config.get('DB', 'db') cfg['db'] = config.get('DB', 'db')
@@ -103,6 +107,6 @@ if __name__ == "__main__":
app.run() app.run()
db.disconnect() db.disconnect()
else: 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 # Another fine product of the sirius cybernetics corporation