summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Kohl2024-09-16 11:31:53 +0200
committerJonas Kohl2024-09-16 11:31:53 +0200
commit38f03c375eafdb6b95190729479c6fa0d721b400 (patch)
tree637616799ed5e20c72d8d7be7a78e72a11826cfa
parentcb9b87997993702131ca24d4d0e1fd45ef64805c (diff)
More i18n
-rw-r--r--src/application/i18n.php14
-rw-r--r--src/application/messages/de.msg145
-rw-r--r--src/application/views/form_addpost.php11
-rw-r--r--src/application/views/form_login.php11
-rw-r--r--src/application/views/form_newtopic.php13
-rw-r--r--src/application/views/form_register.php23
-rw-r--r--src/application/views/nav_logged_in.php9
-rw-r--r--src/application/views/view_post.php20
-rw-r--r--src/application/views/view_topic_start.php43
-rw-r--r--src/application/views/view_topics.php2
-rw-r--r--src/application/views/view_user.php49
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: <small>(max. %max_attachment_count% files, max. %max_attachment_size% MiB each)</small>"
+= "Anhänge: <small>(max. %max_attachment_count% Dateien, je max. %max_attachment_size% MiB)</small>"
+
+: "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();
?>
-<h3 id="form">Reply to this topic</h3>
+<h3 id="form"><?= __("Reply to this topic") ?></h3>
<?php
if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
_view("alert_error", ["message" => $_formError]);
@@ -16,12 +16,15 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>#form" method="post" enctype="multipart/form-data">
<div class="form-group">
- <label for="i_message">Message:</label>
+ <label for="i_message"><?= __("Message:") ?></label>
<textarea class="form-control" id="i_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:499px"></textarea>
</div>
<div class="form-group">
- <label for="i_files">Attachments: <small>(max. <?= htmlentities(MAX_ATTACHMENT_COUNT) ?> files, max. <?= htmlentities(MAX_ATTACHMENT_SIZE >> 20) ?> MiB each)</small></label>
+ <label for="i_files"><?= __("Attachments: <small>(max. %max_attachment_count% files, max. %max_attachment_size% MiB each)</small>", [
+ "max_attachment_count" => strval(MAX_ATTACHMENT_COUNT),
+ "max_attachment_size" => strval(MAX_ATTACHMENT_SIZE >> 20)
+ ]) ?></label>
<input type="file" name="files[]" id="i_files" multiple accept="*/*">
</div>
-<button type="submit" class="btn btn-success">Post reply</button>
+<button type="submit" class="btn btn-success"><?= __("Post reply") ?></button>
</form>
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) {
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
<div class="form-group">
- <label for="i_username">Username:</label>
+ <label for="i_username"><?= __("Username:") ?></label>
<input class="form-control" type="text" id="i_username" name="username" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required autofocus>
</div>
<div class="form-group">
- <label for="i_password">Password:</label>
+ <label for="i_password"><?= __("Password:") ?></label>
<input class="form-control" type="password" id="i_password" name="password" required>
</div>
<div class="form-group">
- <button class="btn btn-default" type="submit">Log in</button>
+ <button class="btn btn-default" type="submit"><?= __("Log in") ?></button>
</div>
<div class="form-group">
- Don't have an account? <a href="?_action=register">Register now</a>
+ <?= __("Don't have an account? %link%Register now%/link%", [
+ "link" => '<a href="?_action=register">',
+ "/link" => '</a>',
+ ]) ?>
</div>
</form>
</div>
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();
?>
<div class="page-header margin-top-0">
- <h1>New topic</h1>
+ <h1><?= __("New topic") ?></h1>
</div>
<?php
if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
@@ -19,16 +19,19 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>#form" method="post" enctype="multipart/form-data">
<div class="form-group">
- <label for="i_message">Topic title:</label>
+ <label for="i_message"><?= __("Topic title:") ?></label>
<input type="text" class="form-control" id="i_title" name="title" value="<?= htmlentities($lastForm["title"] ?? "") ?>" required autofocus>
</div>
<div class="form-group">
- <label for="i_message">Message:</label>
+ <label for="i_message"><?= __("Message:") ?></label>
<textarea class="form-control" id="i_message" name="message" required rows="12" cols="60" style="resize:vertical;max-height:499px"><?= htmlentities($lastForm["message"] ?? "") ?></textarea>
</div>
<div class="form-group">
- <label for="i_files">Attachments: <small>(max. <?= htmlentities(MAX_ATTACHMENT_COUNT) ?> files, max. <?= htmlentities(MAX_ATTACHMENT_SIZE >> 20) ?> MiB each)</small></label>
+ <label for="i_files"><?= __("Attachments: <small>(max. %max_attachment_count% files, max. %max_attachment_size% MiB each)</small>", [
+ "max_attachment_count" => strval(MAX_ATTACHMENT_COUNT),
+ "max_attachment_size" => strval(MAX_ATTACHMENT_SIZE >> 20)
+ ]) ?></label>
<input type="file" name="files[]" id="i_files" multiple accept="*/*">
</div>
-<button type="submit" class="btn btn-success">Create topic</button>
+<button type="submit" class="btn btn-success"><?= __("Create topic") ?></button>
</form>
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) {
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post">
<div class="form-group" id="group0">
- <label for="i_username">Username:</label>
+ <label for="i_username"><?= __("Username:") ?></label>
<input class="form-control" id="i_username" type="text" name="username" value="" required>
</div>
<div class="form-group" id="group1">
- <label for="i_username">Username:</label>
+ <label for="i_username"><?= __("Username:") ?></label>
<input class="form-control" id="i_username" type="text" name="df82a9bc21" value="<?= htmlentities($lastForm["username"] ?? "") ?>" required>
</div>
<div class="form-group" id="group2">
- <label for="i_display_name">Display name:</label>
+ <label for="i_display_name"><?= __("Display name:") ?></label>
<input class="form-control" id="i_display_name" type="text" name="display_name" value="<?= htmlentities($lastForm["display_name"] ?? "") ?>" required>
</div>
<div class="form-group" id="group3">
- <label for="i_password">Choose password:</label>
+ <label for="i_password"><?= __("Choose password:") ?></label>
<input class="form-control" id="i_password" type="password" name="password" required>
</div>
<div class="form-group" id="group4">
- <label for="i_password_retype">Repeat password:</label>
+ <label for="i_password_retype"><?= __("Repeat password:") ?></label>
<input class="form-control" id="i_password_retype" type="password" name="password_retype" required>
</div>
<div class="form-group" id="group5">
- <label for="i_email">Email address:</label>
+ <label for="i_email"><?= __("Email address:") ?></label>
<input class="form-control" id="i_email" type="email" name="email" value="<?= htmlentities($lastForm["email"] ?? "") ?>" required>
</div>
<div class="form-group" id="group6">
- <label for="i_email">CAPTCHA:</label>
+ <label for="i_email"><?= __("CAPTCHA:") ?></label>
<div class="text-center margin-bottom">
<img src="?_action=captcha&t=<?= htmlentities(strval(microtime(true) * 1000)) ?>" alt="CAPTCHA" width="192" height="48" id="captcha-img">
</div>
<div class="input-group">
<input type="text" name="captcha" id="i_captcha" class="form-control" required>
<div class="input-group-btn">
- <button class="btn btn-default" type="button" id="btn-refresh-captcha"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span><span class="sr-only">New CAPTCHA</span></button>
+ <button class="btn btn-default" type="button" id="btn-refresh-captcha"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span><span class="sr-only"><?= __("New CAPTCHA") ?></span></button>
</div>
</div>
</div>
<div class="form-group">
- <button class="btn btn-default" type="submit">Register now</button>
+ <button class="btn btn-default" type="submit"><?= __("Register now") ?></button>
</div>
<div class="form-group">
- Already have an account? <a href="?_action=auth">Sign in now</a>
+ <?= __("Already have an account? %link%Sign in now%/link%", [
+ "link" => '<a href="?_action=auth">',
+ "/link" => '</a>',
+ ]) ?>
</div>
</form>
</div>
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;
?>
<ul class="nav navbar-nav navbar-right">
-<li><p class="navbar-text">Welcome,
-<?php if ($user->id === User::SUPERUSER_ID): ?>
-<strong class="text-danger"><?= htmlentities($user->displayName) ?></strong>!
-<?php else: ?>
-<strong><?= htmlentities($user->displayName) ?></strong>!
-<?php endif; ?>
+<li><p class="navbar-text"><?= __("Welcome, %user%!", [
+ "user" => ($user->id === User::SUPERUSER_ID) ? ('<strong class="text-danger">' . htmlentities($user->displayName) . '</strong>') : ('<strong>' . htmlentities($user->displayName) . '</strong>')
+]) ?>
</p></li>
<li><a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($user->id)) ?>"><span class="glyphicon glyphicon-user" aria-hidden="true"></span><span class="sr-only">View profile</span></a></li>
<li><a href="?_action=logout&amp;next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span><span class="sr-only">Log out</span></a></li>
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;
<div class="media-body">
<div class="well icon-well text-warning">
<span class="glyphicon glyphicon-exclamation-sign color-warning" aria-hidden="true"></span>
- <em>This post has been deleted</em>
+ <em><?= __("This post has been deleted") ?></em>
</div>
</div>
</div>
@@ -41,10 +41,10 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
<div class="media-left hidden-sm hidden-xs">
<?php if ($postAuthor): ?>
<?php if ($hide_actions): ?>
- <img class="media-object" alt="Profile picture" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">
+ <img class="media-object" alt="<?= __("Profile picture") ?>" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">
<?php else: ?>
<a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>">
- <img class="media-object" alt="Profile picture" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">
+ <img class="media-object" alt="<?= __("Profile picture") ?>" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64">
</a>
<?php endif; ?>
<?php else: ?>
@@ -58,17 +58,17 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
<div class="panel-title h3">
<?php if (!$hide_actions): ?>
<div class="pull-right">
- <a href="#post-<?= htmlentities(urlencode($post->id)) ?>" class="btn btn-default"><span class="glyphicon glyphicon-link" aria-hidden="true"></span><span class="sr-only">Permalink</span></a>
+ <a href="#post-<?= htmlentities(urlencode($post->id)) ?>" class="btn btn-default"><span class="glyphicon glyphicon-link" aria-hidden="true"></span><span class="sr-only"><?= __("Permalink") ?></span></a>
<?php if ($canReply): ?>
- <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _reply-post"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span><span class="sr-only">Reply to post</span></button>
+ <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _reply-post"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span><span class="sr-only"><?= __("Reply to post") ?></span></button>
<?php endif; ?>
<?php if ($canEdit): ?>
- <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _edit-post"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span><span class="sr-only">Edit post</span></button>
+ <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _edit-post"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span><span class="sr-only"><?= __("Edit post") ?></span></button>
<?php endif; ?>
<?php if ($canDelete): ?>
<form action="?_action=deletepost" method="post" class="seamless-inline">
<input type="hidden" name="post" value="<?= htmlentities($post->id) ?>">
- <button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span><span class="sr-only">Delete post</span></button>
+ <button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span><span class="sr-only"><?= __("Delete post") ?></span></button>
</form>
<?php endif; ?>
</div>
@@ -80,15 +80,15 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
<a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a>
<?php endif; ?>
<?php if ($your_are_the_author): ?>
- <span class="text-normal label label-primary">You</span>
+ <span class="text-normal label label-primary"><?= __("You") ?></span>
<?php endif; ?>
<?php else: ?>
- <em class="text-muted">(deleted)</em>
+ <em class="text-muted"><?= __("(deleted)") ?></em>
<?php endif; ?>
</div>
<span class="_time"><?= $post->postDate->format("c"); ?></span>
<?php if ($post->edited): ?>
- <em class="text-muted">(edited)</em>
+ <em class="text-muted"><?= __("(edited)") ?></em>
<?php endif; ?>
</div>
<div class="panel-body">
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-
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 class="modal-title">Edit post</h4>
+ <h4 class="modal-title"><?= __("Edit post") ?></h4>
</div>
<div class="modal-body">
- <div class="form-group">
- <label class="sr-only" for="i_edit_message">Message:</label>
- <textarea class="form-control" name="message" id="i_edit_message" rows="12" style="resize: vertical; max-height: 500px"></textarea>
- </div>
+ <label class="sr-only" for="i_edit_message"><?= __("Message:") ?></label>
+ <textarea class="form-control" name="message" id="i_edit_message" rows="12" style="resize: vertical; max-height: 500px"></textarea>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button>
- <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Save changes</button>
+ <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> <?= __("Cancel") ?></button>
+ <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> <?= __("Save changes") ?></button>
</div>
</div>
</form>
@@ -37,14 +35,14 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor-
<div class="modal-dialog modal-danger" role="document">
<div class="modal-content panel-danger">
<div class="modal-header panel-heading">
- <h4 class="modal-title"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> Permission denied</h4>
+ <h4 class="modal-title"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> <?= __("Permission denied") ?></h4>
</div>
<div class="modal-body">
- You must be logged in to view attachments
+ <?= __("You must be logged in to view attachments") ?>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Close</button>
- <a href="?_action=auth&amp;next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>" class="btn btn-success"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Log in</a>
+ <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> <?= __("Close") ?></button>
+ <a href="?_action=auth&amp;next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>" class="btn btn-success"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> <?= __("Log in") ?></a>
</div>
</div>
</div>
@@ -65,37 +63,34 @@ $canDelete = ($GLOBALS["currentUser"]?->id === $topicAuthor->id && $topicAuthor-
<?= htmlentities($topic->title) ?>
<div class="pull-right text-normal">
<?php if ($canEdit): ?>
- <button id="btn-edit-title" class="btn btn-default js-only"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit title</button>
+ <button id="btn-edit-title" class="btn btn-default js-only"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> <?= __("Edit title") ?></button>
<?php endif; ?>
<?php if ($canReply): ?>
- <button id="btn-reply" class="btn btn-default js-only"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> Reply</button>
+ <button id="btn-reply" class="btn btn-default js-only"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> <?= __("Reply") ?></button>
<?php endif; ?>
<?php if ($canDelete): ?>
<form action="?_action=deletetopic" method="post" class="seamless-inline">
<input type="hidden" name="topic" value="<?= htmlentities($topic->id) ?>">
- <button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete topic</button>
+ <button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <?= __("Delete topic") ?></button>
</form>
<?php endif; ?>
</div>
</div><br>
- Started by
- <?php if ($topicAuthor !== null): ?>
- <a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($topicAuthor->id)) ?>"><?= htmlentities($topicAuthor->displayName) ?></a>
- <?php else: ?>
- <em>(deleted)</em>
- <?php endif; ?>
- on <span class="_time"><?= htmlentities($topic->creationDate->format("c")) ?></span>
+ <?= __("Started by %user% on %date%", [
+ "user" => ($topicAuthor !== null) ? ('<a href="?_action=viewuser&amp;user=' . htmlentities(urlencode($topicAuthor->id)) . '">' . htmlentities($topicAuthor->displayName) . '</a>') : __("(deleted)"),
+ "date" => '<span class="_time">' . htmlentities($topic->creationDate->format("c")) . '</span>',
+ ]); ?>
</div>
<?php if ($canEdit): ?>
- <form action="?_action=updatetopic" method="post" id="editHeading" style="display: none;" class="form-inline seamless-inline" style="display: block">
+ <form action="?_action=updatetopic" method="post" id="editHeading" style="display: none;" class="form-inline seamless-inline">
<input type="hidden" name="topic" value="<?= htmlentities(urlencode($topic->id)) ?>">
<div class="row">
<div class="col-md-8">
<input type="text" class="form-control" name="title" id="i_edit_title" data-original-value="<?= htmlentities($topic->title) ?>" value="<?= htmlentities($topic->title) ?>" style="box-sizing: border-box; width: 100%; font-size: 36px; height: 56px">
</div>
<div class="col-md-4 text-right">
- <button type="button" id="topicTitleEditCancel" class="btn btn-default"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Cancel</button>
- <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Save changes</button>
+ <button type="button" id="topicTitleEditCancel" class="btn btn-default"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> <?= __("Cancel") ?></button>
+ <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> <?= __("Save changes") ?></button>
</div>
</div>
</form>
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)):
?>
<p class="text-right">
-<a href="?_action=newtopic" class="btn btn-success"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;New topic</a>
+<a href="?_action=newtopic" class="btn btn-success"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> <?= __("New topic") ?></a>
</p>
<?php endif; ?>
<div class="list-group">
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);
<img class="pull-left margin-right" src="?_action=profilepicture&amp;user=<?= htmlentities(urlencode($user->id)) ?>">
<span class="h1"><?= htmlentities($user->displayName) ?></span>
<?php if ($isOwnProfile): ?>
- <span class="label label-primary">You</span>
+ <span class="label label-primary"><?= __("You") ?></span>
<?php endif; ?><br>
- @<?= htmlentities($user->name) ?> &bull; <span class="text-muted">Member since <span class="_date"><?= htmlentities($dateJoined->format("c")); ?></span></span>
+ @<?= htmlentities($user->name) ?> &bull; <span class="text-muted"><?= __("Member since %join_date%", [
+ "join_date" => '<span class="_date">' . htmlentities($dateJoined->format("c")) . '</span>',
+ ]) ?></span>
</div>
<?php if ($canEdit): ?>
@@ -40,7 +38,9 @@ $dateJoined->setTime(0, 0, 0, 0);
<div class="col-md-9">
<?php endif; ?>
-<h3><?= $sUserPossessive ?> posts</h3>
+<h3><?= __($sUserPossessive, [
+ "display_name" => $user->displayName,
+]) ?></h3>
<?php if (count($posts) > 0): ?>
<div class="post-container">
@@ -49,19 +49,22 @@ $dateJoined->setTime(0, 0, 0, 0);
<?php foreach ($posts as $post): if ($post->deleted) continue; ?>
<a href="?_action=viewtopic&amp;topic=<?= htmlentities(urlencode($post->topicId)) ?>#post-<?= htmlentities(urlencode($post->id)) ?>" class="list-group-item">
<?= htmlentities(StringUtils::truncate(strip_tags(renderPost($post->content)), 100)) ?><br>
- <span class="text-muted">posted on <span class="_time"><?= htmlentities($post->postDate->format("c")) ?></span> in <em><?= htmlentities($topics[$post->topicId]?->title ?? "unknown") ?></em></span>
+ <span class="text-muted"><?= __("posted on %post_date% in %topic%", [
+ "post_date" => '<span class="_time">' . htmlentities($post->postDate->format("c")) . '</span>',
+ "topic" => '<em>' . htmlentities($topics[$post->topicId]?->title ?? "unknown") . '</em>',
+ ]) ?></span>
</a>
<?php endforeach; ?>
</div>
</div>
<div class="post-container-controls">
- <button class="btn btn-default">Show all posts</button>
+ <button class="btn btn-default"><?= __("Show all posts") ?></button>
</div>
</div>
<?php else: ?>
<div class="well icon-well text-info margin-top margin-bottom">
<span class="glyphicon glyphicon-info-sign color-info" aria-hidden="true"></span>
- <em>This user has not posted anything yet</em>
+ <em><?= __("This user has not posted anything yet") ?></em>
</div>
<?php endif; ?>
@@ -69,7 +72,7 @@ $dateJoined->setTime(0, 0, 0, 0);
</div>
<div class="col-md-3">
-<h3>Edit<?= $sIsOwn_your ?> profile</h3>
+<h3><?= __("Edit profile") ?></h3>
<?php
if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
_view("alert_error", ["message" => $_formError]);
@@ -77,24 +80,24 @@ if (($_formError = RequestUtils::getAndClearFormError()) !== null) {
?>
<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post" enctype="multipart/form-data">
<div class="form-group">
- <label for="i_display_name">Display name:</label>
+ <label for="i_display_name"><?= __("Display name:") ?></label>
<input required class="form-control" type="text" name="display_name" id="i_display_name" value="<?= htmlentities($user->displayName) ?>">
</div>
<div class="form-group">
- <label for="i_name">Login name:</label>
+ <label for="i_name"><?= __("Username:") ?></label>
<?php if ($lastNameChangeTooRecent): ?>
<input required class="form-control" type="text" id="i_name" value="<?= htmlentities($user->name) ?>" disabled>
- <small class="text-danger"><strong>You can only change your username every 30 days!</strong></small>
+ <small class="text-danger"><strong><?= __("You can only change your username every 30 days!") ?></strong></small>
<?php else: ?>
<input required class="form-control" type="text" name="name" id="i_name" value="<?= htmlentities($user->name) ?>">
<?php endif; ?>
</div>
<div class="form-group">
- <label for="i_email">Email address:</label>
+ <label for="i_email"><?= __("Email address:") ?></label>
<input required class="form-control" type="email" id="i_email" value="<?= htmlentities($user->email) ?>" disabled>
</div>
<div class="form-group">
- <label>Profile picture:</label>
+ <label><?= __("Profile picture:") ?></label>
<?php
$_checkbox_disabled = empty($user->profilePicture);
$_checkbox_disabled_class = $_checkbox_disabled ? " disabled text-muted" : "";
@@ -102,29 +105,29 @@ $_checkbox_disabled_class = $_checkbox_disabled ? " disabled text-muted" : "";
<div class="radio margin-top-0 <?= $_checkbox_disabled_class ?>">
<label>
<input type="radio" name="pfp_action" id="pfp_action_1" value="keep"<?= !empty($user->profilePicture) ? ' checked' : ' disabled' ?>>
- Keep current profile picture
+ <?= __("Keep current profile picture") ?>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="pfp_action" id="pfp_action_2" value="remove"<?= empty($user->profilePicture) ? ' checked' : '' ?>>
<?php if (empty($user->profilePicture)): ?>
- No profile picture
+ <?= __("No profile picture") ?>
<?php else: ?>
- Remove profile picture
+ <?= __("Remove profile picture") ?>
<?php endif; ?>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="pfp_action" value="replace" id="pfp_action_3">
- Upload new profile picture
+ <?= __("Upload new profile picture") ?>
</label>
</div>
<input type="file" name="pfp" id="i_pfp" accept="image/png,image/jpeg" class="margin-left-3x">
</div>
<div class="form-group">
- <button type="submit" class="btn btn-success">Save changes</button>
+ <button type="submit" class="btn btn-success"><?= __("Save changes") ?></button>
</div>
</form>
</div>