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(-)
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();
?>
-
+
$_formError]);
@@ -16,12 +16,15 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
?>
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) {
?>
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();
?>
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) {
?>
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;
?>
-Welcome,
-id === User::SUPERUSER_ID): ?>
-= htmlentities($user->displayName) ?>!
-
-= htmlentities($user->displayName) ?>!
-
+
= __("Welcome, %user%!", [
+ "user" => ($user->id === User::SUPERUSER_ID) ? ('' . htmlentities($user->displayName) . '') : ('' . htmlentities($user->displayName) . '')
+]) ?>
- View profile
- ">Log out
diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php
index a7624ae..510b22c 100644
--- a/src/application/views/view_post.php
+++ b/src/application/views/view_post.php
@@ -31,7 +31,7 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
- This post has been deleted
+ = __("This post has been deleted") ?>
@@ -41,10 +41,10 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
diff --git a/src/application/views/view_topic_start.php b/src/application/views/view_topic_start.php
index fc54623..35befc7 100644
--- a/src/application/views/view_topic_start.php
+++ b/src/application/views/view_topic_start.php
@@ -16,17 +16,15 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor-
-
-
-
-
+
+
@@ -37,14 +35,14 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor-
- You must be logged in to view attachments
+ = __("You must be logged in to view attachments") ?>
@@ -65,37 +63,34 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor-
= htmlentities($topic->title) ?>
-
+
-
+
- Started by
-
- = htmlentities($topicAuthor->displayName) ?>
-
- (deleted)
-
- on = htmlentities($topic->creationDate->format("c")) ?>
+ = __("Started by %user% on %date%", [
+ "user" => ($topicAuthor !== null) ? ('' . htmlentities($topicAuthor->displayName) . '') : __("(deleted)"),
+ "date" => '' . htmlentities($topic->creationDate->format("c")) . '',
+ ]); ?>
-
diff --git a/src/application/views/view_topics.php b/src/application/views/view_topics.php
index cb871cb..291fbdc 100644
--- a/src/application/views/view_topics.php
+++ b/src/application/views/view_topics.php
@@ -6,7 +6,7 @@ use mystic\forum\orm\UserPermissions;
if ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_TOPIC)):
?>
- New topic
+ = __("New topic") ?>
diff --git a/src/application/views/view_user.php b/src/application/views/view_user.php
index 79b57d2..536cc33 100644
--- a/src/application/views/view_user.php
+++ b/src/application/views/view_user.php
@@ -12,15 +12,11 @@ $canEdit = ($user->id === $GLOBALS["currentUser"]?->id && $user->hasPermission(U
$isOwnProfile = $user->id === $GLOBALS["currentUser"]?->id;
-$sIsOwn_your = "";
-if ($isOwnProfile)
- $sIsOwn_your = " your";
-
$sUserPossessive = "";
if ($isOwnProfile)
- $sUserPossessive = "Your";
+ $sUserPossessive = "Your posts";
else
- $sUserPossessive = $user->displayName . "'s";
+ $sUserPossessive = "%display_name%'s posts";
$dateJoined = DateTime::createFromImmutable($user->created);
$dateJoined->setTime(0, 0, 0, 0);
@@ -30,9 +26,11 @@ $dateJoined->setTime(0, 0, 0, 0);
= htmlentities($user->displayName) ?>
-
You
+
= __("You") ?>
- @= htmlentities($user->name) ?> •
Member since = htmlentities($dateJoined->format("c")); ?>
+ @= htmlentities($user->name) ?> •
= __("Member since %join_date%", [
+ "join_date" => '' . htmlentities($dateJoined->format("c")) . '',
+ ]) ?>
@@ -40,7 +38,9 @@ $dateJoined->setTime(0, 0, 0, 0);
-
= $sUserPossessive ?> posts
+
= __($sUserPossessive, [
+ "display_name" => $user->displayName,
+]) ?>
0): ?>
-
+
- This user has not posted anything yet
+ = __("This user has not posted anything yet") ?>
@@ -69,7 +72,7 @@ $dateJoined->setTime(0, 0, 0, 0);
--
cgit v1.2.3