@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.

Make notification counts properly translatable

Summary:
Ref T9132. When I've touched `PhabricatorApplication` I keep hitting this bad `pht()` junk.

The warning is correct, these strings are not extactable and can not be translated.

Fix it so they can be extracted and translated.

Broadly, in all cases we want to render one of these:

> 95 Things (for fewer than some limit)
> 99+ Things (when we hit the limit)

Test Plan: Looked at homepage status counts, moused over them, saw reasonable strings. Grepped for removed method.

Reviewers: chad

Reviewed By: chad

Subscribers: joshuaspence

Maniphest Tasks: T9132

Differential Revision: https://secure.phabricator.com/D14638

+110 -103
+15 -10
src/applications/audit/application/PhabricatorAuditApplication.php
··· 47 47 48 48 public function loadStatus(PhabricatorUser $user) { 49 49 $status = array(); 50 + $limit = self::MAX_STATUS_ITEMS; 50 51 51 52 $phids = PhabricatorAuditCommentEditor::loadAuditPHIDsForUser($user); 52 53 ··· 54 55 ->setViewer($user) 55 56 ->withAuthorPHIDs(array($user->getPHID())) 56 57 ->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN) 57 - ->setLimit(self::MAX_STATUS_ITEMS); 58 + ->setLimit($limit); 58 59 $commits = $query->execute(); 59 60 60 61 $count = count($commits); 61 - $count_str = self::formatStatusCount( 62 - $count, 63 - '%s Problem Commits', 64 - '%d Problem Commit(s)'); 62 + if ($count >= $limit) { 63 + $count_str = pht('%s+ Problem Commit(s)', new PhutilNumber($limit - 1)); 64 + } else { 65 + $count_str = pht('%s Problem Commit(s)', new PhutilNumber($count)); 66 + } 67 + 65 68 $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 66 69 $status[] = id(new PhabricatorApplicationStatusView()) 67 70 ->setType($type) ··· 72 75 ->setViewer($user) 73 76 ->withNeedsAuditByPHIDs($phids) 74 77 ->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_OPEN) 75 - ->setLimit(self::MAX_STATUS_ITEMS); 78 + ->setLimit($limit); 76 79 $commits = $query->execute(); 77 80 78 81 $count = count($commits); 79 - $count_str = self::formatStatusCount( 80 - $count, 81 - '%s Commits Awaiting Audit', 82 - '%d Commit(s) Awaiting Audit'); 82 + if ($count >= $limit) { 83 + $count_str = pht('%s+ Problem Commit(s)', new PhutilNumber($limit - 1)); 84 + } else { 85 + $count_str = pht('%s Problem Commit(s)', new PhutilNumber($count)); 86 + } 87 + 83 88 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 84 89 $status[] = id(new PhabricatorApplicationStatusView()) 85 90 ->setType($type)
-16
src/applications/base/PhabricatorApplication.php
··· 288 288 return array(); 289 289 } 290 290 291 - /** 292 - * @return string 293 - * @task ui 294 - */ 295 - final public static function formatStatusCount( 296 - $count, 297 - $limit_string = '%s', 298 - $base_string = '%d') { 299 - if ($count == self::MAX_STATUS_ITEMS) { 300 - $count_str = pht($limit_string, ($count - 1).'+'); 301 - } else { 302 - $count_str = pht($base_string, $count); 303 - } 304 - return $count_str; 305 - } 306 - 307 291 308 292 /** 309 293 * You can provide an optional piece of flavor text for the application. This
+20 -18
src/applications/differential/application/PhabricatorDifferentialApplication.php
··· 104 104 } 105 105 106 106 public function loadStatus(PhabricatorUser $user) { 107 + $limit = self::MAX_STATUS_ITEMS; 108 + 107 109 $revisions = id(new DifferentialRevisionQuery()) 108 110 ->setViewer($user) 109 111 ->withResponsibleUsers(array($user->getPHID())) 110 112 ->withStatus(DifferentialRevisionQuery::STATUS_OPEN) 111 113 ->needRelationships(true) 112 - ->setLimit(self::MAX_STATUS_ITEMS) 114 + ->setLimit($limit) 113 115 ->execute(); 114 116 115 117 $status = array(); 116 - if (count($revisions) == self::MAX_STATUS_ITEMS) { 118 + if (count($revisions) >= $limit) { 117 119 $all_count = count($revisions); 118 - $all_count_str = self::formatStatusCount( 119 - $all_count, 120 - '%s Active Reviews', 121 - '%d Active Review(s)'); 120 + $all_count_str = pht( 121 + '%s+ Active Review(s)', 122 + new PhutilNumber($limit - 1)); 123 + 122 124 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 123 125 $status[] = id(new PhabricatorApplicationStatusView()) 124 126 ->setType($type) ··· 131 133 array($user->getPHID())); 132 134 133 135 $blocking = count($blocking); 134 - $blocking_str = self::formatStatusCount( 135 - $blocking, 136 - '%s Reviews Blocking Others', 137 - '%d Review(s) Blocking Others'); 136 + $blocking_str = pht( 137 + '%s Review(s) Blocking Others', 138 + new PhutilNumber($blocking)); 139 + 138 140 $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 139 141 $status[] = id(new PhabricatorApplicationStatusView()) 140 142 ->setType($type) ··· 142 144 ->setCount($blocking); 143 145 144 146 $active = count($active); 145 - $active_str = self::formatStatusCount( 146 - $active, 147 - '%s Reviews Need Attention', 148 - '%d Review(s) Need Attention'); 147 + $active_str = pht( 148 + '%s Review(s) Need Attention', 149 + new PhutilNumber($active)); 150 + 149 151 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 150 152 $status[] = id(new PhabricatorApplicationStatusView()) 151 153 ->setType($type) ··· 153 155 ->setCount($active); 154 156 155 157 $waiting = count($waiting); 156 - $waiting_str = self::formatStatusCount( 157 - $waiting, 158 - '%s Reviews Waiting on Others', 159 - '%d Review(s) Waiting on Others'); 158 + $waiting_str = pht( 159 + '%s Review(s) Waiting on Others', 160 + new PhutilNumber($waiting)); 161 + 160 162 $type = PhabricatorApplicationStatusView::TYPE_INFO; 161 163 $status[] = id(new PhabricatorApplicationStatusView()) 162 164 ->setType($type)
+7 -4
src/applications/flag/application/PhabricatorFlagsApplication.php
··· 34 34 35 35 public function loadStatus(PhabricatorUser $user) { 36 36 $status = array(); 37 + $limit = self::MAX_STATUS_ITEMS; 37 38 38 39 $flags = id(new PhabricatorFlagQuery()) 39 40 ->setViewer($user) ··· 42 43 ->execute(); 43 44 44 45 $count = count($flags); 45 - $count_str = self::formatStatusCount( 46 - $count, 47 - '%s Flagged Objects', 48 - '%d Flagged Object(s)'); 46 + if ($count >= $limit) { 47 + $count_str = pht('%s+ Flagged Object(s)', new PhutilNumber($limit - 1)); 48 + } else { 49 + $count_str = pht('%s Flagged Object(s)', new PhutilNumber($count)); 50 + } 51 + 49 52 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 50 53 $status[] = id(new PhabricatorApplicationStatusView()) 51 54 ->setType($type)
+9 -5
src/applications/maniphest/application/PhabricatorManiphestApplication.php
··· 80 80 return $status; 81 81 } 82 82 83 + $limit = self::MAX_STATUS_ITEMS; 84 + 83 85 $query = id(new ManiphestTaskQuery()) 84 86 ->setViewer($user) 85 87 ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 86 88 ->withOwners(array($user->getPHID())) 87 - ->setLimit(self::MAX_STATUS_ITEMS); 89 + ->setLimit($limit); 90 + 88 91 $count = count($query->execute()); 89 - $count_str = self::formatStatusCount( 90 - $count, 91 - '%s Assigned Tasks', 92 - '%d Assigned Task(s)'); 92 + if ($count >= $limit) { 93 + $count_str = pht('%s+ Assigned Task(s)', new PhutilNumber($limit - 1)); 94 + } else { 95 + $count_str = pht('%s Assigned Task(s)', new PhutilNumber($count)); 96 + } 93 97 94 98 $type = PhabricatorApplicationStatusView::TYPE_WARNING; 95 99 $status[] = id(new PhabricatorApplicationStatusView())
+12 -2
src/applications/meta/view/PhabricatorApplicationLaunchView.php
··· 72 72 array( 73 73 'class' => 'phabricator-application-attention-count', 74 74 ), 75 - PhabricatorApplication::formatStatusCount($count)); 75 + $this->formatStatusItemCount($count)); 76 76 } 77 77 78 78 ··· 82 82 array( 83 83 'class' => 'phabricator-application-warning-count', 84 84 ), 85 - PhabricatorApplication::formatStatusCount($counts[$warning])); 85 + $this->formatStatusItemCount($counts[$warning])); 86 86 } 87 + 87 88 if (nonempty($count1) && nonempty($count2)) { 88 89 $numbers = array($count1, ' / ', $count2); 89 90 } else { ··· 130 131 $icon, 131 132 $content, 132 133 ); 134 + } 135 + 136 + private function formatStatusItemCount($count) { 137 + $limit = PhabricatorApplication::MAX_STATUS_ITEMS; 138 + if ($count >= $limit) { 139 + return pht('%s+', new PhutilNumber($limit - 1)); 140 + } else { 141 + return pht('%s', new PhutilNumber($count)); 142 + } 133 143 } 134 144 135 145 }
+12 -6
src/applications/people/application/PhabricatorPeopleApplication.php
··· 95 95 if (!$user->getIsAdmin()) { 96 96 return array(); 97 97 } 98 + $limit = self::MAX_STATUS_ITEMS; 98 99 99 100 $need_approval = id(new PhabricatorPeopleQuery()) 100 101 ->setViewer($user) 101 102 ->withIsApproved(false) 102 103 ->withIsDisabled(false) 103 - ->setLimit(self::MAX_STATUS_ITEMS) 104 + ->setLimit($limit) 104 105 ->execute(); 105 - 106 106 if (!$need_approval) { 107 107 return array(); 108 108 } ··· 110 110 $status = array(); 111 111 112 112 $count = count($need_approval); 113 - $count_str = self::formatStatusCount( 114 - $count, 115 - '%s Users Need Approval', 116 - '%d User(s) Need Approval'); 113 + if ($count >= $limit) { 114 + $count_str = pht( 115 + '%s+ User(s) Need Approval', 116 + new PhutilNumber($limit - 1)); 117 + } else { 118 + $count_str = pht( 119 + '%s User(s) Need Approval', 120 + new PhutilNumber($count)); 121 + } 122 + 117 123 $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 118 124 $status[] = id(new PhabricatorApplicationStatusView()) 119 125 ->setType($type)
+8 -7
src/applications/phrequent/application/PhabricatorPhrequentApplication.php
··· 48 48 49 49 public function loadStatus(PhabricatorUser $user) { 50 50 $status = array(); 51 + $limit = self::MAX_STATUS_ITEMS; 51 52 52 53 // Show number of objects that are currently 53 54 // being tracked for a user. 54 55 55 - $count = PhrequentUserTimeQuery::getUserTotalObjectsTracked( 56 - $user, 57 - self::MAX_STATUS_ITEMS); 58 - $count_str = self::formatStatusCount( 59 - $count, 60 - '%s Objects Tracked', 61 - '%d Object(s) Tracked'); 56 + $count = PhrequentUserTimeQuery::getUserTotalObjectsTracked($user, $limit); 57 + if ($count >= $limit) { 58 + $count_str = pht('%s+ Object(s) Tracked', new PhutilNumber($limit - 1)); 59 + } else { 60 + $count_str = pht('%s Object(s) Tracked', new PhutilNumber($count)); 61 + } 62 + 62 63 $type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION; 63 64 $status[] = id(new PhabricatorApplicationStatusView()) 64 65 ->setType($type)
-8
src/applications/ponder/application/PhabricatorPonderApplication.php
··· 28 28 return "\xE2\x97\xB3"; 29 29 } 30 30 31 - public function loadStatus(PhabricatorUser $user) { 32 - // Replace with "x new unanswered questions" or some such 33 - // make sure to use `self::formatStatusCount` and friends...! 34 - $status = array(); 35 - 36 - return $status; 37 - } 38 - 39 31 public function getRemarkupRules() { 40 32 return array( 41 33 new PonderRemarkupRule(),
+27 -27
src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
··· 55 55 'There are %d aggregate facts in storage.', 56 56 ), 57 57 58 - '%d Commit(s) Awaiting Audit' => array( 59 - '%d Commit Awaiting Audit', 60 - '%d Commits Awaiting Audit', 58 + '%s Commit(s) Awaiting Audit' => array( 59 + '%s Commit Awaiting Audit', 60 + '%s Commits Awaiting Audit', 61 61 ), 62 62 63 - '%d Problem Commit(s)' => array( 64 - '%d Problem Commit', 65 - '%d Problem Commits', 63 + '%s Problem Commit(s)' => array( 64 + '%s Problem Commit', 65 + '%s Problem Commits', 66 66 ), 67 67 68 - '%d Review(s) Blocking Others' => array( 69 - '%d Review Blocking Others', 70 - '%d Reviews Blocking Others', 68 + '%s Review(s) Blocking Others' => array( 69 + '%s Review Blocking Others', 70 + '%s Reviews Blocking Others', 71 71 ), 72 72 73 - '%d Review(s) Need Attention' => array( 74 - '%d Review Needs Attention', 75 - '%d Reviews Need Attention', 73 + '%s Review(s) Need Attention' => array( 74 + '%s Review Needs Attention', 75 + '%s Reviews Need Attention', 76 76 ), 77 77 78 - '%d Review(s) Waiting on Others' => array( 79 - '%d Review Waiting on Others', 80 - '%d Reviews Waiting on Others', 78 + '%s Review(s) Waiting on Others' => array( 79 + '%s Review Waiting on Others', 80 + '%s Reviews Waiting on Others', 81 81 ), 82 82 83 - '%d Active Review(s)' => array( 84 - '%d Active Review', 85 - '%d Active Reviews', 83 + '%s Active Review(s)' => array( 84 + '%s Active Review', 85 + '%s Active Reviews', 86 86 ), 87 87 88 - '%d Flagged Object(s)' => array( 89 - '%d Flagged Object', 90 - '%d Flagged Objects', 88 + '%s Flagged Object(s)' => array( 89 + '%s Flagged Object', 90 + '%s Flagged Objects', 91 91 ), 92 92 93 - '%d Object(s) Tracked' => array( 94 - '%d Object Tracked', 95 - '%d Objects Tracked', 93 + '%s Object(s) Tracked' => array( 94 + '%s Object Tracked', 95 + '%s Objects Tracked', 96 96 ), 97 97 98 - '%d Assigned Task(s)' => array( 99 - '%d Assigned Task', 100 - '%d Assigned Tasks', 98 + '%s Assigned Task(s)' => array( 99 + '%s Assigned Task', 100 + '%s Assigned Tasks', 101 101 ), 102 102 103 103 'Show %d Lint Message(s)' => array(