From 843ace580d1ea2b05e15710c1b0714dad48dac6c Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 11 Mar 2011 19:05:28 +0100 Subject: [PATCH] i18n/L10n updates Translator documentation added --- plugins/Poll/Poll.php | 11 +++++++---- plugins/Poll/PollPlugin.php | 20 ++++++++++++++------ plugins/Poll/Poll_response.php | 10 +++++++--- plugins/Poll/newpoll.php | 4 ++++ plugins/Poll/newpollform.php | 5 +++++ plugins/Poll/pollresponseform.php | 1 + plugins/Poll/respondpoll.php | 10 +++++++--- plugins/Poll/showpoll.php | 8 +++++++- 8 files changed, 52 insertions(+), 17 deletions(-) diff --git a/plugins/Poll/Poll.php b/plugins/Poll/Poll.php index 001648fd21..f5fa9bade5 100644 --- a/plugins/Poll/Poll.php +++ b/plugins/Poll/Poll.php @@ -235,12 +235,15 @@ class Poll extends Managed_DataObject common_log(LOG_DEBUG, "Saving poll: $p->id $p->uri"); $p->insert(); - $content = sprintf(_m('Poll: %s %s'), + // TRANS: Notice content creating a poll. + // TRANS: %1$s is the poll question, %2$s is a link to the poll. + $content = sprintf(_m('Poll: %1$s %2$s'), $question, $p->uri); - $rendered = sprintf(_m('Poll: %s'), - htmlspecialchars($p->uri), - htmlspecialchars($question)); + $link = '' . htmlspecialchars($question) . ''; + // TRANS: Rendered version of the notice content creating a poll. + // TRANS: %s a link to the poll with the question as link description. + $rendered = sprintf(_m('Poll: %s'), $link); $tags = array('poll'); $replies = array(); diff --git a/plugins/Poll/PollPlugin.php b/plugins/Poll/PollPlugin.php index b3de0634a9..34c37eb526 100644 --- a/plugins/Poll/PollPlugin.php +++ b/plugins/Poll/PollPlugin.php @@ -153,6 +153,7 @@ class PollPlugin extends MicroAppPlugin 'author' => 'Brion Vibber', 'homepage' => 'http://status.net/wiki/Plugin:Poll', 'rawdescription' => + // TRANS: Plugin description. _m('Simple extension for supporting basic polls.')); return true; } @@ -229,11 +230,13 @@ class PollPlugin extends MicroAppPlugin $selection = intval($data->getAttribute('selection')); if (!$pollUri) { - throw new Exception('Invalid poll response: no poll reference.'); + // TRANS: Exception thrown trying to respond to a poll without a poll reference. + throw new Exception(_m('Invalid poll response: no poll reference.')); } $poll = Poll::staticGet('uri', $pollUri); if (!$poll) { - throw new Exception('Invalid poll response: poll is unknown.'); + // TRANS: Exception thrown trying to respond to a non-existing poll. + throw new Exception(_m('Invalid poll response: poll is unknown.')); } try { $notice = Poll_response::saveNew($profile, $poll, $selection, $options); @@ -258,7 +261,9 @@ class PollPlugin extends MicroAppPlugin case self::POLL_RESPONSE_OBJECT: return $this->activityObjectFromNoticePollResponse($notice); default: - throw new Exception('Unexpected type for poll plugin: ' . $notice->object_type); + // TRANS: Exception thrown when performing an unexpected action on a poll. + // TRANS: %s is the unpexpected object type. + throw new Exception(sprintf(_m('Unexpected type for poll plugin: %s.'), $notice->object_type)); } } @@ -361,7 +366,9 @@ class PollPlugin extends MicroAppPlugin case self::POLL_RESPONSE_OBJECT: return $this->showNoticePollResponse($notice, $out); default: - throw new Exception('Unexpected type for poll plugin: ' . $notice->object_type); + // TRANS: Exception thrown when performing an unexpected action on a poll. + // TRANS: %s is the unpexpected object type. + throw new Exception(sprintf(_m('Unexpected type for poll plugin: %s.'), $notice->object_type)); } } @@ -388,7 +395,7 @@ class PollPlugin extends MicroAppPlugin $form->show(); } } else { - $out->text('Poll data is missing'); + $out->text(_('Poll data is missing')); } $out->elementEnd('div'); @@ -421,6 +428,7 @@ class PollPlugin extends MicroAppPlugin function appTitle() { - return _m('Poll'); + // TRANS: Application title. + return _m('APPTITLE','Poll'); } } diff --git a/plugins/Poll/Poll_response.php b/plugins/Poll/Poll_response.php index 8543d1c245..a4ea999933 100644 --- a/plugins/Poll/Poll_response.php +++ b/plugins/Poll/Poll_response.php @@ -162,6 +162,7 @@ class Poll_response extends Managed_DataObject } if (!$poll->isValidSelection($selection)) { + // TRANS: Client exception thrown when responding to a poll with an invalid option. throw new ClientException(_m('Invalid poll selection.')); } $opts = $poll->getOptions(); @@ -189,11 +190,14 @@ class Poll_response extends Managed_DataObject common_log(LOG_DEBUG, "Saving poll response: $pr->id $pr->uri"); $pr->insert(); + // TRANS: Notice content voting for a poll. + // TRANS: %s is the chosen option in the poll. $content = sprintf(_m('voted for "%s"'), $answer); - $rendered = sprintf(_m('voted for “%s”'), - htmlspecialchars($poll->uri), - htmlspecialchars($answer)); + $link = '' . htmlspecialchars($answer) . ''; + // TRANS: Rendered version of the notice content voting for a poll. + // TRANS: %s a link to the poll with the chosen option as link description. + $rendered = sprintf(_m('voted for "%s"'), $link); $tags = array(); $replies = array(); diff --git a/plugins/Poll/newpoll.php b/plugins/Poll/newpoll.php index 0386f3e3b8..1048b0a1ed 100644 --- a/plugins/Poll/newpoll.php +++ b/plugins/Poll/newpoll.php @@ -59,6 +59,7 @@ class NewPollAction extends Action */ function title() { + // TRANS: Title for poll page. return _m('New poll'); } @@ -76,6 +77,7 @@ class NewPollAction extends Action $this->user = common_current_user(); if (empty($this->user)) { + // TRANS: Client exception thrown trying to create a poll while not logged in. throw new ClientException(_m('You must be logged in to post a poll.'), 403); } @@ -127,10 +129,12 @@ class NewPollAction extends Action } try { if (empty($this->question)) { + // TRANS: Client exception thrown trying to create a poll without a question. throw new ClientException(_m('Poll must have a question.')); } if (count($this->options) < 2) { + // TRANS: Client exception thrown trying to create a poll with fewer than two options. throw new ClientException(_m('Poll must have at least two options.')); } diff --git a/plugins/Poll/newpollform.php b/plugins/Poll/newpollform.php index d751ccd458..295619b1b9 100644 --- a/plugins/Poll/newpollform.php +++ b/plugins/Poll/newpollform.php @@ -103,8 +103,10 @@ class NewpollForm extends Form $this->li(); $this->out->input('question', + // TRANS: Field label on the page to create a poll. _m('Question'), $this->question, + // TRANS: Field title on the page to create a poll. _m('What question are people answering?')); $this->unli(); @@ -121,6 +123,8 @@ class NewpollForm extends Form } $this->li(); $this->out->input('option' . ($i + 1), + // TRANS: Field label for an answer option on the page to create a poll. + // TRANS: %d is the option number. sprintf(_m('Option %d'), $i + 1), $default); $this->unli(); @@ -137,6 +141,7 @@ class NewpollForm extends Form */ function formActions() { + // TRANS: Button text for saving a new poll. $this->out->submit('submit', _m('BUTTON', 'Save')); } } diff --git a/plugins/Poll/pollresponseform.php b/plugins/Poll/pollresponseform.php index a543906afb..ce1c31f6c2 100644 --- a/plugins/Poll/pollresponseform.php +++ b/plugins/Poll/pollresponseform.php @@ -123,6 +123,7 @@ class PollResponseForm extends Form */ function formActions() { + // TRANS: Button text for submitting a poll response. $this->out->submit('submit', _m('BUTTON', 'Submit')); } } diff --git a/plugins/Poll/respondpoll.php b/plugins/Poll/respondpoll.php index 0a6014699c..74629c3604 100644 --- a/plugins/Poll/respondpoll.php +++ b/plugins/Poll/respondpoll.php @@ -3,7 +3,7 @@ * StatusNet - the distributed open-source microblogging tool * Copyright (C) 2011, StatusNet, Inc. * - * Add a new Poll + * Respond to a Poll * * PHP version 5 * @@ -34,7 +34,7 @@ if (!defined('STATUSNET')) { } /** - * Add a new Poll + * Respond to a Poll * * @category Poll * @package StatusNet @@ -59,6 +59,7 @@ class RespondPollAction extends Action */ function title() { + // TRANS: Page title for poll response. return _m('Poll response'); } @@ -79,6 +80,7 @@ class RespondPollAction extends Action $this->user = common_current_user(); if (empty($this->user)) { + // TRANS: Client exception thrown trying to respond to a poll while not logged in. throw new ClientException(_m("You must be logged in to respond to a poll."), 403); } @@ -90,11 +92,13 @@ class RespondPollAction extends Action $id = $this->trimmed('id'); $this->poll = Poll::staticGet('id', $id); if (empty($this->poll)) { - throw new ClientException(_m("Invalid or missing poll."), 404); + // TRANS: Client exception thrown trying to respond to a non-existing poll. + throw new ClientException(_m('Invalid or missing poll.'), 404); } $selection = intval($this->trimmed('pollselection')); if ($selection < 1 || $selection > count($this->poll->getOptions())) { + // TRANS: Client exception thrown responding to a poll with an invalid answer. throw new ClientException(_m('Invalid poll selection.')); } $this->selection = $selection; diff --git a/plugins/Poll/showpoll.php b/plugins/Poll/showpoll.php index 60669f96ff..d95b1c512e 100644 --- a/plugins/Poll/showpoll.php +++ b/plugins/Poll/showpoll.php @@ -64,6 +64,7 @@ class ShowPollAction extends ShownoticeAction $this->poll = Poll::staticGet('id', $this->id); if (empty($this->poll)) { + // TRANS: Client exception thrown trying to view a non-existing poll. throw new ClientException(_m('No such poll.'), 404); } @@ -71,18 +72,21 @@ class ShowPollAction extends ShownoticeAction if (empty($this->notice)) { // Did we used to have it, and it got deleted? + // TRANS: Client exception thrown trying to view a non-existing poll notice. throw new ClientException(_m('No such poll notice.'), 404); } $this->user = User::staticGet('id', $this->poll->profile_id); if (empty($this->user)) { + // TRANS: Client exception thrown trying to view a poll of a non-existing user. throw new ClientException(_m('No such user.'), 404); } $this->profile = $this->user->getProfile(); if (empty($this->profile)) { + // TRANS: Server exception thrown trying to view a poll for a user for which the profile could not be loaded. throw new ServerException(_m('User without a profile.')); } @@ -100,7 +104,9 @@ class ShowPollAction extends ShownoticeAction */ function title() { - return sprintf(_m('%s\'s poll: %s'), + // TRANS: Page title for a poll. + // TRANS: %1$s is the nickname of the user that created the poll, %2$s is the poll question. + return sprintf(_m('%1$s\'s poll: %2$s'), $this->user->nickname, $this->poll->question); }