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: <a href="%s">%s</a>'),
- htmlspecialchars($p->uri),
- htmlspecialchars($question));
+ $link = '<a href="' . htmlspecialchars($p->uri) . '">' . htmlspecialchars($question) . '</a>';
+ // 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();
'author' => 'Brion Vibber',
'homepage' => 'http://status.net/wiki/Plugin:Poll',
'rawdescription' =>
+ // TRANS: Plugin description.
_m('Simple extension for supporting basic polls.'));
return true;
}
$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);
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));
}
}
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));
}
}
$form->show();
}
} else {
- $out->text('Poll data is missing');
+ $out->text(_('Poll data is missing'));
}
$out->elementEnd('div');
function appTitle()
{
- return _m('Poll');
+ // TRANS: Application title.
+ return _m('APPTITLE','Poll');
}
}
}
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();
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 “<a href="%s">%s</a>”'),
- htmlspecialchars($poll->uri),
- htmlspecialchars($answer));
+ $link = '<a href="' . htmlspecialchars($poll->uri) . '">' . htmlspecialchars($answer) . '</a>';
+ // 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();
*/
function title()
{
+ // TRANS: Title for poll page.
return _m('New poll');
}
$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);
}
}
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.'));
}
$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();
}
$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();
*/
function formActions()
{
+ // TRANS: Button text for saving a new poll.
$this->out->submit('submit', _m('BUTTON', 'Save'));
}
}
*/
function formActions()
{
+ // TRANS: Button text for submitting a poll response.
$this->out->submit('submit', _m('BUTTON', 'Submit'));
}
}
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc.
*
- * Add a new Poll
+ * Respond to a Poll
*
* PHP version 5
*
}
/**
- * Add a new Poll
+ * Respond to a Poll
*
* @category Poll
* @package StatusNet
*/
function title()
{
+ // TRANS: Page title for poll response.
return _m('Poll response');
}
$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);
}
$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;
$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);
}
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.'));
}
*/
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);
}