diff --git a/src/view/AphrontDialogView.php b/src/view/AphrontDialogView.php index 5b448678bb..686f97deb6 100644 --- a/src/view/AphrontDialogView.php +++ b/src/view/AphrontDialogView.php @@ -31,12 +31,20 @@ final class AphrontDialogView extends AphrontView { return $this->title; } - public function addSubmitButton($text = 'Okay') { + public function addSubmitButton($text = null) { + if (!$text) { + $text = pht('Okay'); + } + $this->submitButton = $text; return $this; } - public function addCancelButton($uri, $text = 'Cancel') { + public function addCancelButton($uri, $text = null) { + if (!$text) { + $text = pht('Cancel'); + } + $this->cancelURI = $uri; $this->cancelText = $text; return $this; @@ -102,7 +110,7 @@ final class AphrontDialogView extends AphrontView { if (!$this->user) { throw new Exception( - "You must call setUser() when rendering an AphrontDialogView."); + pht("You must call setUser() when rendering an AphrontDialogView.")); } $more = $this->class; diff --git a/src/view/AphrontTagView.php b/src/view/AphrontTagView.php index 514c8826f6..4db894f471 100644 --- a/src/view/AphrontTagView.php +++ b/src/view/AphrontTagView.php @@ -111,7 +111,8 @@ abstract class AphrontTagView extends AphrontView { if (!is_array($attributes)) { $class = get_class($this); 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; diff --git a/src/view/AphrontView.php b/src/view/AphrontView.php index 59c7a2172a..7edaf02d95 100644 --- a/src/view/AphrontView.php +++ b/src/view/AphrontView.php @@ -22,7 +22,7 @@ abstract class AphrontView extends Phobject { if (!$this->canAppendChild()) { $class = get_class($this); throw new Exception( - "View '{$class}' does not support children."); + pht("View '%s' does not support children.", $class)); } $this->children[] = $child; return $this; diff --git a/src/view/control/AphrontAttachedFileView.php b/src/view/control/AphrontAttachedFileView.php index 37668525ae..c889bcf7e5 100644 --- a/src/view/control/AphrontAttachedFileView.php +++ b/src/view/control/AphrontAttachedFileView.php @@ -30,7 +30,7 @@ final class AphrontAttachedFileView extends AphrontView { 'target' => '_blank', ), $file->getName()); - $size = number_format($file->getByteSize()).' bytes'; + $size = number_format($file->getByteSize()).' ' .pht('bytes'); $remove = javelin_tag( 'a', diff --git a/src/view/control/AphrontCursorPagerView.php b/src/view/control/AphrontCursorPagerView.php index ecfde94417..4b0d50d416 100644 --- a/src/view/control/AphrontCursorPagerView.php +++ b/src/view/control/AphrontCursorPagerView.php @@ -82,7 +82,7 @@ final class AphrontCursorPagerView extends AphrontView { public function render() { if (!$this->uri) { throw new Exception( - "You must call setURI() before you can call render()."); + pht("You must call setURI() before you can call render().")); } $links = array(); @@ -95,7 +95,7 @@ final class AphrontCursorPagerView extends AphrontView { ->alter('before', null) ->alter('after', null), ), - "\xC2\xAB First"); + "\xC2\xAB ". pht("First")); } if ($this->prevPageID) { @@ -106,7 +106,7 @@ final class AphrontCursorPagerView extends AphrontView { ->alter('after', null) ->alter('before', $this->prevPageID), ), - "\xE2\x80\xB9 Prev"); + "\xE2\x80\xB9 " . pht("Prev")); } if ($this->nextPageID) { diff --git a/src/view/control/AphrontPagerView.php b/src/view/control/AphrontPagerView.php index fe9340c0ae..352fe7a293 100644 --- a/src/view/control/AphrontPagerView.php +++ b/src/view/control/AphrontPagerView.php @@ -99,7 +99,7 @@ final class AphrontPagerView extends AphrontView { public function render() { if (!$this->uri) { 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'); @@ -140,11 +140,11 @@ final class AphrontPagerView extends AphrontView { $next_index = null; if ($min > 0) { - $links[] = array(0, 'First', null); + $links[] = array(0, pht('First'), null); } if ($page > 0) { - $links[] = array($page - 1, 'Prev', null); + $links[] = array($page - 1, pht('Prev'), null); $prev_index = $page - 1; } @@ -153,12 +153,12 @@ final class AphrontPagerView extends AphrontView { } if ($page < $last && $last > 0) { - $links[] = array($page + 1, 'Next', null); + $links[] = array($page + 1, pht('Next'), null); $next_index = $page + 1; } if ($max < ($last - 1)) { - $links[] = array($last, 'Last', null); + $links[] = array($last, pht('Last'), null); } $base_uri = $this->uri; diff --git a/src/view/control/AphrontTableView.php b/src/view/control/AphrontTableView.php index db3b12eb95..ede387b65a 100644 --- a/src/view/control/AphrontTableView.php +++ b/src/view/control/AphrontTableView.php @@ -275,7 +275,7 @@ final class AphrontTableView extends AphrontView { $table[] = hsprintf( '%s', $colspan, - coalesce($this->noDataString, 'No data available.')); + coalesce($this->noDataString, pht('No data available.'))); } $table_class = 'aphront-table-view'; diff --git a/src/view/form/AphrontFormView.php b/src/view/form/AphrontFormView.php index 5d5af2a430..95e3bd2b74 100644 --- a/src/view/form/AphrontFormView.php +++ b/src/view/form/AphrontFormView.php @@ -71,7 +71,7 @@ final class AphrontFormView extends AphrontView { ->appendChild($this->renderChildren()); 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; diff --git a/src/view/form/control/AphrontFormControl.php b/src/view/form/control/AphrontFormControl.php index 0e21457e29..864aabea2b 100644 --- a/src/view/form/control/AphrontFormControl.php +++ b/src/view/form/control/AphrontFormControl.php @@ -128,7 +128,7 @@ abstract class AphrontFormControl extends AphrontView { $error = phutil_tag( 'div', array('class' => 'aphront-form-error aphront-form-required'), - 'Required'); + pht('Required')); } else { $error = phutil_tag( 'div', diff --git a/src/view/form/control/AphrontFormDateControl.php b/src/view/form/control/AphrontFormDateControl.php index 61c470bccf..286b8eb24f 100644 --- a/src/view/form/control/AphrontFormDateControl.php +++ b/src/view/form/control/AphrontFormDateControl.php @@ -23,7 +23,7 @@ final class AphrontFormDateControl extends AphrontFormControl { $user = $this->user; if (!$this->user) { throw new Exception( - "Call setUser() before readValueFromRequest()!"); + pht("Call setUser() before readValueFromRequest()!")); } $user_zone = $user->getTimezoneIdentifier(); @@ -184,18 +184,18 @@ final class AphrontFormDateControl extends AphrontFormControl { $days = array_fuse($days); $months = array( - 1 => 'Jan', - 2 => 'Feb', - 3 => 'Mar', - 4 => 'Apr', - 5 => 'May', - 6 => 'Jun', - 7 => 'Jul', - 8 => 'Aug', - 9 => 'Sep', - 10 => 'Oct', - 11 => 'Nov', - 12 => 'Dec', + 1 => pht('Jan'), + 2 => pht('Feb'), + 3 => pht('Mar'), + 4 => pht('Apr'), + 5 => pht('May'), + 6 => pht('Jun'), + 7 => pht('Jul'), + 8 => pht('Aug'), + 9 => pht('Sep'), + 10 => pht('Oct'), + 11 => pht('Nov'), + 12 => pht('Dec'), ); $years = range($this->getMinYear(), $this->getMaxYear()); diff --git a/src/view/form/control/AphrontFormImageControl.php b/src/view/form/control/AphrontFormImageControl.php index 8e84d6fefc..28c6620037 100644 --- a/src/view/form/control/AphrontFormImageControl.php +++ b/src/view/form/control/AphrontFormImageControl.php @@ -30,7 +30,7 @@ final class AphrontFormImageControl extends AphrontFormControl { array( 'for' => $id, ), - 'Use Default Image instead')); + pht('Use Default Image instead'))); } } diff --git a/src/view/form/control/AphrontFormPolicyControl.php b/src/view/form/control/AphrontFormPolicyControl.php index fc59cba1c1..3db5be8d18 100644 --- a/src/view/form/control/AphrontFormPolicyControl.php +++ b/src/view/form/control/AphrontFormPolicyControl.php @@ -21,12 +21,12 @@ final class AphrontFormPolicyControl extends AphrontFormControl { $this->capability = $capability; $labels = array( - PhabricatorPolicyCapability::CAN_VIEW => 'Visible To', - PhabricatorPolicyCapability::CAN_EDIT => 'Editable By', - PhabricatorPolicyCapability::CAN_JOIN => 'Joinable By', + PhabricatorPolicyCapability::CAN_VIEW => pht('Visible To'), + PhabricatorPolicyCapability::CAN_EDIT => pht('Editable 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; } @@ -52,10 +52,10 @@ final class AphrontFormPolicyControl extends AphrontFormControl { protected function renderInput() { if (!$this->object) { - throw new Exception("Call setPolicyObject() before rendering!"); + throw new Exception(pht("Call setPolicyObject() before rendering!")); } if (!$this->capability) { - throw new Exception("Call setCapability() before rendering!"); + throw new Exception(pht("Call setCapability() before rendering!")); } $policy = $this->object->getPolicy($this->capability); diff --git a/src/view/form/control/AphrontFormSubmitControl.php b/src/view/form/control/AphrontFormSubmitControl.php index 17ccbefcab..3cb1f7fea6 100644 --- a/src/view/form/control/AphrontFormSubmitControl.php +++ b/src/view/form/control/AphrontFormSubmitControl.php @@ -4,7 +4,11 @@ final class AphrontFormSubmitControl extends AphrontFormControl { protected $cancelButton; - public function addCancelButton($href, $label = 'Cancel') { + public function addCancelButton($href, $label = null) { + if (!$label) { + $label = pht('Cancel'); + } + $this->cancelButton = phutil_tag( 'a', array( diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php index 3d82c2881b..35ef006475 100644 --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -81,17 +81,17 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $request = $matches[1]; $map = array( - 'users' => 'Type a user name...', - 'usersorprojects' => 'Type a user or project name...', - 'searchowner' => 'Type a user name...', - 'accounts' => 'Type a user name...', - 'mailable' => 'Type a user or mailing list...', - 'allmailable' => 'Type a user or mailing list...', - 'searchproject' => 'Type a project name...', - 'projects' => 'Type a project name...', - 'repositories' => 'Type a repository name...', - 'packages' => 'Type a package name...', - 'arcanistproject' => 'Type an arc project name...', + 'users' => pht('Type a user name...'), + 'usersorprojects' => pht('Type a user or project name...'), + 'searchowner' => pht('Type a user name...'), + 'accounts' => pht('Type a user name...'), + 'mailable' => pht('Type a user or mailing list...'), + 'allmailable' => pht('Type a user or mailing list...'), + 'searchproject' => pht('Type a project name...'), + 'projects' => pht('Type a project name...'), + 'repositories' => pht('Type a repository name...'), + 'packages' => pht('Type a package name...'), + 'arcanistproject' => pht('Type an arc project name...'), ); return idx($map, $request); diff --git a/src/view/layout/AphrontSideNavFilterView.php b/src/view/layout/AphrontSideNavFilterView.php index e4b2b7c9b9..2a38942edf 100644 --- a/src/view/layout/AphrontSideNavFilterView.php +++ b/src/view/layout/AphrontSideNavFilterView.php @@ -165,10 +165,10 @@ final class AphrontSideNavFilterView extends AphrontView { public function render() { if ($this->menu->getItems()) { if (!$this->baseURI) { - throw new Exception("Call setBaseURI() before render()!"); + throw new Exception(pht("Call setBaseURI() before render()!")); } if ($this->selectedFilter === false) { - throw new Exception("Call selectFilter() before render()!"); + throw new Exception(pht("Call selectFilter() before render()!")); } } diff --git a/src/view/layout/PhabricatorActionListView.php b/src/view/layout/PhabricatorActionListView.php index 3240a821ed..37c3252df9 100644 --- a/src/view/layout/PhabricatorActionListView.php +++ b/src/view/layout/PhabricatorActionListView.php @@ -17,7 +17,7 @@ final class PhabricatorActionListView extends AphrontView { public function render() { if (!$this->user) { - throw new Exception("Call setUser() before render()!"); + throw new Exception(pht("Call setUser() before render()!")); } $event = new PhabricatorEvent( diff --git a/src/view/layout/PhabricatorMenuView.php b/src/view/layout/PhabricatorMenuView.php index c350d00351..bd4c471fe7 100644 --- a/src/view/layout/PhabricatorMenuView.php +++ b/src/view/layout/PhabricatorMenuView.php @@ -59,7 +59,8 @@ final class PhabricatorMenuView extends AphrontTagView { } 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(); @@ -99,7 +100,7 @@ final class PhabricatorMenuView extends AphrontTagView { $other = $this->getItem($key); 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; @@ -122,7 +123,7 @@ final class PhabricatorMenuView extends AphrontTagView { private function requireKey($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 (isset($key_map[$key])) { throw new Exception( - "Menu contains duplicate items with key '{$key}'!"); + pht("Menu contains duplicate items with key '%s'!", $key)); } $key_map[$key] = $item; } diff --git a/src/view/layout/PhabricatorObjectItemView.php b/src/view/layout/PhabricatorObjectItemView.php index 2d52803738..e58f14b68c 100644 --- a/src/view/layout/PhabricatorObjectItemView.php +++ b/src/view/layout/PhabricatorObjectItemView.php @@ -169,7 +169,7 @@ final class PhabricatorObjectItemView extends AphrontView { case null: break; default: - throw new Exception("Invalid effect!"); + throw new Exception(pht("Invalid effect!")); } $content = phutil_tag( diff --git a/src/view/layout/PhabricatorPropertyListView.php b/src/view/layout/PhabricatorPropertyListView.php index 21018330f4..34c7cbea08 100644 --- a/src/view/layout/PhabricatorPropertyListView.php +++ b/src/view/layout/PhabricatorPropertyListView.php @@ -103,7 +103,7 @@ final class PhabricatorPropertyListView extends AphrontView { $items[] = $this->renderTextPart($part); break; default: - throw new Exception("Unknown part type '{$type}'!"); + throw new Exception(pht("Unknown part type '%s'!", $type)); } } diff --git a/src/view/layout/PhabricatorTagView.php b/src/view/layout/PhabricatorTagView.php index c28ba9cecd..0beec16a21 100644 --- a/src/view/layout/PhabricatorTagView.php +++ b/src/view/layout/PhabricatorTagView.php @@ -79,7 +79,7 @@ final class PhabricatorTagView extends AphrontView { public function render() { 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'); diff --git a/src/view/layout/PhabricatorTransactionView.php b/src/view/layout/PhabricatorTransactionView.php index 6233c570f1..a4906d6d54 100644 --- a/src/view/layout/PhabricatorTransactionView.php +++ b/src/view/layout/PhabricatorTransactionView.php @@ -49,7 +49,7 @@ final class PhabricatorTransactionView extends AphrontView { public function render() { 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'); diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php index 08b97981f8..1df3707a10 100644 --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -95,7 +95,8 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { if (!$this->getRequest()) { 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(); diff --git a/src/view/viewutils.php b/src/view/viewutils.php index ca2be6de9d..2616d08270 100644 --- a/src/view/viewutils.php +++ b/src/view/viewutils.php @@ -95,8 +95,8 @@ function phabricator_format_local_time($epoch, $user, $format) { // NOTE: DateTime throws an empty exception if the format is invalid, // just replace it with a useful one. throw new Exception( - "Construction of a DateTime() with epoch '{$epoch}' ". - "raised an exception."); + pht("Construction of a DateTime() with epoch '%s' ". + "raised an exception.", $epoch)); } $date->setTimeZone($zone);