@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+301 -30
+78
src/applications/differential/constants/DifferentialAction.php
··· 20 20 const ACTION_CLAIM = 'claim'; 21 21 const ACTION_REOPEN = 'reopen'; 22 22 23 + public static function getBasicStoryText($action, $author_name) { 24 + switch ($action) { 25 + case DifferentialAction::ACTION_COMMENT: 26 + $title = pht('%s commented on this revision.', 27 + $author_name); 28 + break; 29 + case DifferentialAction::ACTION_ACCEPT: 30 + $title = pht('%s accepted this revision.', 31 + $author_name); 32 + break; 33 + case DifferentialAction::ACTION_REJECT: 34 + $title = pht('%s requested changes to this revision.', 35 + $author_name); 36 + break; 37 + case DifferentialAction::ACTION_RETHINK: 38 + $title = pht('%s planned changes to this revision.', 39 + $author_name); 40 + break; 41 + case DifferentialAction::ACTION_ABANDON: 42 + $title = pht('%s abandoned this revision.', 43 + $author_name); 44 + break; 45 + case DifferentialAction::ACTION_CLOSE: 46 + $title = pht('%s closed this revision.', 47 + $author_name); 48 + break; 49 + case DifferentialAction::ACTION_REQUEST: 50 + $title = pht('%s requested a review of this revision.', 51 + $author_name); 52 + break; 53 + case DifferentialAction::ACTION_RECLAIM: 54 + $title = pht('%s reclaimed this revision.', 55 + $author_name); 56 + break; 57 + case DifferentialAction::ACTION_UPDATE: 58 + $title = pht('%s updated this revision.', 59 + $author_name); 60 + break; 61 + case DifferentialAction::ACTION_RESIGN: 62 + $title = pht('%s resigned from this revision.', 63 + $author_name); 64 + break; 65 + case DifferentialAction::ACTION_SUMMARIZE: 66 + $title = pht('%s summarized this revision.', 67 + $author_name); 68 + break; 69 + case DifferentialAction::ACTION_TESTPLAN: 70 + $title = pht('%s explained the test plan for this revision.', 71 + $author_name); 72 + break; 73 + case DifferentialAction::ACTION_CREATE: 74 + $title = pht('%s created this revision.', 75 + $author_name); 76 + break; 77 + case DifferentialAction::ACTION_ADDREVIEWERS: 78 + $title = pht('%s added reviewers to this revision.', 79 + $author_name); 80 + break; 81 + case DifferentialAction::ACTION_ADDCCS: 82 + $title = pht('%s added CCs to this revision.', 83 + $author_name); 84 + break; 85 + case DifferentialAction::ACTION_CLAIM: 86 + $title = pht('%s commandeered this revision.', 87 + $author_name); 88 + break; 89 + case DifferentialAction::ACTION_REOPEN: 90 + $title = pht('%s reopened this revision.', 91 + $author_name); 92 + break; 93 + default: 94 + $title = pht('Ghosts happened to this revision.'); 95 + break; 96 + } 97 + return $title; 98 + } 99 + 100 + /* legacy, for just mail now */ 23 101 public static function getActionPastTenseVerb($action) { 24 102 $verbs = array( 25 103 self::ACTION_COMMENT => 'commented on',
+10 -17
src/applications/differential/view/DifferentialRevisionCommentView.php
··· 112 112 DifferentialComment::METADATA_ADDED_CCS, 113 113 array()); 114 114 115 - $verb = DifferentialAction::getActionPastTenseVerb($comment->getAction()); 116 - 117 115 $actions = array(); 118 - // TODO: i18n 119 116 switch ($comment->getAction()) { 120 117 case DifferentialAction::ACTION_ADDCCS: 121 - $actions[] = hsprintf( 118 + $actions[] = pht( 122 119 "%s added CCs: %s.", 123 120 $author_link, 124 121 $this->renderHandleList($added_ccs)); 125 122 $added_ccs = null; 126 123 break; 127 124 case DifferentialAction::ACTION_ADDREVIEWERS: 128 - $actions[] = hsprintf( 125 + $actions[] = pht( 129 126 "%s added reviewers: %s.", 130 127 $author_link, 131 128 $this->renderHandleList($added_reviewers)); ··· 140 137 'href' => '/D'.$comment->getRevisionID().'?id='.$diff_id, 141 138 ), 142 139 'Diff #'.$diff_id); 143 - $actions[] = hsprintf( 140 + $actions[] = pht( 144 141 "%s updated this revision to %s.", 145 142 $author_link, 146 143 $diff_link); 147 144 } else { 148 - $actions[] = hsprintf( 149 - "%s %s this revision.", 150 - $author_link, 151 - $verb); 145 + $actions[] = DifferentialAction::getBasicStoryText( 146 + $comment->getAction(), $author_link); 152 147 } 153 148 break; 154 149 default: 155 - $actions[] = hsprintf( 156 - "%s %s this revision.", 157 - $author_link, 158 - $verb); 150 + $actions[] = DifferentialAction::getBasicStoryText( 151 + $comment->getAction(), $author_link); 159 152 break; 160 153 } 161 154 162 155 if ($added_reviewers) { 163 - $actions[] = hsprintf( 156 + $actions[] = pht( 164 157 "%s added reviewers: %s.", 165 158 $author_link, 166 159 $this->renderHandleList($added_reviewers)); 167 160 } 168 161 169 162 if ($removed_reviewers) { 170 - $actions[] = hsprintf( 163 + $actions[] = pht( 171 164 "%s removed reviewers: %s.", 172 165 $author_link, 173 166 $this->renderHandleList($removed_reviewers)); 174 167 } 175 168 176 169 if ($added_ccs) { 177 - $actions[] = hsprintf( 170 + $actions[] = pht( 178 171 "%s added CCs: %s.", 179 172 $author_link, 180 173 $this->renderHandleList($added_ccs));
+213 -13
src/applications/feed/story/PhabricatorFeedStoryDifferential.php
··· 48 48 $actor_link = $this->linkTo($actor_phid); 49 49 $revision_link = $this->linkTo($revision_phid); 50 50 51 - $verb = DifferentialAction::getActionPastTenseVerb($action); 52 - 53 - $one_line = hsprintf( 54 - '%s %s revision %s', 55 - $actor_link, 56 - $verb, 57 - $revision_link); 51 + switch ($action) { 52 + case DifferentialAction::ACTION_COMMENT: 53 + $one_line = pht('%s commented on revision %s', 54 + $actor_link, $revision_link); 55 + break; 56 + case DifferentialAction::ACTION_ACCEPT: 57 + $one_line = pht('%s accepted revision %s', 58 + $actor_link, $revision_link); 59 + break; 60 + case DifferentialAction::ACTION_REJECT: 61 + $one_line = pht('%s requested changes to revision %s', 62 + $actor_link, $revision_link); 63 + break; 64 + case DifferentialAction::ACTION_RETHINK: 65 + $one_line = pht('%s planned changes to revision %s', 66 + $actor_link, $revision_link); 67 + break; 68 + case DifferentialAction::ACTION_ABANDON: 69 + $one_line = pht('%s abandoned revision %s', 70 + $actor_link, $revision_link); 71 + break; 72 + case DifferentialAction::ACTION_CLOSE: 73 + $one_line = pht('%s closed revision %s', 74 + $actor_link, $revision_link); 75 + break; 76 + case DifferentialAction::ACTION_REQUEST: 77 + $one_line = pht('%s requested a review of revision %s', 78 + $actor_link, $revision_link); 79 + break; 80 + case DifferentialAction::ACTION_RECLAIM: 81 + $one_line = pht('%s reclaimed revision %s', 82 + $actor_link, $revision_link); 83 + break; 84 + case DifferentialAction::ACTION_UPDATE: 85 + $one_line = pht('%s updated revision %s', 86 + $actor_link, $revision_link); 87 + break; 88 + case DifferentialAction::ACTION_RESIGN: 89 + $one_line = pht('%s resigned from revision %s', 90 + $actor_link, $revision_link); 91 + break; 92 + case DifferentialAction::ACTION_SUMMARIZE: 93 + $one_line = pht('%s summarized revision %s', 94 + $actor_link, $revision_link); 95 + break; 96 + case DifferentialAction::ACTION_TESTPLAN: 97 + $one_line = pht('%s explained the test plan for revision %s', 98 + $actor_link, $revision_link); 99 + break; 100 + case DifferentialAction::ACTION_CREATE: 101 + $one_line = pht('%s created revision %s', 102 + $actor_link, $revision_link); 103 + break; 104 + case DifferentialAction::ACTION_ADDREVIEWERS: 105 + $one_line = pht('%s added reviewers to revision %s', 106 + $actor_link, $revision_link); 107 + break; 108 + case DifferentialAction::ACTION_ADDCCS: 109 + $one_line = pht('%s added CCs to revision %s', 110 + $actor_link, $revision_link); 111 + break; 112 + case DifferentialAction::ACTION_CLAIM: 113 + $one_line = pht('%s commandeered revision %s', 114 + $actor_link, $revision_link); 115 + break; 116 + case DifferentialAction::ACTION_REOPEN: 117 + $one_line = pht('%s reopened revision %s', 118 + $actor_link, $revision_link); 119 + break; 120 + } 58 121 59 122 return $one_line; 60 123 } ··· 67 130 $revision_uri = PhabricatorEnv::getURI($revision_handle->getURI()); 68 131 69 132 $action = $this->getValue('action'); 70 - $verb = DifferentialAction::getActionPastTenseVerb($action); 71 133 72 - $text = "{$author_name} {$verb} revision {$revision_title} {$revision_uri}"; 134 + switch ($action) { 135 + case DifferentialAction::ACTION_COMMENT: 136 + $one_line = pht('%s commented on revision %s %s', 137 + $author_name, $revision_title, $revision_uri); 138 + break; 139 + case DifferentialAction::ACTION_ACCEPT: 140 + $one_line = pht('%s accepted revision %s %s', 141 + $author_name, $revision_title, $revision_uri); 142 + break; 143 + case DifferentialAction::ACTION_REJECT: 144 + $one_line = pht('%s requested changes to revision %s %s', 145 + $author_name, $revision_title, $revision_uri); 146 + break; 147 + case DifferentialAction::ACTION_RETHINK: 148 + $one_line = pht('%s planned changes to revision %s %s', 149 + $author_name, $revision_title, $revision_uri); 150 + break; 151 + case DifferentialAction::ACTION_ABANDON: 152 + $one_line = pht('%s abandoned revision %s %s', 153 + $author_name, $revision_title, $revision_uri); 154 + break; 155 + case DifferentialAction::ACTION_CLOSE: 156 + $one_line = pht('%s closed revision %s %s', 157 + $author_name, $revision_title, $revision_uri); 158 + break; 159 + case DifferentialAction::ACTION_REQUEST: 160 + $one_line = pht('%s requested a review of revision %s %s', 161 + $author_name, $revision_title, $revision_uri); 162 + break; 163 + case DifferentialAction::ACTION_RECLAIM: 164 + $one_line = pht('%s reclaimed revision %s %s', 165 + $author_name, $revision_title, $revision_uri); 166 + break; 167 + case DifferentialAction::ACTION_UPDATE: 168 + $one_line = pht('%s updated revision %s %s', 169 + $author_name, $revision_title, $revision_uri); 170 + break; 171 + case DifferentialAction::ACTION_RESIGN: 172 + $one_line = pht('%s resigned from revision %s %s', 173 + $author_name, $revision_title, $revision_uri); 174 + break; 175 + case DifferentialAction::ACTION_SUMMARIZE: 176 + $one_line = pht('%s summarized revision %s %s', 177 + $author_name, $revision_title, $revision_uri); 178 + break; 179 + case DifferentialAction::ACTION_TESTPLAN: 180 + $one_line = pht('%s explained the test plan for revision %s %s', 181 + $author_name, $revision_title, $revision_uri); 182 + break; 183 + case DifferentialAction::ACTION_CREATE: 184 + $one_line = pht('%s created revision %s %s', 185 + $author_name, $revision_title, $revision_uri); 186 + break; 187 + case DifferentialAction::ACTION_ADDREVIEWERS: 188 + $one_line = pht('%s added reviewers to revision %s %s', 189 + $author_name, $revision_title, $revision_uri); 190 + break; 191 + case DifferentialAction::ACTION_ADDCCS: 192 + $one_line = pht('%s added CCs to revision %s %s', 193 + $author_name, $revision_title, $revision_uri); 194 + break; 195 + case DifferentialAction::ACTION_CLAIM: 196 + $one_line = pht('%s commandeered revision %s %s', 197 + $author_name, $revision_title, $revision_uri); 198 + break; 199 + case DifferentialAction::ACTION_REOPEN: 200 + $one_line = pht('%s reopened revision %s %s', 201 + $author_name, $revision_title, $revision_uri); 202 + break; 203 + } 73 204 74 - return $text; 205 + return $one_line; 75 206 } 76 207 77 208 public function getNotificationAggregations() { ··· 96 227 97 228 $author_name = $this->getHandle($this->getAuthorPHID())->getName(); 98 229 $action = $this->getValue('action'); 99 - $verb = DifferentialAction::getActionPastTenseVerb($action); 100 230 101 231 $engine = PhabricatorMarkupEngine::newMarkupEngine(array()) 102 232 ->setConfig('viewer', new PhabricatorUser()) ··· 106 236 $revision_name = $this->getHandle($revision_phid)->getFullName(); 107 237 108 238 if ($implied_context) { 109 - $title = "{$author_name} {$verb} this revision."; 239 + $title = DifferentialAction::getBasicStoryText( 240 + $action, $author_name); 110 241 } else { 111 - $title = "{$author_name} {$verb} revision {$revision_name}."; 242 + switch ($action) { 243 + case DifferentialAction::ACTION_COMMENT: 244 + $title = pht('%s commented on revision %s', 245 + $author_name, $revision_name); 246 + break; 247 + case DifferentialAction::ACTION_ACCEPT: 248 + $title = pht('%s accepted revision %s', 249 + $author_name, $revision_name); 250 + break; 251 + case DifferentialAction::ACTION_REJECT: 252 + $title = pht('%s requested changes to revision %s', 253 + $author_name, $revision_name); 254 + break; 255 + case DifferentialAction::ACTION_RETHINK: 256 + $title = pht('%s planned changes to revision %s', 257 + $author_name, $revision_name); 258 + break; 259 + case DifferentialAction::ACTION_ABANDON: 260 + $title = pht('%s abandoned revision %s', 261 + $author_name, $revision_name); 262 + break; 263 + case DifferentialAction::ACTION_CLOSE: 264 + $title = pht('%s closed revision %s', 265 + $author_name, $revision_name); 266 + break; 267 + case DifferentialAction::ACTION_REQUEST: 268 + $title = pht('%s requested a review of revision %s', 269 + $author_name, $revision_name); 270 + break; 271 + case DifferentialAction::ACTION_RECLAIM: 272 + $title = pht('%s reclaimed revision %s', 273 + $author_name, $revision_name); 274 + break; 275 + case DifferentialAction::ACTION_UPDATE: 276 + $title = pht('%s updated revision %s', 277 + $author_name, $revision_name); 278 + break; 279 + case DifferentialAction::ACTION_RESIGN: 280 + $title = pht('%s resigned from revision %s', 281 + $author_name, $revision_name); 282 + break; 283 + case DifferentialAction::ACTION_SUMMARIZE: 284 + $title = pht('%s summarized revision %s', 285 + $author_name, $revision_name); 286 + break; 287 + case DifferentialAction::ACTION_TESTPLAN: 288 + $title = pht('%s explained the test plan for revision %s', 289 + $author_name, $revision_name); 290 + break; 291 + case DifferentialAction::ACTION_CREATE: 292 + $title = pht('%s created revision %s', 293 + $author_name, $revision_name); 294 + break; 295 + case DifferentialAction::ACTION_ADDREVIEWERS: 296 + $title = pht('%s added reviewers to revision %s', 297 + $author_name, $revision_name); 298 + break; 299 + case DifferentialAction::ACTION_ADDCCS: 300 + $title = pht('%s added CCs to revision %s', 301 + $author_name, $revision_name); 302 + break; 303 + case DifferentialAction::ACTION_CLAIM: 304 + $title = pht('%s commandeered revision %s', 305 + $author_name, $revision_name); 306 + break; 307 + case DifferentialAction::ACTION_REOPEN: 308 + $title = pht('%s reopened revision %s', 309 + $author_name, $revision_name); 310 + break; 311 + } 112 312 } 113 313 114 314 if (strlen($comment)) {