From 38f03c375eafdb6b95190729479c6fa0d721b400 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Mon, 16 Sep 2024 11:31:53 +0200 Subject: More i18n --- src/application/i18n.php | 14 ++- src/application/messages/de.msg | 145 +++++++++++++++++++++++++++++ src/application/views/form_addpost.php | 11 ++- src/application/views/form_login.php | 11 ++- src/application/views/form_newtopic.php | 13 ++- src/application/views/form_register.php | 23 +++-- src/application/views/nav_logged_in.php | 9 +- src/application/views/view_post.php | 20 ++-- src/application/views/view_topic_start.php | 43 ++++----- src/application/views/view_topics.php | 2 +- src/application/views/view_user.php | 49 +++++----- 11 files changed, 249 insertions(+), 91 deletions(-) (limited to 'src/application') diff --git a/src/application/i18n.php b/src/application/i18n.php index 964439f..2fcadab 100644 --- a/src/application/i18n.php +++ b/src/application/i18n.php @@ -6,8 +6,10 @@ $__i18n_msg_store = []; $__i18n_current_locale = null; function i18n_parse(string $contents, ?string $filename = null): array { - $syntax_error = fn(string $msg, ?int $line = null): never => - throw new Exception("i18n syntax error: $msg (in " . ($filename ?? "unknown") . ":" . ($line ?? 0) . ")"); + $syntax_error = fn(string $msg, int $line): never => + throw new Exception("i18n syntax error: $msg (in " . ($filename ?? "unknown") . ":" . $line . ")"); + $other_error = fn(string $msg, int $line): never => + throw new Exception("i18n error: $msg (in " . ($filename ?? "unknown") . ":" . $line . ")"); $msgs = []; $lines = explode("\n", $contents); @@ -27,7 +29,9 @@ function i18n_parse(string $contents, ?string $filename = null): array { if ($currentId !== "") { if ($currentContext !== "") $currentId = $currentContext . "\004" . $currentId; - $msgs[$currentId] ??= $currentMessage; + if (isset($msgs[$currentId])) + $other_error("duplicate message id '$currentId'", $lnNum); + $msgs[$currentId] = $currentMessage; } $currentId = json_decode(substr($ln, 2)); $currentContext = ""; @@ -58,7 +62,9 @@ function i18n_parse(string $contents, ?string $filename = null): array { if ($currentId !== "") { if ($currentContext !== "") $currentId = $currentContext . "\x7F" . $currentId; - $msgs[$currentId] ??= $currentMessage; + if (isset($msgs[$currentId])) + $other_error("duplicate message id '$currentId'", count($lines)); + $msgs[$currentId] = $currentMessage; } return $msgs; } diff --git a/src/application/messages/de.msg b/src/application/messages/de.msg index 5ee2f6c..692e559 100644 --- a/src/application/messages/de.msg +++ b/src/application/messages/de.msg @@ -115,3 +115,148 @@ : "Delete post" = "Beitrag löschen" + +: "Username:" += "Nutzername:" + +: "Display name:" += "Anzeigename:" + +: "Choose password:" += "Passwort festlegen:" + +: "Repeat password:" += "Passwort wiederholen:" + +: "Email address:" += "E-Mail-Adresse:" + +: "CAPTCHA:" += "CAPTCHA:" + +: "New CAPTCHA" += "Neues CAPTCHA" + +: "Register now" += "Jetzt registrieren" + +: "Already have an account? %link%Sign in now%/link%" += "Sie haben bereits ein Nutzerkonto? %link%Jetzt anmelden%/link%" + +: "Don't have an account? %link%Register now%/link%" += "Sie haben noch kein Nutzerkonto? %link%Jetzt registrieren%/link%" + +: "Edit post" += "Beitrag bearbeiten" + +: "Message:" += "Nachricht:" + +: "Cancel" += "Abbrechen" + +: "Save changes" += "Änderungen speichern" + +: "Permission denied" += "Zugriff verweigert" + +: "Close" += "Schließen" + +: "Edit title" += "Titel ändern" + +: "Reply" += "Antworten" + +: "Delete topic" += "Thema löschen" + +: "(deleted)" += "(gelöscht)" + +: "Started by %user% on %date%" += "Gestartet von %user% am %date%" + +: "Welcome, %user%!" += "Willkommen, %user%!" + +: "This post has been deleted" += "Dieser Beitrag wurde gelöscht" + +: "Profile picture" += "Profilbild" + +: "Permalink" += "Permalink" + +: "Reply to post" += "Auf Beitrag antworten" + +: "(edited)" += "(bearbeitet)" + +: "You" += "Sie" + +: "Reply to this topic" += "Auf dieses Thema antworten" + +: "Attachments: (max. %max_attachment_count% files, max. %max_attachment_size% MiB each)" += "Anhänge: (max. %max_attachment_count% Dateien, je max. %max_attachment_size% MiB)" + +: "Post reply" += "Antwort veröffentlichen" + +: "Topic title:" += "Titel des Themas:" + +: "Create topic" += "Thema erstellen" + +: "Member since %join_date%" += "Mitglied seit %join_date%" + +: "Your posts" += "Ihre Beiträge" + +: "%display_name%'s posts" += "Beiträge von %display_name%" + +: "unknown" += "unbekannt" + +: "posted on %post_date% in %topic%" += "veröffentlicht am %post_date% in %topic%" + +: "Show all posts" += "Alle Beiträge anzeigen" + +: "This user has not posted anything yet" += "Dieser Nutzer hat noch nichts veröffentlicht" + +: "Edit profile" += "Profil bearbeiten" + +: "Profile picture:" += "Profilbild:" + +: "Keep current profile picture" += "Aktuelles Profilbild behalten" + +: "No profile picture" += "Kein Profilbild" + +: "Remove profile picture" += "Profilbild entfernen" + +: "Upload new profile picture" += "Neues Profilbild hochladen" + + +#:: +#- "Select file" +#- "Select files" +#= "Datei auswählen" +#- "Dateien auswählen" diff --git a/src/application/views/form_addpost.php b/src/application/views/form_addpost.php index 88648b4..72dafe5 100644 --- a/src/application/views/form_addpost.php +++ b/src/application/views/form_addpost.php @@ -8,7 +8,7 @@ if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = []; RequestUtils::clearLastForm(); ?> -

Reply to this topic

+

$_formError]); @@ -16,12 +16,15 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) { ?>
#form" method="post" enctype="multipart/form-data">
- +
- +
- +
diff --git a/src/application/views/form_login.php b/src/application/views/form_login.php index de8f28c..1ae20a9 100644 --- a/src/application/views/form_login.php +++ b/src/application/views/form_login.php @@ -21,21 +21,24 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) { ?>
" method="post">
- + " required autofocus>
- +
- +
- Don't have an account? Register now + '', + "/link" => '', + ]) ?>
diff --git a/src/application/views/form_newtopic.php b/src/application/views/form_newtopic.php index 2e58268..a40f3a6 100644 --- a/src/application/views/form_newtopic.php +++ b/src/application/views/form_newtopic.php @@ -10,7 +10,7 @@ RequestUtils::clearLastForm(); ?>
#form" method="post" enctype="multipart/form-data">
- + " required autofocus>
- +
- +
- +
diff --git a/src/application/views/form_register.php b/src/application/views/form_register.php index 83f3f4e..a37e5c3 100644 --- a/src/application/views/form_register.php +++ b/src/application/views/form_register.php @@ -21,54 +21,57 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) { ?>
" method="post">
- +
- + " required>
- + " required>
- +
- +
- + " required>
- +
CAPTCHA
- +
- +
- Already have an account? Sign in now + '', + "/link" => '', + ]) ?>
diff --git a/src/application/views/nav_logged_in.php b/src/application/views/nav_logged_in.php index 8ed8d07..39c65cb 100644 --- a/src/application/views/nav_logged_in.php +++ b/src/application/views/nav_logged_in.php @@ -2,12 +2,9 @@ use mystic\forum\orm\User; ?>