i18n/L10n updates

Translator documentation added
This commit is contained in:
Siebrand Mazeland 2011-03-11 19:05:28 +01:00
parent a70914cd57
commit 843ace580d
8 changed files with 52 additions and 17 deletions

View File

@ -235,12 +235,15 @@ class Poll extends Managed_DataObject
common_log(LOG_DEBUG, "Saving poll: $p->id $p->uri"); common_log(LOG_DEBUG, "Saving poll: $p->id $p->uri");
$p->insert(); $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, $question,
$p->uri); $p->uri);
$rendered = sprintf(_m('Poll: <a href="%s">%s</a>'), $link = '<a href="' . htmlspecialchars($p->uri) . '">' . htmlspecialchars($question) . '</a>';
htmlspecialchars($p->uri), // TRANS: Rendered version of the notice content creating a poll.
htmlspecialchars($question)); // TRANS: %s a link to the poll with the question as link description.
$rendered = sprintf(_m('Poll: %s'), $link);
$tags = array('poll'); $tags = array('poll');
$replies = array(); $replies = array();

View File

@ -153,6 +153,7 @@ class PollPlugin extends MicroAppPlugin
'author' => 'Brion Vibber', 'author' => 'Brion Vibber',
'homepage' => 'http://status.net/wiki/Plugin:Poll', 'homepage' => 'http://status.net/wiki/Plugin:Poll',
'rawdescription' => 'rawdescription' =>
// TRANS: Plugin description.
_m('Simple extension for supporting basic polls.')); _m('Simple extension for supporting basic polls.'));
return true; return true;
} }
@ -229,11 +230,13 @@ class PollPlugin extends MicroAppPlugin
$selection = intval($data->getAttribute('selection')); $selection = intval($data->getAttribute('selection'));
if (!$pollUri) { 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); $poll = Poll::staticGet('uri', $pollUri);
if (!$poll) { 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 { try {
$notice = Poll_response::saveNew($profile, $poll, $selection, $options); $notice = Poll_response::saveNew($profile, $poll, $selection, $options);
@ -258,7 +261,9 @@ class PollPlugin extends MicroAppPlugin
case self::POLL_RESPONSE_OBJECT: case self::POLL_RESPONSE_OBJECT:
return $this->activityObjectFromNoticePollResponse($notice); return $this->activityObjectFromNoticePollResponse($notice);
default: 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: case self::POLL_RESPONSE_OBJECT:
return $this->showNoticePollResponse($notice, $out); return $this->showNoticePollResponse($notice, $out);
default: 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(); $form->show();
} }
} else { } else {
$out->text('Poll data is missing'); $out->text(_('Poll data is missing'));
} }
$out->elementEnd('div'); $out->elementEnd('div');
@ -421,6 +428,7 @@ class PollPlugin extends MicroAppPlugin
function appTitle() function appTitle()
{ {
return _m('Poll'); // TRANS: Application title.
return _m('APPTITLE','Poll');
} }
} }

View File

@ -162,6 +162,7 @@ class Poll_response extends Managed_DataObject
} }
if (!$poll->isValidSelection($selection)) { if (!$poll->isValidSelection($selection)) {
// TRANS: Client exception thrown when responding to a poll with an invalid option.
throw new ClientException(_m('Invalid poll selection.')); throw new ClientException(_m('Invalid poll selection.'));
} }
$opts = $poll->getOptions(); $opts = $poll->getOptions();
@ -189,11 +190,14 @@ class Poll_response extends Managed_DataObject
common_log(LOG_DEBUG, "Saving poll response: $pr->id $pr->uri"); common_log(LOG_DEBUG, "Saving poll response: $pr->id $pr->uri");
$pr->insert(); $pr->insert();
// TRANS: Notice content voting for a poll.
// TRANS: %s is the chosen option in the poll.
$content = sprintf(_m('voted for "%s"'), $content = sprintf(_m('voted for "%s"'),
$answer); $answer);
$rendered = sprintf(_m('voted for “<a href="%s">%s</a>”'), $link = '<a href="' . htmlspecialchars($poll->uri) . '">' . htmlspecialchars($answer) . '</a>';
htmlspecialchars($poll->uri), // TRANS: Rendered version of the notice content voting for a poll.
htmlspecialchars($answer)); // TRANS: %s a link to the poll with the chosen option as link description.
$rendered = sprintf(_m('voted for "%s"'), $link);
$tags = array(); $tags = array();
$replies = array(); $replies = array();

View File

@ -59,6 +59,7 @@ class NewPollAction extends Action
*/ */
function title() function title()
{ {
// TRANS: Title for poll page.
return _m('New poll'); return _m('New poll');
} }
@ -76,6 +77,7 @@ class NewPollAction extends Action
$this->user = common_current_user(); $this->user = common_current_user();
if (empty($this->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.'), throw new ClientException(_m('You must be logged in to post a poll.'),
403); 403);
} }
@ -127,10 +129,12 @@ class NewPollAction extends Action
} }
try { try {
if (empty($this->question)) { 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.')); throw new ClientException(_m('Poll must have a question.'));
} }
if (count($this->options) < 2) { 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.')); throw new ClientException(_m('Poll must have at least two options.'));
} }

View File

@ -103,8 +103,10 @@ class NewpollForm extends Form
$this->li(); $this->li();
$this->out->input('question', $this->out->input('question',
// TRANS: Field label on the page to create a poll.
_m('Question'), _m('Question'),
$this->question, $this->question,
// TRANS: Field title on the page to create a poll.
_m('What question are people answering?')); _m('What question are people answering?'));
$this->unli(); $this->unli();
@ -121,6 +123,8 @@ class NewpollForm extends Form
} }
$this->li(); $this->li();
$this->out->input('option' . ($i + 1), $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), sprintf(_m('Option %d'), $i + 1),
$default); $default);
$this->unli(); $this->unli();
@ -137,6 +141,7 @@ class NewpollForm extends Form
*/ */
function formActions() function formActions()
{ {
// TRANS: Button text for saving a new poll.
$this->out->submit('submit', _m('BUTTON', 'Save')); $this->out->submit('submit', _m('BUTTON', 'Save'));
} }
} }

View File

@ -123,6 +123,7 @@ class PollResponseForm extends Form
*/ */
function formActions() function formActions()
{ {
// TRANS: Button text for submitting a poll response.
$this->out->submit('submit', _m('BUTTON', 'Submit')); $this->out->submit('submit', _m('BUTTON', 'Submit'));
} }
} }

View File

@ -3,7 +3,7 @@
* StatusNet - the distributed open-source microblogging tool * StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2011, StatusNet, Inc. * Copyright (C) 2011, StatusNet, Inc.
* *
* Add a new Poll * Respond to a Poll
* *
* PHP version 5 * PHP version 5
* *
@ -34,7 +34,7 @@ if (!defined('STATUSNET')) {
} }
/** /**
* Add a new Poll * Respond to a Poll
* *
* @category Poll * @category Poll
* @package StatusNet * @package StatusNet
@ -59,6 +59,7 @@ class RespondPollAction extends Action
*/ */
function title() function title()
{ {
// TRANS: Page title for poll response.
return _m('Poll response'); return _m('Poll response');
} }
@ -79,6 +80,7 @@ class RespondPollAction extends Action
$this->user = common_current_user(); $this->user = common_current_user();
if (empty($this->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."), throw new ClientException(_m("You must be logged in to respond to a poll."),
403); 403);
} }
@ -90,11 +92,13 @@ class RespondPollAction extends Action
$id = $this->trimmed('id'); $id = $this->trimmed('id');
$this->poll = Poll::staticGet('id', $id); $this->poll = Poll::staticGet('id', $id);
if (empty($this->poll)) { 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')); $selection = intval($this->trimmed('pollselection'));
if ($selection < 1 || $selection > count($this->poll->getOptions())) { 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.')); throw new ClientException(_m('Invalid poll selection.'));
} }
$this->selection = $selection; $this->selection = $selection;

View File

@ -64,6 +64,7 @@ class ShowPollAction extends ShownoticeAction
$this->poll = Poll::staticGet('id', $this->id); $this->poll = Poll::staticGet('id', $this->id);
if (empty($this->poll)) { if (empty($this->poll)) {
// TRANS: Client exception thrown trying to view a non-existing poll.
throw new ClientException(_m('No such poll.'), 404); throw new ClientException(_m('No such poll.'), 404);
} }
@ -71,18 +72,21 @@ class ShowPollAction extends ShownoticeAction
if (empty($this->notice)) { if (empty($this->notice)) {
// Did we used to have it, and it got deleted? // 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); throw new ClientException(_m('No such poll notice.'), 404);
} }
$this->user = User::staticGet('id', $this->poll->profile_id); $this->user = User::staticGet('id', $this->poll->profile_id);
if (empty($this->user)) { 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); throw new ClientException(_m('No such user.'), 404);
} }
$this->profile = $this->user->getProfile(); $this->profile = $this->user->getProfile();
if (empty($this->profile)) { 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.')); throw new ServerException(_m('User without a profile.'));
} }
@ -100,7 +104,9 @@ class ShowPollAction extends ShownoticeAction
*/ */
function title() 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->user->nickname,
$this->poll->question); $this->poll->question);
} }