1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Translate Differential Feed/Comment/Asana stories

Summary: I don't think this is too terrible, and makes the future easier? Maybe?

Test Plan: ALLCAPS translation, Viewed a diff, feed, and notifications.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Differential Revision: https://secure.phabricator.com/D8175
This commit is contained in:
Chad Little 2014-02-09 10:07:29 -08:00
parent dfd53fb008
commit ee44c6db53
3 changed files with 301 additions and 30 deletions

View file

@ -20,6 +20,84 @@ final class DifferentialAction {
const ACTION_CLAIM = 'claim'; const ACTION_CLAIM = 'claim';
const ACTION_REOPEN = 'reopen'; const ACTION_REOPEN = 'reopen';
public static function getBasicStoryText($action, $author_name) {
switch ($action) {
case DifferentialAction::ACTION_COMMENT:
$title = pht('%s commented on this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ACCEPT:
$title = pht('%s accepted this revision.',
$author_name);
break;
case DifferentialAction::ACTION_REJECT:
$title = pht('%s requested changes to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_RETHINK:
$title = pht('%s planned changes to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ABANDON:
$title = pht('%s abandoned this revision.',
$author_name);
break;
case DifferentialAction::ACTION_CLOSE:
$title = pht('%s closed this revision.',
$author_name);
break;
case DifferentialAction::ACTION_REQUEST:
$title = pht('%s requested a review of this revision.',
$author_name);
break;
case DifferentialAction::ACTION_RECLAIM:
$title = pht('%s reclaimed this revision.',
$author_name);
break;
case DifferentialAction::ACTION_UPDATE:
$title = pht('%s updated this revision.',
$author_name);
break;
case DifferentialAction::ACTION_RESIGN:
$title = pht('%s resigned from this revision.',
$author_name);
break;
case DifferentialAction::ACTION_SUMMARIZE:
$title = pht('%s summarized this revision.',
$author_name);
break;
case DifferentialAction::ACTION_TESTPLAN:
$title = pht('%s explained the test plan for this revision.',
$author_name);
break;
case DifferentialAction::ACTION_CREATE:
$title = pht('%s created this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$title = pht('%s added reviewers to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_ADDCCS:
$title = pht('%s added CCs to this revision.',
$author_name);
break;
case DifferentialAction::ACTION_CLAIM:
$title = pht('%s commandeered this revision.',
$author_name);
break;
case DifferentialAction::ACTION_REOPEN:
$title = pht('%s reopened this revision.',
$author_name);
break;
default:
$title = pht('Ghosts happened to this revision.');
break;
}
return $title;
}
/* legacy, for just mail now */
public static function getActionPastTenseVerb($action) { public static function getActionPastTenseVerb($action) {
$verbs = array( $verbs = array(
self::ACTION_COMMENT => 'commented on', self::ACTION_COMMENT => 'commented on',

View file

@ -112,20 +112,17 @@ final class DifferentialRevisionCommentView extends AphrontView {
DifferentialComment::METADATA_ADDED_CCS, DifferentialComment::METADATA_ADDED_CCS,
array()); array());
$verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
$actions = array(); $actions = array();
// TODO: i18n
switch ($comment->getAction()) { switch ($comment->getAction()) {
case DifferentialAction::ACTION_ADDCCS: case DifferentialAction::ACTION_ADDCCS:
$actions[] = hsprintf( $actions[] = pht(
"%s added CCs: %s.", "%s added CCs: %s.",
$author_link, $author_link,
$this->renderHandleList($added_ccs)); $this->renderHandleList($added_ccs));
$added_ccs = null; $added_ccs = null;
break; break;
case DifferentialAction::ACTION_ADDREVIEWERS: case DifferentialAction::ACTION_ADDREVIEWERS:
$actions[] = hsprintf( $actions[] = pht(
"%s added reviewers: %s.", "%s added reviewers: %s.",
$author_link, $author_link,
$this->renderHandleList($added_reviewers)); $this->renderHandleList($added_reviewers));
@ -140,41 +137,37 @@ final class DifferentialRevisionCommentView extends AphrontView {
'href' => '/D'.$comment->getRevisionID().'?id='.$diff_id, 'href' => '/D'.$comment->getRevisionID().'?id='.$diff_id,
), ),
'Diff #'.$diff_id); 'Diff #'.$diff_id);
$actions[] = hsprintf( $actions[] = pht(
"%s updated this revision to %s.", "%s updated this revision to %s.",
$author_link, $author_link,
$diff_link); $diff_link);
} else { } else {
$actions[] = hsprintf( $actions[] = DifferentialAction::getBasicStoryText(
"%s %s this revision.", $comment->getAction(), $author_link);
$author_link,
$verb);
} }
break; break;
default: default:
$actions[] = hsprintf( $actions[] = DifferentialAction::getBasicStoryText(
"%s %s this revision.", $comment->getAction(), $author_link);
$author_link,
$verb);
break; break;
} }
if ($added_reviewers) { if ($added_reviewers) {
$actions[] = hsprintf( $actions[] = pht(
"%s added reviewers: %s.", "%s added reviewers: %s.",
$author_link, $author_link,
$this->renderHandleList($added_reviewers)); $this->renderHandleList($added_reviewers));
} }
if ($removed_reviewers) { if ($removed_reviewers) {
$actions[] = hsprintf( $actions[] = pht(
"%s removed reviewers: %s.", "%s removed reviewers: %s.",
$author_link, $author_link,
$this->renderHandleList($removed_reviewers)); $this->renderHandleList($removed_reviewers));
} }
if ($added_ccs) { if ($added_ccs) {
$actions[] = hsprintf( $actions[] = pht(
"%s added CCs: %s.", "%s added CCs: %s.",
$author_link, $author_link,
$this->renderHandleList($added_ccs)); $this->renderHandleList($added_ccs));

View file

@ -48,13 +48,76 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
$actor_link = $this->linkTo($actor_phid); $actor_link = $this->linkTo($actor_phid);
$revision_link = $this->linkTo($revision_phid); $revision_link = $this->linkTo($revision_phid);
$verb = DifferentialAction::getActionPastTenseVerb($action); switch ($action) {
case DifferentialAction::ACTION_COMMENT:
$one_line = hsprintf( $one_line = pht('%s commented on revision %s',
'%s %s revision %s', $actor_link, $revision_link);
$actor_link, break;
$verb, case DifferentialAction::ACTION_ACCEPT:
$revision_link); $one_line = pht('%s accepted revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_REJECT:
$one_line = pht('%s requested changes to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_RETHINK:
$one_line = pht('%s planned changes to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_ABANDON:
$one_line = pht('%s abandoned revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_CLOSE:
$one_line = pht('%s closed revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_REQUEST:
$one_line = pht('%s requested a review of revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_RECLAIM:
$one_line = pht('%s reclaimed revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_UPDATE:
$one_line = pht('%s updated revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_RESIGN:
$one_line = pht('%s resigned from revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_SUMMARIZE:
$one_line = pht('%s summarized revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_TESTPLAN:
$one_line = pht('%s explained the test plan for revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_CREATE:
$one_line = pht('%s created revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$one_line = pht('%s added reviewers to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_ADDCCS:
$one_line = pht('%s added CCs to revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_CLAIM:
$one_line = pht('%s commandeered revision %s',
$actor_link, $revision_link);
break;
case DifferentialAction::ACTION_REOPEN:
$one_line = pht('%s reopened revision %s',
$actor_link, $revision_link);
break;
}
return $one_line; return $one_line;
} }
@ -67,11 +130,79 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
$revision_uri = PhabricatorEnv::getURI($revision_handle->getURI()); $revision_uri = PhabricatorEnv::getURI($revision_handle->getURI());
$action = $this->getValue('action'); $action = $this->getValue('action');
$verb = DifferentialAction::getActionPastTenseVerb($action);
$text = "{$author_name} {$verb} revision {$revision_title} {$revision_uri}"; switch ($action) {
case DifferentialAction::ACTION_COMMENT:
$one_line = pht('%s commented on revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ACCEPT:
$one_line = pht('%s accepted revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_REJECT:
$one_line = pht('%s requested changes to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_RETHINK:
$one_line = pht('%s planned changes to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ABANDON:
$one_line = pht('%s abandoned revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_CLOSE:
$one_line = pht('%s closed revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_REQUEST:
$one_line = pht('%s requested a review of revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_RECLAIM:
$one_line = pht('%s reclaimed revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_UPDATE:
$one_line = pht('%s updated revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_RESIGN:
$one_line = pht('%s resigned from revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_SUMMARIZE:
$one_line = pht('%s summarized revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_TESTPLAN:
$one_line = pht('%s explained the test plan for revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_CREATE:
$one_line = pht('%s created revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$one_line = pht('%s added reviewers to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_ADDCCS:
$one_line = pht('%s added CCs to revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_CLAIM:
$one_line = pht('%s commandeered revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
case DifferentialAction::ACTION_REOPEN:
$one_line = pht('%s reopened revision %s %s',
$author_name, $revision_title, $revision_uri);
break;
}
return $text; return $one_line;
} }
public function getNotificationAggregations() { public function getNotificationAggregations() {
@ -96,7 +227,6 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
$author_name = $this->getHandle($this->getAuthorPHID())->getName(); $author_name = $this->getHandle($this->getAuthorPHID())->getName();
$action = $this->getValue('action'); $action = $this->getValue('action');
$verb = DifferentialAction::getActionPastTenseVerb($action);
$engine = PhabricatorMarkupEngine::newMarkupEngine(array()) $engine = PhabricatorMarkupEngine::newMarkupEngine(array())
->setConfig('viewer', new PhabricatorUser()) ->setConfig('viewer', new PhabricatorUser())
@ -106,9 +236,79 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
$revision_name = $this->getHandle($revision_phid)->getFullName(); $revision_name = $this->getHandle($revision_phid)->getFullName();
if ($implied_context) { if ($implied_context) {
$title = "{$author_name} {$verb} this revision."; $title = DifferentialAction::getBasicStoryText(
$action, $author_name);
} else { } else {
$title = "{$author_name} {$verb} revision {$revision_name}."; switch ($action) {
case DifferentialAction::ACTION_COMMENT:
$title = pht('%s commented on revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_ACCEPT:
$title = pht('%s accepted revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_REJECT:
$title = pht('%s requested changes to revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_RETHINK:
$title = pht('%s planned changes to revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_ABANDON:
$title = pht('%s abandoned revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_CLOSE:
$title = pht('%s closed revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_REQUEST:
$title = pht('%s requested a review of revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_RECLAIM:
$title = pht('%s reclaimed revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_UPDATE:
$title = pht('%s updated revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_RESIGN:
$title = pht('%s resigned from revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_SUMMARIZE:
$title = pht('%s summarized revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_TESTPLAN:
$title = pht('%s explained the test plan for revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_CREATE:
$title = pht('%s created revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$title = pht('%s added reviewers to revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_ADDCCS:
$title = pht('%s added CCs to revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_CLAIM:
$title = pht('%s commandeered revision %s',
$author_name, $revision_name);
break;
case DifferentialAction::ACTION_REOPEN:
$title = pht('%s reopened revision %s',
$author_name, $revision_name);
break;
}
} }
if (strlen($comment)) { if (strlen($comment)) {