diff options
author | Philip Häusler <msquare@notrademark.de> | 2013-11-28 22:40:48 +0100 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2013-11-28 22:40:48 +0100 |
commit | 1e05da6c8114238edb499fd21104bd573f9cf3e3 (patch) | |
tree | f9bb035f606774a85a17748619e2e10bad1b58b8 | |
parent | 8a5915594ffbbf529c827b2ce31a64590b0d1b14 (diff) |
gettext for user sites
-rw-r--r-- | includes/pages/guest_login.php | 12 | ||||
-rw-r--r-- | includes/pages/user_messages.php | 10 | ||||
-rw-r--r-- | includes/pages/user_myshifts.php | 4 | ||||
-rw-r--r-- | includes/pages/user_news.php | 8 | ||||
-rw-r--r-- | includes/pages/user_settings.php | 2 | ||||
-rw-r--r-- | includes/pages/user_shifts.php | 61 | ||||
-rw-r--r-- | public/css/base.css | 4 | ||||
-rw-r--r-- | templates/admin_shifts_angel_types.html | 8 | ||||
-rw-r--r-- | templates/user_shifts.html | 9 | ||||
-rw-r--r-- | templates/user_shifts_admin_delete.html | 6 | ||||
-rw-r--r-- | templates/user_shifts_edit.html | 35 |
11 files changed, 58 insertions, 101 deletions
diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 84bf34c2..c7ba4380 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -152,7 +152,7 @@ function guest_register() { form_text('jabber', _("Jabber"), $jabber), form_text('hometown', _("Hometown"), $hometown), $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $tshirt_size) : '', - form_textarea('comment', _("Did you help at former CCC events and which tasks have you performed then?"), $comment), + // form_textarea('comment', _("Did you help at former CCC events and which tasks have you performed then?"), $comment), form_checkboxes('angel_types', _("What do you want to do?") . sprintf("<br>(<a href=\"https://events.ccc.de/congress/2012/wiki/Volunteers#What_kind_of_volunteers_are_needed.3F\">%s</a>)", _("Description of job types")), $angel_types, $selected_angel_types), form_info("", _("Restricted angel types need will be confirmed later by an archangel. You can change your selection in the options section.")), form_password('password', _("Password") . "*"), @@ -171,7 +171,6 @@ function guest_logout() { function guest_login() { global $user; - $msg = ""; $nick = ""; unset($_SESSION['uid']); @@ -187,19 +186,19 @@ function guest_login() { if (isset($_REQUEST['password'])) { if (! verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) { $ok = false; - $msg .= error(_("Your password is incorrect. Please try it again."), true); + error(_("Your password is incorrect. Please try it again.")); } } else { $ok = false; - $msg .= error(_("Please enter a password."), true); + error(_("Please enter a password.")); } } else { $ok = false; - $msg .= error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask an Dispatcher."), true); + error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask an Dispatcher.")); } } else { $ok = false; - $msg .= error(_("Please enter a nickname."), true); + error(_("Please enter a nickname.")); } if ($ok) { @@ -210,7 +209,6 @@ function guest_login() { } return page(array( - $msg, msg(), _("Resistance is futile! Your biological and physical parameters will be added to our collectiv! Assimilating angel:"), form(array( diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php index c71dea92..f4928333 100644 --- a/includes/pages/user_messages.php +++ b/includes/pages/user_messages.php @@ -10,7 +10,7 @@ function user_unread_messages() { $new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`=" . sql_escape($user['UID'])); if ($new_messages > 0) - return sprintf('<p class="info"><a href="%s">%s</a></p><hr />', page_link_to("user_messages"), sprintf(_("You have %s new messages.", $new_messages))); + return sprintf('<p class="info"><a href="%s">%s</a></p><hr />', page_link_to("user_messages"), sprintf(ngettext("You have %s new message.", "You have %s new messages.", $new_messages), $new_messages)); } return ""; @@ -23,7 +23,7 @@ function user_messages() { $users = sql_select("SELECT * FROM `User` WHERE NOT `UID`=" . sql_escape($user['UID']) . " ORDER BY `Nick`"); $to_select_data = array( - "" => "Select recipient..." + "" => _("Select recipient...") ); foreach ($users as $u) @@ -36,10 +36,10 @@ function user_messages() { foreach ($messages as $message) { $sender_user_source = User($message['SUID']); if ($sender_user_source === false) - engelsystem_error("Unable to load user."); + engelsystem_error(_("Unable to load user.")); $receiver_user_source = User($message['RUID']); if ($receiver_user_source === false) - engelsystem_error("Unable to load user."); + engelsystem_error(_("Unable to load user.")); $messages_html .= sprintf('<tr %s> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td><td>%s</td>', ($message['isRead'] == 'N' ? ' class="new_message"' : ''), ($message['isRead'] == 'N' ? '•' : ''), date("Y-m-d H:i", $message['Datum']), User_Nick_render($sender_user_source), User_Nick_render($receiver_user_source), str_replace("\n", '<br />', $message['Text'])); @@ -55,7 +55,7 @@ function user_messages() { return template_render('../templates/user_messages.html', array( 'link' => page_link_to("user_messages"), - 'greeting' => _(sprintf("Hello %s, here can you leave messages for other angels", User_Nick_render($user))) . '<br /><br />', + 'greeting' => sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)) . '<br /><br />', 'messages' => $messages_html, 'new_label' => _("New"), 'date_label' => _("Date"), diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index b3f98e6f..9ccd8240 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -20,7 +20,7 @@ function user_myshifts() { if (isset($_REQUEST['reset'])) { if ($_REQUEST['reset'] == "ack") { User_reset_api_key($user); - success("Key geändert."); + success(_("Key changed.")); redirect(page_link_to('user_myshifts')); } return template_render('../templates/user_myshifts_reset.html', array()); @@ -35,7 +35,7 @@ function user_myshifts() { $user_source = User($shift['UID']); sql_query("UPDATE `ShiftEntry` SET `Comment`='" . sql_escape($comment) . "' WHERE `id`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("Updated " . User_Nick_render($user_source) . "'s shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end']) . " with comment " . $comment); - success("Schicht gespeichert."); + success(_("Shift saved.")); redirect(page_link_to('user_myshifts')); } diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php index ed4de018..d082b411 100644 --- a/includes/pages/user_news.php +++ b/includes/pages/user_news.php @@ -50,7 +50,7 @@ function display_news($news) { $user_source = User($news['UID']); if($user_source === false) - engelsystem_error("Unable to load user."); + engelsystem_error(_("Unable to load user.")); $html .= User_Nick_render($user_source); if ($p != "news_comments") @@ -59,7 +59,7 @@ function display_news($news) { $html .= '<h3>' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '</h3>'; $html .= '<p>' . ReplaceSmilies(nl2br($news['Text'])) . '</p>'; if (in_array("admin_news", $privileges)) - $html .= "<details><a href=\"" . page_link_to("admin_news") . "&action=edit&id=" . $news['ID'] . "\">Edit</a></details>\n"; + $html .= '<details><a href="' . page_link_to("admin_news") . '&action=edit&id=' . $news['ID'] . '">' . _("edit") . '</a></details>'; $html .= '</article>'; return $html; @@ -79,7 +79,7 @@ function user_news_comments() { $html .= success(_("Entry saved."), true); } - $html .= '<a href="' . page_link_to("news") . '">« Back</a>'; + $html .= '<a href="' . page_link_to("news") . '">« ' . _("back") . '</a>'; $html .= display_news($news); $html .= '<h2>' . _("Comments") . '</h2>'; @@ -88,7 +88,7 @@ function user_news_comments() { foreach ($comments as $comment) { $user_source = User($comment['UID']); if($user_source === false) - engelsystem_error("Unable to load user."); + engelsystem_error(_("Unable to load user.")); $html .= '<article class="news_comment">'; $html .= User_Avatar_render($user_source); diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 334fea45..9705fcdf 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -140,7 +140,7 @@ function user_settings() { if ($ok) { sql_query("UPDATE `User` SET `color`='" . sql_escape($selected_theme) . "' WHERE `UID`=" . sql_escape($user['UID'])); - success("Theme changed."); + success(_("Theme changed.")); redirect(page_link_to('user_settings')); } } elseif (isset($_REQUEST['submit_language'])) { diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 0cd6697d..19adf08e 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -19,9 +19,9 @@ function user_shifts() { sql_query("DELETE FROM `ShiftEntry` WHERE `id`=" . sql_escape($entry_id) . " LIMIT 1"); engelsystem_log("Deleted " . User_Nick_render($shift_entry_source) . "'s shift: " . $shift_entry_source['name'] . " at " . $shift_entry_source['Name'] . " from " . date("y-m-d H:i", $shift_entry_source['start']) . " to " . date("y-m-d H:i", $shift_entry_source['end']) . " as " . $shift_entry_source['angel_type']); - success("Der Schicht-Eintrag wurde gelöscht."); + success(_("Shift entry deleted.")); } else - error("Entry not found."); + error(_("Entry not found.")); redirect(page_link_to('user_shifts')); } // Schicht bearbeiten elseif (isset($_REQUEST['edit_shift']) && in_array('admin_shifts', $privileges)) { @@ -86,26 +86,26 @@ function user_shifts() { else { $ok = false; $rid = $rooms[0]['RID']; - $msg .= error("Wähle bitte einen Raum aus.", true); + $msg .= error(_("Please select a room."), true); } if (isset($_REQUEST['start']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['start']))) $start = $tmp->getTimestamp(); else { $ok = false; - $msg .= error("Bitte gib einen Startzeitpunkt für die Schichten an.", true); + $msg .= error(_("Please enter a valid starting time for the shifts."), true); } if (isset($_REQUEST['end']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['end']))) $end = $tmp->getTimestamp(); else { $ok = false; - $msg .= error("Bitte gib einen Endzeitpunkt für die Schichten an.", true); + $msg .= error(_("Please enter a valid ending time for the shifts."), true); } if ($start >= $end) { $ok = false; - $msg .= error("Das Ende muss nach dem Startzeitpunkt liegen!", true); + $msg .= error(_("The ending time has to be after the starting time."), true); } foreach ($needed_angel_types_source as $type) { @@ -113,7 +113,7 @@ function user_shifts() { $needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]); } else { $ok = false; - $msg .= error("Bitte überprüfe die Eingaben für die benötigten Engel des Typs " . $type['name'] . ".", true); + $msg .= error(sprintf(_("Please check your input for needed angels of type %s."), $type['name']), true); } } @@ -127,7 +127,7 @@ function user_shifts() { } engelsystem_log("Updated shift '" . $name . "' from " . date("y-m-d H:i", $start) . " to " . date("y-m-d H:i", $end) . " with angel types " . join(", ", $needed_angel_types_info)); - success("Schicht gespeichert."); + success(_("Shift updated.")); redirect(page_link_to('user_shifts')); } } @@ -143,13 +143,18 @@ function user_shifts() { )); } - return template_render('../templates/user_shifts_edit.html', array( - 'msg' => $msg, - 'name' => $name, - 'room_select' => $room_select, - 'start' => date("Y-m-d H:i", $start), - 'end' => date("Y-m-d H:i", $end), - 'angel_types' => $angel_types + return page(array( + msg(), + '<noscript>' . info(_("This page is much more comfortable with javascript."), true) . '</noscript>', + form(array( + form_text('name', _("Name/Description:"), $name), + form_select('rid', _("Room:"), $room_array, $rid), + form_text('start', _("Start:"), date("Y-m-d H:i", $start)), + form_text('end', _("End:"), date("Y-m-d H:i", $end)), + '<h2>' . _("Needed angels") . '</h2>', + $angel_types, + form_submit('submit', _("Save")) + )) )); } // Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg) elseif (isset($_REQUEST['delete_shift']) && in_array('user_shifts_admin', $privileges)) { @@ -170,15 +175,13 @@ function user_shifts() { sql_query("DELETE FROM `Shifts` WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1"); engelsystem_log("Deleted shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end'])); - success("Die Schicht wurde gelöscht."); + success(_("Shift deleted.")); redirect(page_link_to('user_shifts')); } - return template_render('../templates/user_shifts_admin_delete.html', array( - 'name' => $shift['name'], - 'start' => date("Y-m-d H:i", $shift['start']), - 'end' => date("H:i", $shift['end']), - 'id' => $shift_id + return page(array( + error(sprintf(_("Do you want to delete the shift %s from %s to %s?"), $shift['name'], date("Y-m-d H:i", $shift['start']), date("H:i", $shift['end'])), true), + '<a class="button" href="?p=user_shifts&delete_shift=' . $shift_id . '&delete">' . _("delete") . '</a>' )); } elseif (isset($_REQUEST['shift_id'])) { if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) @@ -198,13 +201,13 @@ function user_shifts() { // Schicht läuft schon, Eintragen für Engel nicht mehr möglich if (! in_array('user_shifts_admin', $privileges) && time() > $shift['start']) { - error("Diese Schicht läuft gerade oder ist bereits vorbei. Bitte kontaktiere den Schichtkoordinator um Dich eintragen zu lassen."); + error(_("This shift is running now or ended already. Please contact a dispatcher to join the shift.")); redirect(page_link_to('user_shifts')); } // Another shift the user is signed up for collides with this one if (! in_array('user_shifts_admin', $privileges) && sql_num_query("SELECT `Shifts`.`SID` FROM `Shifts` INNER JOIN `ShiftEntry` ON (`Shifts`.`SID` = `ShiftEntry`.`SID` AND `ShiftEntry`.`UID` = " . sql_escape($user['UID']) . ") WHERE `start` < '" . sql_escape($shift['end']) . "' AND `end` > '" . sql_escape($shift['start']) . "'") > 0) { - error("Du bist bereits in einer parallelen Schicht eingetragen. Bitte kontaktiere den Schichtkoordinator, um dich eintragen zu lassen."); + error(_("You already subscribed to shift in the same timeslot. Please contact a dispatcher to join the shift.")); redirect(page_link_to('user_shifts')); } @@ -243,7 +246,7 @@ function user_shifts() { $user_source = User($user_id); engelsystem_log("User " . User_Nick_render($user_source) . " signed up for shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end'])); - success("Du bist eingetragen. Danke!" . ' <a href="' . page_link_to('user_myshifts') . '">Meine Schichten »</a>'); + success(_("You are subscribed. Thank you!") . ' <a href="' . page_link_to('user_myshifts') . '">' . _("My shifts") . ' »</a>'); redirect(page_link_to('user_shifts')); } @@ -521,7 +524,7 @@ function view_user_shifts() { if (time() > $shift['start']) $entry_list[] = $inner_text . ' (vorbei)'; elseif ($angeltype['restricted'] == 1 && isset($angeltype['user_id']) && ! isset($angeltype['confirm_user_id'])) - $entry_list[] = $inner_text . ' <img src="pic/lock.png" alt="unconfirmed" title="Du bist für diesen Engeltyp noch nicht freigeschaltet." />'; + $entry_list[] = $inner_text . ' <img src="pic/lock.png" alt="unconfirmed" title="' . _("You are not confirmed for this angel type.") . '" />'; elseif ($collides) $entry_list[] = $inner_text; else @@ -537,7 +540,7 @@ function view_user_shifts() { $shifts_row .= '<br />'; } if (in_array('user_shifts_admin', $privileges)) { - $shifts_row .= '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">Weitere Helfer eintragen »</a>'; + $shifts_row .= '<a href="' . page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'] . '">' . _("Add more angels") .' »</a>'; } } if ($shift['own'] && ! in_array('user_shifts_admin', $privileges)) @@ -687,11 +690,11 @@ function view_user_shifts() { 'end_time' => $_SESSION['user_shifts']['end_time'], 'type_select' => make_select($types, $_SESSION['user_shifts']['types'], "types", _("Tasks") . '<sup>1</sup>'), 'filled_select' => make_select($filled, $_SESSION['user_shifts']['filled'], "filled", _("Occupancy")), - 'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the preferences you defined in your settings! <a href=\"https://events.ccc.de/congress/2012/wiki/Volunteers#What_kind_of_volunteers_are_needed.3F\">Description of the jobs</a>."), + 'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the preferences you defined in your settings!") . " <a href=\"https://events.ccc.de/congress/2013/wiki/Volunteers#What_kind_of_volunteers_are_needed.3F\">" . _("Description of the jobs.") . "</a>", 'new_style_checkbox' => '<label><input type="checkbox" name="new_style" value="1" ' . ($_SESSION['user_shifts']['new_style'] ? ' checked' : '') . '> Use new style if possible</label>', 'shifts_table' => $shifts_table, - 'ical_text' => sprintf(_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset'), - 'filter' => _("Filter") + 'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf(_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset') . '</p>', + 'filter' => _("Filter") )); } diff --git a/public/css/base.css b/public/css/base.css index a08042fd..1088582a 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -336,14 +336,14 @@ tr:hover .hidden { text-decoration: line-through; } -.spinner a { +.form .form_input.spinner a { background: #f0f0f0; border: 1px solid #888; padding: 1px 5px; text-decoration: none; } -.spinner input { +.form .form_input.spinner input { border: 1px solid #888; border-left: none; border-right: none; diff --git a/templates/admin_shifts_angel_types.html b/templates/admin_shifts_angel_types.html index 04e31c81..9b54fb89 100644 --- a/templates/admin_shifts_angel_types.html +++ b/templates/admin_shifts_angel_types.html @@ -1,8 +1,8 @@ -<p> - <label> +<div class="form_element"> + <label class="form_label"> %type%: </label> - <span class="spinner"><a id="type_%id%_down" href="#">-</a><input type="text" id="type_%id%" name="type_%id%" value="%value%" /><a id="type_%id%_up" href="#">+</a></span> + <div class="form_input spinner"><a id="type_%id%_down" href="#">-</a><input type="text" id="type_%id%" name="type_%id%" value="%value%" /><a id="type_%id%_up" href="#">+</a></div> <script type="text/javascript"> document.getElementById("type_%id%_up").onclick = function(e){ document.getElementById("type_%id%").value = (parseInt(document.getElementById("type_%id%").value) + 101) % 100; @@ -19,4 +19,4 @@ return false; }; </script> -</p> +</div> diff --git a/templates/user_shifts.html b/templates/user_shifts.html index 0bdebc50..ea73ead1 100644 --- a/templates/user_shifts.html +++ b/templates/user_shifts.html @@ -9,8 +9,8 @@ function set_to_now(id) { } } </script> -<form action="#shifts" type="get"> -<fieldset class="form" id="filter"><legend>Filter</legend> +<form action="#shifts" method="get"> +<fieldset class="form" id="filter"><legend>%filter%</legend> <div> %start_select% <input type="time" id="start_time" name="start_time" size="5" pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%start_time%"> <img src="pic/icons/clock.png" alt="Now" title="Now" style="cursor: pointer;vertical-align: middle;" onclick="set_to_now('start');"> – %end_select% <input type="time" id="end_time" name="end_time" size="5" pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%end_time%"> <img src="pic/icons/clock.png" alt="Now" title="Now" style="cursor: pointer;vertical-align: middle;" onclick="set_to_now('end');"> @@ -27,7 +27,4 @@ function set_to_now(id) { %shifts_table% -<h2>iCal Export</h2> -<p> - %ical_text% -</p> +%ical_text% diff --git a/templates/user_shifts_admin_delete.html b/templates/user_shifts_admin_delete.html deleted file mode 100644 index b225065d..00000000 --- a/templates/user_shifts_admin_delete.html +++ /dev/null @@ -1,6 +0,0 @@ -<p class="error"> - Die Schicht "%name%" von %start% - %end% löschen? -</p> -<p> - <a class="button" href="?p=user_shifts&delete_shift=%id%&delete">Löschen</a> -</p> diff --git a/templates/user_shifts_edit.html b/templates/user_shifts_edit.html deleted file mode 100644 index f129e5e4..00000000 --- a/templates/user_shifts_edit.html +++ /dev/null @@ -1,35 +0,0 @@ -<noscript> - Diese Seite ist mit aktiviertem JavaScript sehr viel komfortabler. -</noscript> -<form action="" method="post"> - <fieldset> - %msg% - <p> - <label> - Name/Beschreibung: - </label> - <input type="text" name="name" value="%name%" /> - </p> - <p> - <label> - Ort: - </label>%room_select% - </p> - <p> - <label> - Beginn: - </label> - <input type="text" name="start" value="%start%" /> - </p> - <p> - <label> - Ende: - </label> - <input type="text" name="end" value="%end%" /> - </p><h2>Benötigte Engel:</h2> - %angel_types% - <p> - <input type="submit" name="submit" value="Speichern" /> - </p> - </fieldset> -</form>
\ No newline at end of file |