From 4acd1d4ef61a360076fe38380b6ec74560aa15db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maurice=20Preu=C3=9F=20=28envoyr=29?= Date: Tue, 20 Dec 2022 19:59:24 +0100 Subject: [PATCH] add missing translation strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurice Preuß (envoyr) --- lib/Froxlor/Install/Install.php | 2 +- lib/Froxlor/Install/Install/Core.php | 27 ++++++++++++++++----------- lng/de.lng.php | 12 +++++++++++- lng/en.lng.php | 12 +++++++++++- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/lib/Froxlor/Install/Install.php b/lib/Froxlor/Install/Install.php index ff423d00..2919c6ea 100644 --- a/lib/Froxlor/Install/Install.php +++ b/lib/Froxlor/Install/Install.php @@ -282,7 +282,7 @@ class Install { // TODO: do validations if (isset($field['mandatory']) && $field['mandatory'] && empty($attribute)) { - throw new Exception('Mandatory field is not set!'); + throw new Exception(lng('install.errors.mandatory_field_not_set', [htmlspecialchars($field['label'])])); } return $attribute; } diff --git a/lib/Froxlor/Install/Install/Core.php b/lib/Froxlor/Install/Install/Core.php index 0efe7dd5..57dbeadf 100644 --- a/lib/Froxlor/Install/Install/Core.php +++ b/lib/Froxlor/Install/Install/Core.php @@ -67,7 +67,7 @@ class Core try { $db_root = new PDO($dsn, $this->validatedData['mysql_root_user'], $this->validatedData['mysql_root_pass'], $options); } catch (PDOException $e) { - // possibly without passwd? + // login failed; try to log in without passwd try { $db_root = new PDO($dsn, $this->validatedData['mysql_root_user'], '', $options); // set the given password @@ -78,8 +78,8 @@ class Core 'passwd' => $this->validatedData['mysql_root_pass'] ]); } catch (PDOException $e) { - // nope - throw new Exception('', 0, $e); + // login has failed; with and without password + throw new Exception(lng('install.errors.privileged_sql_connection_failed'), 0, $e); } } @@ -121,6 +121,9 @@ class Core } } + /** + * @throws Exception + */ public function getUnprivilegedPdo(): PDO { $options = [ @@ -143,7 +146,7 @@ class Core $pdo->exec('SET sql_mode = "' . $sql_mode . '"'); return $pdo; } catch (PDOException $e) { - throw new Exception('Unexpected exception occured', 0, $e); + throw new Exception(lng('install.errors.unexpected_database_error', [$e->getMessage()]), 0, $e); } } @@ -166,7 +169,7 @@ class Core // backup tables if exist if ($rows > 0) { if (!$this->validatedData['mysql_force_create']) { - throw new Exception('We found a database and were not allow to override it!'); + throw new Exception(lng('install.errors.database_already_exiting')); } // create temporary backup-filename @@ -190,11 +193,13 @@ class Core $output = []; exec($command, $output); @unlink($cnffilename); - if (stristr(implode(" ", $output), "error") || !file_exists($filename)) { - throw new Exception('backup_failed'); + if (stristr(implode(" ", $output), "error")) { + throw new Exception(lng('install.errors.mysqldump_backup_failed')); + } else if (!file_exists($filename)) { + throw new Exception(lng('install.errors.sql_backup_file_missing')); } } else { - throw new Exception('backup_binary_missing'); + throw new Exception(lng('install.errors.backup_binary_missing')); } } } @@ -344,7 +349,7 @@ class Core try { $pdo = $this->getUnprivilegedPdo(); } catch (PDOException $e) { - throw new Exception('failed to initialize froxlor user connection!'); + throw new Exception(lng('install.errors.unprivileged_sql_connection_failed')); } // actually import data @@ -353,7 +358,7 @@ class Core $pdo->query($froxlorSQL); } catch (PDOException $e) { - throw new Exception('failed to import data!' . $e->getMessage(), 0, $e); + throw new Exception(lng('install.errors.sql_import_failed', [$e->getMessage()]), 0, $e); } } @@ -651,7 +656,7 @@ class Core @fputs($fp, $userdata, strlen($userdata)); @fclose($fp); } else { - throw new Exception('creating_configfile_failed'); + throw new Exception(lng('install.errors.creating_configfile_failed')); } } @umask($umask); diff --git a/lng/de.lng.php b/lng/de.lng.php index 8da256a2..6b3fa10e 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -2221,7 +2221,17 @@ Vielen Dank, Ihr Administrator', 'servernameneedstobevalid' => 'Der angegebene Server-Name scheint kein gültiger FQDN oder Hostname zu sein', 'websrvuserdoesnotexist' => 'Der angegebene Webserver-Benutzer scheint auf dem System nicht zu existieren', 'websrvgrpdoesnotexist' => 'Die angegebene Webserver-Gruppe scheint auf dem System nicht zu existieren', - 'notyetconfigured' => 'Es scheint als wären die Dienste (noch) nicht erfolgreich konfiguriert worden. Bitte den angezeigten Befehl ausführen oder überspringen (direkt zum Login)' + 'notyetconfigured' => 'Es scheint als wären die Dienste (noch) nicht erfolgreich konfiguriert worden. Bitte den angezeigten Befehl ausführen oder überspringen (direkt zum Login)', + 'mandatory_field_not_set' => 'Pflichtfeld "%s" ist nicht gesetzt!', + 'unexpected_database_error' => 'Eine unerwarteter Datenbankfehler ist aufgetreten.', + 'sql_import_failed' => 'Der Import von SQL-Daten ist fehlgeschlagen!', + 'unprivileged_sql_connection_failed' => 'Unprivilegierte SQL-Verbindung konnte nicht initialisiert werden!', + 'privileged_sql_connection_failed' => 'Initialisierung der privilegierten SQL-Verbindung fehlgeschlagen!', + 'mysqldump_backup_failed' => 'Es kann keine Datenbanksicherung erstellt werden, wir haben einen Fehler von mysqldump erhalten.', + 'sql_backup_file_missing' => 'Es kann keine Datenbanksicherung erstellt werden, die Sicherungsdatei ist nicht vorhanden.', + 'backup_binary_missing' => 'Es kann keine Datenbanksicherung erstellen werden, stelle sicher, dass mysqldump installiert wurde.', + 'creating_configfile_failed' => 'Konfigurationsdateien können nicht erstellt werden, Datei kann nicht geschrieben werden.', + 'database_already_exiting' => 'Es existiert bereits eine Datenbank, diese darf aber nicht überschreiben werden!' ] ], 'welcome' => [ diff --git a/lng/en.lng.php b/lng/en.lng.php index 5a1c2285..aa5f1611 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -2353,7 +2353,17 @@ Yours sincerely, your administrator', 'servernameneedstobevalid' => 'Given servername does not seem to be a FQDN or hostname', 'websrvuserdoesnotexist' => 'Given webserver-user does not seem to exist on the system', 'websrvgrpdoesnotexist' => 'Given webserver-group does not seem to exist on the system', - 'notyetconfigured' => 'It seems that the services were not yet configured (successfully). Please either run the command shown below or check the box to do it later.' + 'notyetconfigured' => 'It seems that the services were not yet configured (successfully). Please either run the command shown below or check the box to do it later.', + 'mandatory_field_not_set' => 'Mandatory field "%s" is not set!', + 'unexpected_database_error' => 'Unexpected database exception occurred.', + 'sql_import_failed' => 'Failed to import SQL data!', + 'unprivileged_sql_connection_failed' => 'Failed to initialize unprivileged SQL connection!', + 'privileged_sql_connection_failed' => 'Failed to initialize privileged SQL connection!', + 'mysqldump_backup_failed' => 'Cannot create a database backup, we got an error from mysqldump.', + 'sql_backup_file_missing' => 'Cannot create a database backup, the backup file does not exist.', + 'backup_binary_missing' => 'Cannot create a database backup, make sure you installed mysqldump.', + 'creating_configfile_failed' => 'Cannot create config files, unable to write file.', + 'database_already_exiting' => 'We found a database and were not allow to override it!' ] ], 'welcome' => [