1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 10:42:41 +01:00

pht() for view and form elements

Summary:
actually just wanted to `pht()` the //Cancel// button.

includes `pht()`ed exceptions.

refrained from `pht()`-ing `phabricator_relative_date()` since I wasn't too sure about the effects.

Test Plan: visited all form elements that I remembered - looks reasonable

Reviewers: epriestley, chad, btrahan

Reviewed By: chad

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5175
This commit is contained in:
Anh Nhan Nguyen 2013-03-01 15:37:32 -08:00 committed by epriestley
parent bedc06b1bc
commit 8e51764118
23 changed files with 78 additions and 63 deletions

View file

@ -31,12 +31,20 @@ final class AphrontDialogView extends AphrontView {
return $this->title; return $this->title;
} }
public function addSubmitButton($text = 'Okay') { public function addSubmitButton($text = null) {
if (!$text) {
$text = pht('Okay');
}
$this->submitButton = $text; $this->submitButton = $text;
return $this; return $this;
} }
public function addCancelButton($uri, $text = 'Cancel') { public function addCancelButton($uri, $text = null) {
if (!$text) {
$text = pht('Cancel');
}
$this->cancelURI = $uri; $this->cancelURI = $uri;
$this->cancelText = $text; $this->cancelText = $text;
return $this; return $this;
@ -102,7 +110,7 @@ final class AphrontDialogView extends AphrontView {
if (!$this->user) { if (!$this->user) {
throw new Exception( throw new Exception(
"You must call setUser() when rendering an AphrontDialogView."); pht("You must call setUser() when rendering an AphrontDialogView."));
} }
$more = $this->class; $more = $this->class;

View file

@ -111,7 +111,8 @@ abstract class AphrontTagView extends AphrontView {
if (!is_array($attributes)) { if (!is_array($attributes)) {
$class = get_class($this); $class = get_class($this);
throw new Exception( throw new Exception(
"View '{$class}' did not return an array from getTagAttributes()!"); pht("View '%s' did not return an array from getTagAttributes()!",
$class));
} }
$sigils = $this->sigils; $sigils = $this->sigils;

View file

@ -22,7 +22,7 @@ abstract class AphrontView extends Phobject {
if (!$this->canAppendChild()) { if (!$this->canAppendChild()) {
$class = get_class($this); $class = get_class($this);
throw new Exception( throw new Exception(
"View '{$class}' does not support children."); pht("View '%s' does not support children.", $class));
} }
$this->children[] = $child; $this->children[] = $child;
return $this; return $this;

View file

@ -30,7 +30,7 @@ final class AphrontAttachedFileView extends AphrontView {
'target' => '_blank', 'target' => '_blank',
), ),
$file->getName()); $file->getName());
$size = number_format($file->getByteSize()).' bytes'; $size = number_format($file->getByteSize()).' ' .pht('bytes');
$remove = javelin_tag( $remove = javelin_tag(
'a', 'a',

View file

@ -82,7 +82,7 @@ final class AphrontCursorPagerView extends AphrontView {
public function render() { public function render() {
if (!$this->uri) { if (!$this->uri) {
throw new Exception( throw new Exception(
"You must call setURI() before you can call render()."); pht("You must call setURI() before you can call render()."));
} }
$links = array(); $links = array();
@ -95,7 +95,7 @@ final class AphrontCursorPagerView extends AphrontView {
->alter('before', null) ->alter('before', null)
->alter('after', null), ->alter('after', null),
), ),
"\xC2\xAB First"); "\xC2\xAB ". pht("First"));
} }
if ($this->prevPageID) { if ($this->prevPageID) {
@ -106,7 +106,7 @@ final class AphrontCursorPagerView extends AphrontView {
->alter('after', null) ->alter('after', null)
->alter('before', $this->prevPageID), ->alter('before', $this->prevPageID),
), ),
"\xE2\x80\xB9 Prev"); "\xE2\x80\xB9 " . pht("Prev"));
} }
if ($this->nextPageID) { if ($this->nextPageID) {

View file

@ -99,7 +99,7 @@ final class AphrontPagerView extends AphrontView {
public function render() { public function render() {
if (!$this->uri) { if (!$this->uri) {
throw new Exception( throw new Exception(
"You must call setURI() before you can call render()."); pht("You must call setURI() before you can call render()."));
} }
require_celerity_resource('aphront-pager-view-css'); require_celerity_resource('aphront-pager-view-css');
@ -140,11 +140,11 @@ final class AphrontPagerView extends AphrontView {
$next_index = null; $next_index = null;
if ($min > 0) { if ($min > 0) {
$links[] = array(0, 'First', null); $links[] = array(0, pht('First'), null);
} }
if ($page > 0) { if ($page > 0) {
$links[] = array($page - 1, 'Prev', null); $links[] = array($page - 1, pht('Prev'), null);
$prev_index = $page - 1; $prev_index = $page - 1;
} }
@ -153,12 +153,12 @@ final class AphrontPagerView extends AphrontView {
} }
if ($page < $last && $last > 0) { if ($page < $last && $last > 0) {
$links[] = array($page + 1, 'Next', null); $links[] = array($page + 1, pht('Next'), null);
$next_index = $page + 1; $next_index = $page + 1;
} }
if ($max < ($last - 1)) { if ($max < ($last - 1)) {
$links[] = array($last, 'Last', null); $links[] = array($last, pht('Last'), null);
} }
$base_uri = $this->uri; $base_uri = $this->uri;

View file

@ -275,7 +275,7 @@ final class AphrontTableView extends AphrontView {
$table[] = hsprintf( $table[] = hsprintf(
'<tr class="no-data"><td colspan="%s">%s</td></tr>', '<tr class="no-data"><td colspan="%s">%s</td></tr>',
$colspan, $colspan,
coalesce($this->noDataString, 'No data available.')); coalesce($this->noDataString, pht('No data available.')));
} }
$table_class = 'aphront-table-view'; $table_class = 'aphront-table-view';

View file

@ -71,7 +71,7 @@ final class AphrontFormView extends AphrontView {
->appendChild($this->renderChildren()); ->appendChild($this->renderChildren());
if (!$this->user) { if (!$this->user) {
throw new Exception('You must pass the user to AphrontFormView.'); throw new Exception(pht('You must pass the user to AphrontFormView.'));
} }
$sigils = $this->sigils; $sigils = $this->sigils;

View file

@ -128,7 +128,7 @@ abstract class AphrontFormControl extends AphrontView {
$error = phutil_tag( $error = phutil_tag(
'div', 'div',
array('class' => 'aphront-form-error aphront-form-required'), array('class' => 'aphront-form-error aphront-form-required'),
'Required'); pht('Required'));
} else { } else {
$error = phutil_tag( $error = phutil_tag(
'div', 'div',

View file

@ -23,7 +23,7 @@ final class AphrontFormDateControl extends AphrontFormControl {
$user = $this->user; $user = $this->user;
if (!$this->user) { if (!$this->user) {
throw new Exception( throw new Exception(
"Call setUser() before readValueFromRequest()!"); pht("Call setUser() before readValueFromRequest()!"));
} }
$user_zone = $user->getTimezoneIdentifier(); $user_zone = $user->getTimezoneIdentifier();
@ -184,18 +184,18 @@ final class AphrontFormDateControl extends AphrontFormControl {
$days = array_fuse($days); $days = array_fuse($days);
$months = array( $months = array(
1 => 'Jan', 1 => pht('Jan'),
2 => 'Feb', 2 => pht('Feb'),
3 => 'Mar', 3 => pht('Mar'),
4 => 'Apr', 4 => pht('Apr'),
5 => 'May', 5 => pht('May'),
6 => 'Jun', 6 => pht('Jun'),
7 => 'Jul', 7 => pht('Jul'),
8 => 'Aug', 8 => pht('Aug'),
9 => 'Sep', 9 => pht('Sep'),
10 => 'Oct', 10 => pht('Oct'),
11 => 'Nov', 11 => pht('Nov'),
12 => 'Dec', 12 => pht('Dec'),
); );
$years = range($this->getMinYear(), $this->getMaxYear()); $years = range($this->getMinYear(), $this->getMaxYear());

View file

@ -30,7 +30,7 @@ final class AphrontFormImageControl extends AphrontFormControl {
array( array(
'for' => $id, 'for' => $id,
), ),
'Use Default Image instead')); pht('Use Default Image instead')));
} }
} }

View file

@ -21,12 +21,12 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
$this->capability = $capability; $this->capability = $capability;
$labels = array( $labels = array(
PhabricatorPolicyCapability::CAN_VIEW => 'Visible To', PhabricatorPolicyCapability::CAN_VIEW => pht('Visible To'),
PhabricatorPolicyCapability::CAN_EDIT => 'Editable By', PhabricatorPolicyCapability::CAN_EDIT => pht('Editable By'),
PhabricatorPolicyCapability::CAN_JOIN => 'Joinable By', PhabricatorPolicyCapability::CAN_JOIN => pht('Joinable By'),
); );
$this->setLabel(idx($labels, $this->capability, 'Unknown Policy')); $this->setLabel(idx($labels, $this->capability, pht('Unknown Policy')));
return $this; return $this;
} }
@ -52,10 +52,10 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
protected function renderInput() { protected function renderInput() {
if (!$this->object) { if (!$this->object) {
throw new Exception("Call setPolicyObject() before rendering!"); throw new Exception(pht("Call setPolicyObject() before rendering!"));
} }
if (!$this->capability) { if (!$this->capability) {
throw new Exception("Call setCapability() before rendering!"); throw new Exception(pht("Call setCapability() before rendering!"));
} }
$policy = $this->object->getPolicy($this->capability); $policy = $this->object->getPolicy($this->capability);

View file

@ -4,7 +4,11 @@ final class AphrontFormSubmitControl extends AphrontFormControl {
protected $cancelButton; protected $cancelButton;
public function addCancelButton($href, $label = 'Cancel') { public function addCancelButton($href, $label = null) {
if (!$label) {
$label = pht('Cancel');
}
$this->cancelButton = phutil_tag( $this->cancelButton = phutil_tag(
'a', 'a',
array( array(

View file

@ -81,17 +81,17 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
$request = $matches[1]; $request = $matches[1];
$map = array( $map = array(
'users' => 'Type a user name...', 'users' => pht('Type a user name...'),
'usersorprojects' => 'Type a user or project name...', 'usersorprojects' => pht('Type a user or project name...'),
'searchowner' => 'Type a user name...', 'searchowner' => pht('Type a user name...'),
'accounts' => 'Type a user name...', 'accounts' => pht('Type a user name...'),
'mailable' => 'Type a user or mailing list...', 'mailable' => pht('Type a user or mailing list...'),
'allmailable' => 'Type a user or mailing list...', 'allmailable' => pht('Type a user or mailing list...'),
'searchproject' => 'Type a project name...', 'searchproject' => pht('Type a project name...'),
'projects' => 'Type a project name...', 'projects' => pht('Type a project name...'),
'repositories' => 'Type a repository name...', 'repositories' => pht('Type a repository name...'),
'packages' => 'Type a package name...', 'packages' => pht('Type a package name...'),
'arcanistproject' => 'Type an arc project name...', 'arcanistproject' => pht('Type an arc project name...'),
); );
return idx($map, $request); return idx($map, $request);

View file

@ -165,10 +165,10 @@ final class AphrontSideNavFilterView extends AphrontView {
public function render() { public function render() {
if ($this->menu->getItems()) { if ($this->menu->getItems()) {
if (!$this->baseURI) { if (!$this->baseURI) {
throw new Exception("Call setBaseURI() before render()!"); throw new Exception(pht("Call setBaseURI() before render()!"));
} }
if ($this->selectedFilter === false) { if ($this->selectedFilter === false) {
throw new Exception("Call selectFilter() before render()!"); throw new Exception(pht("Call selectFilter() before render()!"));
} }
} }

View file

@ -17,7 +17,7 @@ final class PhabricatorActionListView extends AphrontView {
public function render() { public function render() {
if (!$this->user) { if (!$this->user) {
throw new Exception("Call setUser() before render()!"); throw new Exception(pht("Call setUser() before render()!"));
} }
$event = new PhabricatorEvent( $event = new PhabricatorEvent(

View file

@ -59,7 +59,8 @@ final class PhabricatorMenuView extends AphrontTagView {
} }
if (!$this->getItem($key)) { if (!$this->getItem($key)) {
throw new Exception("No such key '{$key}' to add menu item after!"); throw new Exception(pht("No such key '%s' to add menu item after!",
$key));
} }
$result = array(); $result = array();
@ -99,7 +100,7 @@ final class PhabricatorMenuView extends AphrontTagView {
$other = $this->getItem($key); $other = $this->getItem($key);
if ($other->getType() != PhabricatorMenuItemView::TYPE_LABEL) { if ($other->getType() != PhabricatorMenuItemView::TYPE_LABEL) {
throw new Exception("Menu item '{$key}' is not a label!"); throw new Exception(pht("Menu item '%s' is not a label!", $key));
} }
$seen = false; $seen = false;
@ -122,7 +123,7 @@ final class PhabricatorMenuView extends AphrontTagView {
private function requireKey($key) { private function requireKey($key) {
if (!$this->getItem($key)) { if (!$this->getItem($key)) {
throw new Exception("No menu item with key '{$key}' exists!"); throw new Exception(pht("No menu item with key '%s' exists!", $key));
} }
} }
@ -153,7 +154,7 @@ final class PhabricatorMenuView extends AphrontTagView {
if ($key !== null) { if ($key !== null) {
if (isset($key_map[$key])) { if (isset($key_map[$key])) {
throw new Exception( throw new Exception(
"Menu contains duplicate items with key '{$key}'!"); pht("Menu contains duplicate items with key '%s'!", $key));
} }
$key_map[$key] = $item; $key_map[$key] = $item;
} }

View file

@ -169,7 +169,7 @@ final class PhabricatorObjectItemView extends AphrontView {
case null: case null:
break; break;
default: default:
throw new Exception("Invalid effect!"); throw new Exception(pht("Invalid effect!"));
} }
$content = phutil_tag( $content = phutil_tag(

View file

@ -103,7 +103,7 @@ final class PhabricatorPropertyListView extends AphrontView {
$items[] = $this->renderTextPart($part); $items[] = $this->renderTextPart($part);
break; break;
default: default:
throw new Exception("Unknown part type '{$type}'!"); throw new Exception(pht("Unknown part type '%s'!", $type));
} }
} }

View file

@ -79,7 +79,7 @@ final class PhabricatorTagView extends AphrontView {
public function render() { public function render() {
if (!$this->type) { if (!$this->type) {
throw new Exception("You must call setType() before render()!"); throw new Exception(pht("You must call setType() before render()!"));
} }
require_celerity_resource('phabricator-tag-view-css'); require_celerity_resource('phabricator-tag-view-css');

View file

@ -49,7 +49,7 @@ final class PhabricatorTransactionView extends AphrontView {
public function render() { public function render() {
if (!$this->user) { if (!$this->user) {
throw new Exception("Call setUser() before render()!"); throw new Exception(pht("Call setUser() before render()!"));
} }
require_celerity_resource('phabricator-transaction-view-css'); require_celerity_resource('phabricator-transaction-view-css');

View file

@ -95,7 +95,8 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
if (!$this->getRequest()) { if (!$this->getRequest()) {
throw new Exception( throw new Exception(
"You must set the Request to render a PhabricatorStandardPageView."); pht(
"You must set the Request to render a PhabricatorStandardPageView."));
} }
$console = $this->getConsole(); $console = $this->getConsole();

View file

@ -95,8 +95,8 @@ function phabricator_format_local_time($epoch, $user, $format) {
// NOTE: DateTime throws an empty exception if the format is invalid, // NOTE: DateTime throws an empty exception if the format is invalid,
// just replace it with a useful one. // just replace it with a useful one.
throw new Exception( throw new Exception(
"Construction of a DateTime() with epoch '{$epoch}' ". pht("Construction of a DateTime() with epoch '%s' ".
"raised an exception."); "raised an exception.", $epoch));
} }
$date->setTimeZone($zone); $date->setTimeZone($zone);