mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01: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:
parent
dfd53fb008
commit
ee44c6db53
3 changed files with 301 additions and 30 deletions
|
@ -20,6 +20,84 @@ final class DifferentialAction {
|
|||
const ACTION_CLAIM = 'claim';
|
||||
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) {
|
||||
$verbs = array(
|
||||
self::ACTION_COMMENT => 'commented on',
|
||||
|
|
|
@ -112,20 +112,17 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
DifferentialComment::METADATA_ADDED_CCS,
|
||||
array());
|
||||
|
||||
$verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
|
||||
|
||||
$actions = array();
|
||||
// TODO: i18n
|
||||
switch ($comment->getAction()) {
|
||||
case DifferentialAction::ACTION_ADDCCS:
|
||||
$actions[] = hsprintf(
|
||||
$actions[] = pht(
|
||||
"%s added CCs: %s.",
|
||||
$author_link,
|
||||
$this->renderHandleList($added_ccs));
|
||||
$added_ccs = null;
|
||||
break;
|
||||
case DifferentialAction::ACTION_ADDREVIEWERS:
|
||||
$actions[] = hsprintf(
|
||||
$actions[] = pht(
|
||||
"%s added reviewers: %s.",
|
||||
$author_link,
|
||||
$this->renderHandleList($added_reviewers));
|
||||
|
@ -140,41 +137,37 @@ final class DifferentialRevisionCommentView extends AphrontView {
|
|||
'href' => '/D'.$comment->getRevisionID().'?id='.$diff_id,
|
||||
),
|
||||
'Diff #'.$diff_id);
|
||||
$actions[] = hsprintf(
|
||||
$actions[] = pht(
|
||||
"%s updated this revision to %s.",
|
||||
$author_link,
|
||||
$diff_link);
|
||||
} else {
|
||||
$actions[] = hsprintf(
|
||||
"%s %s this revision.",
|
||||
$author_link,
|
||||
$verb);
|
||||
$actions[] = DifferentialAction::getBasicStoryText(
|
||||
$comment->getAction(), $author_link);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$actions[] = hsprintf(
|
||||
"%s %s this revision.",
|
||||
$author_link,
|
||||
$verb);
|
||||
$actions[] = DifferentialAction::getBasicStoryText(
|
||||
$comment->getAction(), $author_link);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($added_reviewers) {
|
||||
$actions[] = hsprintf(
|
||||
$actions[] = pht(
|
||||
"%s added reviewers: %s.",
|
||||
$author_link,
|
||||
$this->renderHandleList($added_reviewers));
|
||||
}
|
||||
|
||||
if ($removed_reviewers) {
|
||||
$actions[] = hsprintf(
|
||||
$actions[] = pht(
|
||||
"%s removed reviewers: %s.",
|
||||
$author_link,
|
||||
$this->renderHandleList($removed_reviewers));
|
||||
}
|
||||
|
||||
if ($added_ccs) {
|
||||
$actions[] = hsprintf(
|
||||
$actions[] = pht(
|
||||
"%s added CCs: %s.",
|
||||
$author_link,
|
||||
$this->renderHandleList($added_ccs));
|
||||
|
|
|
@ -48,13 +48,76 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
|
|||
$actor_link = $this->linkTo($actor_phid);
|
||||
$revision_link = $this->linkTo($revision_phid);
|
||||
|
||||
$verb = DifferentialAction::getActionPastTenseVerb($action);
|
||||
|
||||
$one_line = hsprintf(
|
||||
'%s %s revision %s',
|
||||
$actor_link,
|
||||
$verb,
|
||||
$revision_link);
|
||||
switch ($action) {
|
||||
case DifferentialAction::ACTION_COMMENT:
|
||||
$one_line = pht('%s commented on revision %s',
|
||||
$actor_link, $revision_link);
|
||||
break;
|
||||
case DifferentialAction::ACTION_ACCEPT:
|
||||
$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;
|
||||
}
|
||||
|
@ -67,11 +130,79 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
|
|||
$revision_uri = PhabricatorEnv::getURI($revision_handle->getURI());
|
||||
|
||||
$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() {
|
||||
|
@ -96,7 +227,6 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
|
|||
|
||||
$author_name = $this->getHandle($this->getAuthorPHID())->getName();
|
||||
$action = $this->getValue('action');
|
||||
$verb = DifferentialAction::getActionPastTenseVerb($action);
|
||||
|
||||
$engine = PhabricatorMarkupEngine::newMarkupEngine(array())
|
||||
->setConfig('viewer', new PhabricatorUser())
|
||||
|
@ -106,9 +236,79 @@ final class PhabricatorFeedStoryDifferential extends PhabricatorFeedStory {
|
|||
$revision_name = $this->getHandle($revision_phid)->getFullName();
|
||||
|
||||
if ($implied_context) {
|
||||
$title = "{$author_name} {$verb} this revision.";
|
||||
$title = DifferentialAction::getBasicStoryText(
|
||||
$action, $author_name);
|
||||
} 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)) {
|
||||
|
|
Loading…
Reference in a new issue