From aaf8d73ec798217e18fc994883c5812a15a117c3 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 10 Feb 2015 18:49:08 +1100 Subject: [PATCH] Fix `pht` method calls Summary: Ref T7046. This is mainly a proof-of-concept for D11661. Test Plan: `arc lint` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7046 Differential Revision: https://secure.phabricator.com/D11680 --- .../AlmanacManagementRegisterWorkflow.php | 2 +- .../ConduitMethodDoesNotExistException.php | 3 +- .../config/view/PhabricatorSetupIssueView.php | 4 +- .../DifferentialHovercardEventListener.php | 2 +- .../mail/DifferentialCreateMailReceiver.php | 8 +-- .../DifferentialChangesetHTMLRenderer.php | 49 +++++-------------- .../PhabricatorPeopleApproveController.php | 3 +- .../PhabricatorRepositoryURINormalizer.php | 2 +- ...epositoryManagementLookupUsersWorkflow.php | 4 +- .../PhabricatorBaseEnglishTranslation.php | 10 ++-- ...bricatorRemarkupCowsayBlockInterpreter.php | 4 +- 11 files changed, 35 insertions(+), 56 deletions(-) diff --git a/src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php b/src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php index cf0104af82..6df7369ba2 100644 --- a/src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php +++ b/src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php @@ -192,7 +192,7 @@ final class AlmanacManagementRegisterWorkflow $console->writeOut( "%s\n", - pht('Installing device ID...', $raw_device)); + pht('Installing device %s...', $raw_device)); // The permissions on this file are more open because the webserver also // needs to read it. diff --git a/src/applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php b/src/applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php index 19311df9e1..27c361e05d 100644 --- a/src/applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php +++ b/src/applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php @@ -6,7 +6,8 @@ final class ConduitMethodDoesNotExistException public function __construct($method_name) { parent::__construct( pht( - 'Conduit API method "%s" does not exist.')); + 'Conduit API method "%s" does not exist.', + $method_name)); } } diff --git a/src/applications/config/view/PhabricatorSetupIssueView.php b/src/applications/config/view/PhabricatorSetupIssueView.php index a5ccd6797e..99acbe7576 100644 --- a/src/applications/config/view/PhabricatorSetupIssueView.php +++ b/src/applications/config/view/PhabricatorSetupIssueView.php @@ -385,8 +385,8 @@ final class PhabricatorSetupIssueView extends AphrontView { 'p', array(), pht( - 'PHP also loaded these configuration file(s):', - count($more_loc))); + 'PHP also loaded these %s configuration file(s):', + new PhutilNumber(count($more_loc)))); $info[] = phutil_tag( 'pre', array(), diff --git a/src/applications/differential/event/DifferentialHovercardEventListener.php b/src/applications/differential/event/DifferentialHovercardEventListener.php index 80ef4eb249..82ec5565c1 100644 --- a/src/applications/differential/event/DifferentialHovercardEventListener.php +++ b/src/applications/differential/event/DifferentialHovercardEventListener.php @@ -60,7 +60,7 @@ final class DifferentialHovercardEventListener implode_selected_handle_links(', ', $handles, $reviewer_phids)); if ($tasks) { - $hovercard->addField(pht('Task(s)', count($tasks)), + $hovercard->addField(pht('%s Task(s)', new PhutilNumber(count($tasks))), implode_selected_handle_links(', ', $handles, $tasks)); } diff --git a/src/applications/differential/mail/DifferentialCreateMailReceiver.php b/src/applications/differential/mail/DifferentialCreateMailReceiver.php index 9d9ac05043..614c52306d 100644 --- a/src/applications/differential/mail/DifferentialCreateMailReceiver.php +++ b/src/applications/differential/mail/DifferentialCreateMailReceiver.php @@ -79,15 +79,15 @@ final class DifferentialCreateMailReceiver extends PhabricatorMailReceiver { count($diffs)); } else { $subject = pht( - 'Diff creation failed; see body for error(s).', - count($errors)); + 'Diff creation failed; see body for %s error(s).', + new PhutilNumber(count($errors))); } $body = new PhabricatorMetaMTAMailBody(); $body->addRawSection($subject); if (count($diffs)) { $text_body = ''; $html_body = array(); - $body_label = pht('DIFF LINK(S)', count($diffs)); + $body_label = pht('%s DIFF LINK(S)', new PhutilNumber(count($diffs))); foreach ($diffs as $filename => $diff_uri) { $text_body .= $filename.': '.$diff_uri."\n"; $html_body[] = phutil_tag( @@ -104,7 +104,7 @@ final class DifferentialCreateMailReceiver extends PhabricatorMailReceiver { if (count($errors)) { $body_section = new PhabricatorMetaMTAMailSection(); - $body_label = pht('ERROR(S)', count($errors)); + $body_label = pht('%s ERROR(S)', new PhutilNumber(count($errors))); foreach ($errors as $error) { $body_section->addFragment($error); } diff --git a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php index f3790e4b7c..dc25eb8950 100644 --- a/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetHTMLRenderer.php @@ -10,40 +10,27 @@ abstract class DifferentialChangesetHTMLRenderer $file = $changeset->getFileType(); $messages = array(); - $none = hsprintf(''); switch ($change) { case DifferentialChangeType::TYPE_ADD: switch ($file) { case DifferentialChangeType::FILE_TEXT: - $messages[] = pht( - 'This file was added.', - $none); + $messages[] = pht('This file was added.'); break; case DifferentialChangeType::FILE_IMAGE: - $messages[] = pht( - 'This image was added.', - $none); + $messages[] = pht('This image was added.'); break; case DifferentialChangeType::FILE_DIRECTORY: - $messages[] = pht( - 'This directory was added.', - $none); + $messages[] = pht('This directory was added.'); break; case DifferentialChangeType::FILE_BINARY: - $messages[] = pht( - 'This binary file was added.', - $none); + $messages[] = pht('This binary file was added.'); break; case DifferentialChangeType::FILE_SYMLINK: - $messages[] = pht( - 'This symlink was added.', - $none); + $messages[] = pht('This symlink was added.'); break; case DifferentialChangeType::FILE_SUBMODULE: - $messages[] = pht( - 'This submodule was added.', - $none); + $messages[] = pht('This submodule was added.'); break; } break; @@ -51,34 +38,22 @@ abstract class DifferentialChangesetHTMLRenderer case DifferentialChangeType::TYPE_DELETE: switch ($file) { case DifferentialChangeType::FILE_TEXT: - $messages[] = pht( - 'This file was deleted.', - $none); + $messages[] = pht('This file was deleted.'); break; case DifferentialChangeType::FILE_IMAGE: - $messages[] = pht( - 'This image was deleted.', - $none); + $messages[] = pht('This image was deleted.'); break; case DifferentialChangeType::FILE_DIRECTORY: - $messages[] = pht( - 'This directory was deleted.', - $none); + $messages[] = pht('This directory was deleted.'); break; case DifferentialChangeType::FILE_BINARY: - $messages[] = pht( - 'This binary file was deleted.', - $none); + $messages[] = pht('This binary file was deleted.'); break; case DifferentialChangeType::FILE_SYMLINK: - $messages[] = pht( - 'This symlink was deleted.', - $none); + $messages[] = pht('This symlink was deleted.'); break; case DifferentialChangeType::FILE_SUBMODULE: - $messages[] = pht( - 'This submodule was deleted.', - $none); + $messages[] = pht('This submodule was deleted.'); break; } break; diff --git a/src/applications/people/controller/PhabricatorPeopleApproveController.php b/src/applications/people/controller/PhabricatorPeopleApproveController.php index ce1ac85dde..bbf69f23f8 100644 --- a/src/applications/people/controller/PhabricatorPeopleApproveController.php +++ b/src/applications/people/controller/PhabricatorPeopleApproveController.php @@ -31,8 +31,7 @@ final class PhabricatorPeopleApproveController $title = pht( 'Phabricator Account "%s" Approved', - $user->getUsername(), - $admin->getUsername()); + $user->getUsername()); $body = pht( "Your Phabricator account (%s) has been approved by %s. You can ". diff --git a/src/applications/repository/data/PhabricatorRepositoryURINormalizer.php b/src/applications/repository/data/PhabricatorRepositoryURINormalizer.php index bcfd6b061c..3a9508e197 100644 --- a/src/applications/repository/data/PhabricatorRepositoryURINormalizer.php +++ b/src/applications/repository/data/PhabricatorRepositoryURINormalizer.php @@ -52,7 +52,7 @@ final class PhabricatorRepositoryURINormalizer extends Phobject { case self::TYPE_MERCURIAL: break; default: - throw new Exception(pht('Unknown URI type "%s"!')); + throw new Exception(pht('Unknown URI type "%s"!', $type)); } $this->type = $type; diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php index 1f93618042..e4f03a4d1b 100644 --- a/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php @@ -48,7 +48,9 @@ final class PhabricatorRepositoryManagementLookupUsersWorkflow if (empty($refs_raw['data'])) { throw new Exception( - pht('Unable to retrieve details for commit "%s"!')); + pht( + 'Unable to retrieve details for commit "%s"!', + $commit->getPHID())); } $ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data'])); diff --git a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php index 868159642c..3e7355ef8b 100644 --- a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php +++ b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php @@ -17,9 +17,9 @@ abstract class PhabricatorBaseEnglishTranslation 'This configuration value is related:', 'These configuration values are related:', ), - 'Task(s)' => array('Task', 'Tasks'), + '%s Task(s)' => array('Task', 'Tasks'), - 'ERROR(S)' => array('ERROR', 'ERRORS'), + '%s ERROR(S)' => array('ERROR', 'ERRORS'), '%d Error(s)' => array('%d Error', '%d Errors'), '%d Warning(s)' => array('%d Warning', '%d Warnings'), '%d Auto-Fix(es)' => array('%d Auto-Fix', '%d Auto-Fixes'), @@ -32,12 +32,12 @@ abstract class PhabricatorBaseEnglishTranslation '%d path(s)' => array('%d path', '%d paths'), '%d diff(s)' => array('%d diff', '%d diffs'), - 'DIFF LINK(S)' => array('DIFF LINK', 'DIFF LINKS'), + '%s DIFF LINK(S)' => array('DIFF LINK', 'DIFF LINKS'), 'You successfully created %d diff(s).' => array( 'You successfully created %d diff.', 'You successfully created %d diffs.', ), - 'Diff creation failed; see body for error(s).' => array( + 'Diff creation failed; see body for %s error(s).' => array( 'Diff creation failed; see body for error.', 'Diff creation failed; see body for errors.', ), @@ -499,7 +499,7 @@ abstract class PhabricatorBaseEnglishTranslation 'here:', ), - 'PHP also loaded these configuration file(s):' => array( + 'PHP also loaded these %s configuration file(s):' => array( 'PHP also loaded this configuration file:', 'PHP also loaded these configuration files:', ), diff --git a/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php b/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php index 275849d33b..8f3cd3552c 100644 --- a/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php +++ b/src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php @@ -37,7 +37,9 @@ final class PhabricatorRemarkupCowsayBlockInterpreter if ($err) { return $this->markupError( pht( - 'Execution of `cowsay` failed:', $stderr)); + 'Execution of `%s` failed: %s', + 'cowsay', + $stderr)); }