1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

PHT's for Differential.

Summary:
Went through this last night, I had to remove some static vars, but didn't see that as a huge perf issue.

Lint

Test Plan: Tested numerous differential pages, creating a diff, commenting, editing.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4617
This commit is contained in:
Chad Little 2013-01-24 10:46:47 -08:00
parent 451ea2f958
commit 68affb72ec
13 changed files with 118 additions and 115 deletions

View file

@ -7,7 +7,7 @@ final class PhabricatorApplicationDifferential extends PhabricatorApplication {
}
public function getShortDescription() {
return 'Review Code';
return pht('Review Code');
}
public function getIconName() {

View file

@ -27,7 +27,7 @@ final class DifferentialAction {
self::ACTION_REJECT => 'requested changes to',
self::ACTION_RETHINK => 'planned changes to',
self::ACTION_ABANDON => 'abandoned',
self::ACTION_CLOSE => pht('closed'),
self::ACTION_CLOSE => 'closed',
self::ACTION_REQUEST => 'requested a review of',
self::ACTION_RECLAIM => 'reclaimed',
self::ACTION_UPDATE => 'updated',
@ -49,20 +49,20 @@ final class DifferentialAction {
}
public static function getActionVerb($action) {
static $verbs = array(
self::ACTION_COMMENT => 'Comment',
self::ACTION_ACCEPT => "Accept Revision \xE2\x9C\x94",
self::ACTION_REJECT => "Request Changes \xE2\x9C\x98",
self::ACTION_RETHINK => "Plan Changes \xE2\x9C\x98",
self::ACTION_ABANDON => 'Abandon Revision',
self::ACTION_REQUEST => 'Request Review',
self::ACTION_RECLAIM => 'Reclaim Revision',
self::ACTION_RESIGN => 'Resign as Reviewer',
self::ACTION_ADDREVIEWERS => 'Add Reviewers',
self::ACTION_ADDCCS => 'Add CCs',
self::ACTION_CLOSE => 'Close Revision',
self::ACTION_CLAIM => 'Commandeer Revision',
self::ACTION_REOPEN => 'Reopen',
$verbs = array(
self::ACTION_COMMENT => pht('Comment'),
self::ACTION_ACCEPT => pht("Accept Revision \xE2\x9C\x94"),
self::ACTION_REJECT => pht("Request Changes \xE2\x9C\x98"),
self::ACTION_RETHINK => pht("Plan Changes \xE2\x9C\x98"),
self::ACTION_ABANDON => pht('Abandon Revision'),
self::ACTION_REQUEST => pht('Request Review'),
self::ACTION_RECLAIM => pht('Reclaim Revision'),
self::ACTION_RESIGN => pht('Resign as Reviewer'),
self::ACTION_ADDREVIEWERS => pht('Add Reviewers'),
self::ACTION_ADDCCS => pht('Add CCs'),
self::ACTION_CLOSE => pht('Close Revision'),
self::ACTION_CLAIM => pht('Commandeer Revision'),
self::ACTION_REOPEN => pht('Reopen'),
);
if (!empty($verbs[$action])) {

View file

@ -93,17 +93,17 @@ final class DifferentialChangeType {
}
public static function getFullNameForChangeType($type) {
static $types = array(
self::TYPE_ADD => 'Added',
self::TYPE_CHANGE => 'Modified',
self::TYPE_DELETE => 'Deleted',
self::TYPE_MOVE_AWAY => 'Moved Away',
self::TYPE_COPY_AWAY => 'Copied Away',
self::TYPE_MOVE_HERE => 'Moved Here',
self::TYPE_COPY_HERE => 'Copied Here',
self::TYPE_MULTICOPY => 'Deleted After Multiple Copy',
self::TYPE_MESSAGE => 'Commit Message',
self::TYPE_CHILD => 'Contents Modified',
$types = array(
self::TYPE_ADD => pht('Added'),
self::TYPE_CHANGE => pht('Modified'),
self::TYPE_DELETE => pht('Deleted'),
self::TYPE_MOVE_AWAY => pht('Moved Away'),
self::TYPE_COPY_AWAY => pht('Copied Away'),
self::TYPE_MOVE_HERE => pht('Moved Here'),
self::TYPE_COPY_HERE => pht('Copied Here'),
self::TYPE_MULTICOPY => pht('Deleted After Multiple Copy'),
self::TYPE_MESSAGE => pht('Commit Message'),
self::TYPE_CHILD => pht('Contents Modified'),
);
return idx($types, coalesce($type, '?'), 'Unknown');
}

View file

@ -252,7 +252,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
$panel
),
array(
'title' => 'Changeset View',
'title' => pht('Changeset View'),
));
}

View file

@ -54,16 +54,16 @@ final class DifferentialCommentSaveController extends DifferentialController {
$dialog->addHiddenInput('ccs', $ccs);
$dialog->addHiddenInput('comment', $comment);
$dialog->setTitle('Action Has No Effect');
$dialog->setTitle(pht('Action Has No Effect'));
$dialog->appendChild(
'<p>'.phutil_escape_html($no_effect->getMessage()).'</p>');
if (strlen($comment) || $has_inlines) {
$dialog->addSubmitButton('Post as Comment');
$dialog->addSubmitButton(pht('Post as Comment'));
$dialog->appendChild('<br />');
$dialog->appendChild(
'<p>Do you want to post your feedback anyway, as a normal '.
'comment?</p>');
'<p>'.pht('Do you want to post your feedback anyway, as a normal '.
'comment?').'</p>');
}
return id(new AphrontDialogResponse())->setDialog($dialog);

View file

@ -13,7 +13,7 @@ abstract class DifferentialController extends PhabricatorController {
$viewer_is_anonymous = !$this->getRequest()->getUser()->isLoggedIn();
$page = $this->buildStandardPageView();
$page->setApplicationName('Differential');
$page->setApplicationName(pht('Differential'));
$page->setBaseURI('/differential/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9A\x99");
@ -31,7 +31,7 @@ abstract class DifferentialController extends PhabricatorController {
$crumbs->addAction(
id(new PhabricatorMenuItemView())
->setHref($this->getApplicationURI('/diff/create/'))
->setName('Create Diff')
->setName(pht('Create Diff'))
->setIcon('create'));
return $crumbs;

View file

@ -42,33 +42,33 @@ final class DifferentialDiffCreateController extends DifferentialController {
->setEncType('multipart/form-data')
->setUser($request->getUser())
->appendChild(
'<p class="aphront-form-instructions">The best way to create a '.
"Differential diff is by using $arcanist_link, but you ".
'<p class="aphront-form-instructions">'.pht('The best way to create '.
'a Differential diff is by using %s, but you '.
'can also just paste a diff (e.g., from <tt>svn diff</tt> or '.
'<tt>git diff</tt>) into this box or upload it as a file if you '.
'really want.</p>')
'really want.', $arcanist_link).'</p>')
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Raw Diff')
->setLabel(pht('Raw Diff'))
->setName('diff')
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
->appendChild(
id(new AphrontFormFileControl())
->setLabel('Raw Diff from file')
->setLabel(pht('Raw Diff from file'))
->setName('diff-file'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue("Create Diff \xC2\xBB"));
->setValue(pht("Create Diff \xC2\xBB")));
$panel = new AphrontPanelView();
$panel->setHeader('Create New Diff');
$panel->setHeader(pht('Create New Diff'));
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Create Diff',
'title' => pht('Create Diff'),
));
}

View file

@ -25,20 +25,23 @@ final class DifferentialDiffViewController extends DifferentialController {
'href' => PhabricatorEnv::getURI('/D'.$diff->getRevisionID()),
),
phutil_escape_html('D'.$diff->getRevisionID()));
$top_panel->appendChild("<h1>This diff belongs to revision {$link}</h1>");
$top_panel->appendChild(
"<h1>".pht('This diff belongs to revision %s', $link)."</h1>");
} else {
$action_panel = new AphrontPanelView();
$action_panel->setHeader('Preview Diff');
$action_panel->setWidth(AphrontPanelView::WIDTH_WIDE);
$action_panel->appendChild(
'<p class="aphront-panel-instructions">Review the diff for '.
'<p class="aphront-panel-instructions">'.pht('Review the diff for '.
'correctness. When you are satisfied, either <strong>create a new '.
'revision</strong> or <strong>update an existing revision</strong>.');
'revision</strong> or <strong>update an existing revision</strong>.'));
// TODO: implmenent optgroup support in AphrontFormSelectControl?
$select = array();
$select[] = '<optgroup label="Create New Revision">';
$select[] = '<option value="">Create a new Revision...</option>';
$select[] = '<option value="">'.
pht('Create a new Revision...').
'</option>';
$select[] = '</optgroup>';
$revision_data = new DifferentialRevisionListData(
@ -47,7 +50,7 @@ final class DifferentialDiffViewController extends DifferentialController {
$revisions = $revision_data->loadRevisions();
if ($revisions) {
$select[] = '<optgroup label="Update Existing Revision">';
$select[] = '<optgroup label="'.pht('Update Existing Revision').'">';
foreach ($revisions as $revision) {
$select[] = phutil_render_tag(
'option',
@ -72,11 +75,11 @@ final class DifferentialDiffViewController extends DifferentialController {
->addHiddenInput('viaDiffView', 1)
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel('Attach To')
->setLabel(pht('Attach To'))
->setValue($select))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Continue'));
->setValue(pht('Continue')));
$action_panel->appendChild($action_form);
@ -133,7 +136,7 @@ final class DifferentialDiffViewController extends DifferentialController {
->setRenderingReferences($refs)
->setStandaloneURI('/differential/changeset/')
->setDiff($diff)
->setTitle('Diff '.$diff->getID())
->setTitle(pht('Diff %d', $diff->getID()))
->setUser($request->getUser());
return $this->buildStandardPageResponse(
@ -146,7 +149,7 @@ final class DifferentialDiffViewController extends DifferentialController {
$details->render(),
)),
array(
'title' => 'Diff View',
'title' => pht('Diff View'),
));
}

View file

@ -95,7 +95,7 @@ final class DifferentialRevisionEditController extends DifferentialController {
$error_view = null;
if ($errors) {
$error_view = id(new AphrontErrorView())
->setTitle('Form Errors')
->setTitle(pht('Form Errors'))
->setErrors($errors);
}
@ -103,13 +103,13 @@ final class DifferentialRevisionEditController extends DifferentialController {
$form
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Comments')
->setLabel(pht('Comments'))
->setName('comments')
->setCaption("Explain what's new in this diff.")
->setCaption(pht("Explain what's new in this diff."))
->setValue($request->getStr('comments')))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save'))
->setValue(pht('Save')))
->appendChild(
id(new AphrontFormDividerControl()));
}
@ -134,21 +134,22 @@ final class DifferentialRevisionEditController extends DifferentialController {
$panel = new AphrontPanelView();
if ($revision->getID()) {
if ($diff) {
$panel->setHeader('Update Differential Revision');
$panel->setHeader(pht('Update Differential Revision'));
} else {
$panel->setHeader('Edit Differential Revision');
$panel->setHeader(pht('Edit Differential Revision'));
}
} else {
$panel->setHeader('Create New Differential Revision');
$panel->setHeader(pht('Create New Differential Revision'));
}
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$panel->setNoBackground();
return $this->buildStandardPageResponse(
array($error_view, $panel),
array(
'title' => 'Edit Differential Revision',
'title' => pht('Edit Differential Revision'),
));
}

View file

@ -101,9 +101,9 @@ final class DifferentialRevisionListController extends DifferentialController {
// the viewing user's). Show a warning instead.
$warning = new AphrontErrorView();
$warning->setSeverity(AphrontErrorView::SEVERITY_WARNING);
$warning->setTitle('User Required');
$warning->setTitle(pht('User Required'));
$warning->appendChild(
'This filter requires that a user be specified above.');
pht('This filter requires that a user be specified above.'));
$panels[] = $warning;
} else {
$query = $this->buildQuery($this->filter, $params);
@ -173,7 +173,7 @@ final class DifferentialRevisionListController extends DifferentialController {
->addHiddenInput('order', $params['order'])
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Filter Revisions'));
->setValue(pht('Filter Revisions')));
$filter_view = new AphrontListFilterView();
$filter_view->appendChild($filter_form);
@ -198,20 +198,20 @@ final class DifferentialRevisionListController extends DifferentialController {
return $this->buildApplicationPage(
$side_nav,
array(
'title' => 'Differential Home',
'title' => pht('Differential Home'),
));
}
private function getFilters() {
return array(
array(null, 'User Revisions'),
array('active', 'Active'),
array('revisions', 'Revisions'),
array('reviews', 'Reviews'),
array('subscribed', 'Subscribed'),
array('drafts', 'Draft Reviews'),
array(null, 'All Revisions'),
array('all', 'All'),
array(null, pht('User Revisions')),
array('active', pht('Active')),
array('revisions', pht('Revisions')),
array('reviews', pht('Reviews')),
array('subscribed', pht('Subscribed')),
array('drafts', pht('Draft Reviews')),
array(null, pht('All Revisions')),
array('all', pht('All')),
);
}
@ -328,18 +328,18 @@ final class DifferentialRevisionListController extends DifferentialController {
if ($control == 'subscriber') {
$source = '/typeahead/common/allmailable/';
$label = 'View Subscribers';
$label = pht('View Subscribers');
} else {
$source = '/typeahead/common/accounts/';
switch ($this->filter) {
case 'revisions':
$label = 'Authors';
$label = pht('Authors');
break;
case 'reviews':
$label = 'Reviewers';
$label = pht('Reviewers');
break;
default:
$label = 'View Users';
$label = pht('View Users');
break;
}
}
@ -353,10 +353,10 @@ final class DifferentialRevisionListController extends DifferentialController {
case 'participants':
switch ($this->filter) {
case 'revisions':
$label = 'Reviewers';
$label = pht('Reviewers');
break;
case 'reviews':
$label = 'Authors';
$label = pht('Authors');
break;
}
$value = mpull(
@ -370,26 +370,26 @@ final class DifferentialRevisionListController extends DifferentialController {
case 'status':
return id(new AphrontFormToggleButtonsControl())
->setLabel('Status')
->setLabel(pht('Status'))
->setValue($params['status'])
->setBaseURI($uri, 'status')
->setButtons(
array(
'all' => 'All',
'open' => 'Open',
'all' => pht('All'),
'open' => pht('Open'),
'closed' => pht('Closed'),
'abandoned' => 'Abandoned',
'abandoned' => pht('Abandoned'),
));
case 'order':
return id(new AphrontFormToggleButtonsControl())
->setLabel('Order')
->setLabel(pht('Order'))
->setValue($params['order'])
->setBaseURI($uri, 'order')
->setButtons(
array(
'modified' => 'Updated',
'created' => 'Created',
'modified' => pht('Updated'),
'created' => pht('Created'),
));
default:
@ -444,7 +444,7 @@ final class DifferentialRevisionListController extends DifferentialController {
->setRevisions($active)
->loadAssets();
$views[] = array(
'title' => 'Action Required',
'title' => pht('Action Required'),
'view' => $view,
);
@ -463,7 +463,7 @@ final class DifferentialRevisionListController extends DifferentialController {
->setUser($user);
$views[] = array(
'title' => 'Flagged Revisions',
'title' => pht('Flagged Revisions'),
'view' => $view,
'special' => true,
);
@ -474,7 +474,7 @@ final class DifferentialRevisionListController extends DifferentialController {
->setRevisions($waiting)
->loadAssets();
$views[] = array(
'title' => 'Waiting On Others',
'title' => pht('Waiting On Others'),
'view' => $view,
);
break;
@ -484,10 +484,10 @@ final class DifferentialRevisionListController extends DifferentialController {
case 'drafts':
case 'all':
$titles = array(
'revisions' => 'Revisions by Author',
'reviews' => 'Revisions by Reviewer',
'subscribed' => 'Revisions by Subscriber',
'all' => 'Revisions',
'revisions' => pht('Revisions by Author'),
'reviews' => pht('Revisions by Reviewer'),
'subscribed' => pht('Revisions by Subscriber'),
'all' => pht('Revisions'),
);
$view = id(clone $template)
->setRevisions($revisions)
@ -504,5 +504,4 @@ final class DifferentialRevisionListController extends DifferentialController {
return $views;
}
}

View file

@ -118,7 +118,7 @@ final class DifferentialRevisionStatsController extends DifferentialController {
$filter_form->appendChild(
$this->renderControl($params['phid'], $handles));
$filter_form->appendChild(id(new AphrontFormSubmitControl())
->setValue('Filter Revisions'));
->setValue(pht('Filter Revisions')));
$side_nav->appendChild($filter_form);
@ -127,7 +127,7 @@ final class DifferentialRevisionStatsController extends DifferentialController {
$diffs = $this->loadDiffs($revisions);
$panel = new AphrontPanelView();
$panel->setHeader('Differential rate analysis');
$panel->setHeader(pht('Differential rate analysis'));
$panel->appendChild(
id(new DifferentialRevisionStatsView())
->setComments($comments)
@ -144,7 +144,7 @@ final class DifferentialRevisionStatsController extends DifferentialController {
return $this->buildStandardPageResponse(
$side_nav,
array(
'title' => 'Differential statistics',
'title' => pht('Differential Statistics'),
));
}
@ -157,7 +157,7 @@ final class DifferentialRevisionStatsController extends DifferentialController {
}
return id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/users/')
->setLabel('View User')
->setLabel(pht('View User'))
->setName('view_user')
->setValue($value)
->setLimit(1);

View file

@ -150,7 +150,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
if (!$has_live_reviewer) {
$reviewer_warning = new AphrontErrorView();
$reviewer_warning->setSeverity(AphrontErrorView::SEVERITY_WARNING);
$reviewer_warning->setTitle('No Active Reviewers');
$reviewer_warning->setTitle(pht('No Active Reviewers'));
if ($revision->getReviewers()) {
$reviewer_warning->appendChild(
phutil_render_tag(
@ -181,8 +181,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
$warning->setTitle('Very Large Diff');
$warning->setSeverity(AphrontErrorView::SEVERITY_WARNING);
$warning->appendChild(
"<p>This diff is very large and affects {$count} files. Load ".
"each file individually. ".
'<p>'.pht('This diff is very large and affects %d files. Load '.
'each file individually. ', $count).
"<strong>".
phutil_render_tag(
'a',
@ -191,7 +191,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
->alter('large', 'true')
->setFragment('toc'),
),
'Show All Files Inline').
pht('Show All Files Inline')).
"</strong>");
$warning = $warning->render();
@ -483,7 +483,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$links[] = array(
'icon' => 'edit',
'href' => "/differential/revision/edit/{$revision_id}/",
'name' => 'Edit Revision',
'name' => pht('Edit Revision'),
);
}
@ -494,14 +494,14 @@ final class DifferentialRevisionViewController extends DifferentialController {
$links[] = array(
'icon' => $viewer_is_cc ? 'subscribe-delete' : 'subscribe-add',
'href' => "/differential/subscribe/{$action}/{$revision_id}/",
'name' => $viewer_is_cc ? 'Unsubscribe' : 'Subscribe',
'name' => $viewer_is_cc ? pht('Unsubscribe') : pht('Subscribe'),
'instant' => true,
'sigil' => 'workflow',
);
} else {
$links[] = array(
'icon' => 'subscribe-auto',
'name' => 'Automatically Subscribed',
'name' => pht('Automatically Subscribed'),
'disabled' => true,
);
}
@ -511,7 +511,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$links[] = array(
'icon' => 'link',
'name' => 'Edit Dependencies',
'name' => pht('Edit Dependencies'),
'href' => "/search/attach/{$revision_phid}/DREV/dependencies/",
'sigil' => 'workflow',
);
@ -519,7 +519,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
if (PhabricatorEnv::getEnvConfig('maniphest.enabled')) {
$links[] = array(
'icon' => 'attach',
'name' => 'Edit Maniphest Tasks',
'name' => pht('Edit Maniphest Tasks'),
'href' => "/search/attach/{$revision_phid}/TASK/",
'sigil' => 'workflow',
);
@ -528,14 +528,14 @@ final class DifferentialRevisionViewController extends DifferentialController {
if ($user->getIsAdmin()) {
$links[] = array(
'icon' => 'file',
'name' => 'MetaMTA Transcripts',
'name' => pht('MetaMTA Transcripts'),
'href' => "/mail/?phid={$revision_phid}",
);
}
$links[] = array(
'icon' => 'file',
'name' => 'Herald Transcripts',
'name' => pht('Herald Transcripts'),
'href' => "/herald/transcript/?phid={$revision_phid}",
);
}
@ -543,7 +543,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$request_uri = $this->getRequest()->getRequestURI();
$links[] = array(
'icon' => 'download',
'name' => 'Download Raw Diff',
'name' => pht('Download Raw Diff'),
'href' => $request_uri->alter('download', 'true')
);

View file

@ -25,16 +25,16 @@ final class DifferentialSubscribeController extends DifferentialController {
switch ($this->action) {
case 'add':
$button = 'Subscribe';
$title = 'Subscribe to Revision';
$prompt = 'Really subscribe to this revision?';
$button = pht('Subscribe');
$title = pht('Subscribe to Revision');
$prompt = pht('Really subscribe to this revision?');
break;
case 'rem':
$button = 'Unsubscribe';
$title = 'Unsubscribe from Revision';
$prompt = 'Really unsubscribe from this revision? Herald will '.
$button = pht('Unsubscribe');
$title = pht('Unsubscribe from Revision');
$prompt = pht('Really unsubscribe from this revision? Herald will '.
'not resubscribe you to a revision you unsubscribe '.
'from.';
'from.');
break;
default:
return new Aphront400Response();