From 1e05da6c8114238edb499fd21104bd573f9cf3e3 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Thu, 28 Nov 2013 22:40:48 +0100 Subject: gettext for user sites --- includes/pages/guest_login.php | 12 ++++---- includes/pages/user_messages.php | 10 +++---- includes/pages/user_myshifts.php | 4 +-- includes/pages/user_news.php | 8 +++--- includes/pages/user_settings.php | 2 +- includes/pages/user_shifts.php | 61 +++++++++++++++++++++------------------- 6 files changed, 49 insertions(+), 48 deletions(-) (limited to 'includes/pages') 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("
(%s)", _("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('

%s


', page_link_to("user_messages"), sprintf(_("You have %s new messages.", $new_messages))); + return sprintf('

%s


', 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(' %s %s %s %s%s', ($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", '
', $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))) . '

', + 'greeting' => sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)) . '

', '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 .= '

' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '

'; $html .= '

' . ReplaceSmilies(nl2br($news['Text'])) . '

'; if (in_array("admin_news", $privileges)) - $html .= "
Edit
\n"; + $html .= '
' . _("edit") . '
'; $html .= ''; return $html; @@ -79,7 +79,7 @@ function user_news_comments() { $html .= success(_("Entry saved."), true); } - $html .= '« Back'; + $html .= '« ' . _("back") . ''; $html .= display_news($news); $html .= '

' . _("Comments") . '

'; @@ -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 .= '
'; $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(), + '', + 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)), + '

' . _("Needed angels") . '

', + $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), + '' . _("delete") . '' )); } 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!" . ' Meine Schichten »'); + success(_("You are subscribed. Thank you!") . ' ' . _("My shifts") . ' »'); 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 . ' unconfirmed'; + $entry_list[] = $inner_text . ' unconfirmed'; elseif ($collides) $entry_list[] = $inner_text; else @@ -537,7 +540,7 @@ function view_user_shifts() { $shifts_row .= '
'; } if (in_array('user_shifts_admin', $privileges)) { - $shifts_row .= 'Weitere Helfer eintragen »'; + $shifts_row .= '' . _("Add more angels") .' »'; } } 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") . '1'), 'filled_select' => make_select($filled, $_SESSION['user_shifts']['filled'], "filled", _("Occupancy")), - 'task_notice' => '1' . _("The tasks shown here are influenced by the preferences you defined in your settings! Description of the jobs."), + 'task_notice' => '1' . _("The tasks shown here are influenced by the preferences you defined in your settings!") . " " . _("Description of the jobs.") . "", 'new_style_checkbox' => '', 'shifts_table' => $shifts_table, - 'ical_text' => sprintf(_("Export of shown shifts. iCal format or JSON format available (please keep secret, otherwise reset the api key)."), 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' => '

' . _("iCal export") . '

' . sprintf(_("Export of shown shifts. iCal format or JSON format available (please keep secret, otherwise reset the api key)."), 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") )); } -- cgit v1.2.3-54-g00ecf