From d2b38cdf94441146daf5f5ae68169689dc0c24d7 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Wed, 13 May 2015 18:05:15 +1000 Subject: [PATCH] `pht` all the things MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: `pht`ize almost all strings in rARC. Test Plan: ¯\_(ツ)_/¯ Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: aurelijus, Korvin, epriestley Differential Revision: https://secure.phabricator.com/D12607 --- src/configuration/ArcanistConfiguration.php | 15 +- .../ArcanistConfigurationManager.php | 20 +- src/configuration/ArcanistSettings.php | 2 +- .../__tests__/ArcanistBritishTestCase.php | 4 +- src/difference/ArcanistDiffUtils.php | 2 +- .../ArcanistDifferentialRevisionStatus.php | 2 +- .../usage/ArcanistUserAbortException.php | 2 +- src/hgdaemon/ArcanistHgClientChannel.php | 2 +- src/hgdaemon/ArcanistHgProxyClient.php | 5 +- src/hgdaemon/ArcanistHgProxyServer.php | 35 ++- src/hgdaemon/ArcanistHgServerChannel.php | 3 +- src/lint/ArcanistLintPatcher.php | 8 +- src/lint/ArcanistLintSeverity.php | 12 +- src/lint/engine/ArcanistLintEngine.php | 8 +- src/lint/linter/ArcanistBaseXHPASTLinter.php | 5 +- src/lint/linter/ArcanistCSharpLinter.php | 40 ++- src/lint/linter/ArcanistCppcheckLinter.php | 8 +- src/lint/linter/ArcanistCpplintLinter.php | 6 +- src/lint/linter/ArcanistFlake8Linter.php | 7 +- src/lint/linter/ArcanistGeneratedLinter.php | 4 +- src/lint/linter/ArcanistGoLintLinter.php | 4 +- src/lint/linter/ArcanistHLintLinter.php | 13 +- src/lint/linter/ArcanistJSHintLinter.php | 6 +- src/lint/linter/ArcanistJSONLintLinter.php | 4 +- src/lint/linter/ArcanistJscsLinter.php | 8 +- src/lint/linter/ArcanistLesscLinter.php | 17 +- src/lint/linter/ArcanistLinter.php | 17 +- src/lint/linter/ArcanistPEP8Linter.php | 2 +- src/lint/linter/ArcanistPhpLinter.php | 2 +- src/lint/linter/ArcanistPhpcsLinter.php | 7 +- .../linter/ArcanistPhutilXHPASTLinter.php | 7 +- src/lint/linter/ArcanistPyFlakesLinter.php | 2 +- src/lint/linter/ArcanistPyLintLinter.php | 22 +- src/lint/linter/ArcanistRuboCopLinter.php | 6 +- src/lint/linter/ArcanistRubyLinter.php | 6 +- .../linter/ArcanistScriptAndRegexLinter.php | 2 +- src/lint/linter/ArcanistXMLLinter.php | 2 +- .../ArcanistCppcheckLinterTestCase.php | 2 +- .../ArcanistCpplintLinterTestCase.php | 2 +- .../__tests__/ArcanistLinterTestCase.php | 5 +- .../ArcanistNoLintLinterTestCase.php | 2 +- .../ArcanistPhutilXHPASTLinterTestCase.php | 2 +- .../ArcanistPyLintLinterTestCase.php | 2 +- .../renderer/ArcanistConsoleLintRenderer.php | 14 +- .../renderer/ArcanistSummaryLintRenderer.php | 4 +- src/parser/ArcanistBaseCommitParser.php | 45 +-- src/parser/ArcanistBundle.php | 21 +- src/parser/ArcanistDiffParser.php | 87 ++++-- .../__tests__/ArcanistBundleTestCase.php | 25 +- .../__tests__/ArcanistDiffParserTestCase.php | 8 +- src/parser/diff/ArcanistDiffChange.php | 4 +- src/parser/diff/ArcanistDiffChangeType.php | 31 +- src/parser/diff/ArcanistDiffHunk.php | 2 +- src/repository/api/ArcanistGitAPI.php | 202 ++++++++----- src/repository/api/ArcanistMercurialAPI.php | 131 +++++--- src/repository/api/ArcanistRepositoryAPI.php | 3 +- src/repository/api/ArcanistSubversionAPI.php | 26 +- .../ArcanistRepositoryAPIStateTestCase.php | 8 +- .../parser/ArcanistMercurialParser.php | 21 +- .../ArcanistMercurialParserTestCase.php | 3 +- src/unit/engine/ArcanistUnitTestEngine.php | 8 +- src/unit/engine/CSharpToolsTestEngine.php | 11 +- src/unit/engine/NoseTestEngine.php | 12 +- src/unit/engine/PhpunitTestEngine.php | 8 +- src/unit/engine/PhutilUnitTestEngine.php | 29 +- src/unit/engine/PytestTestEngine.php | 2 +- src/unit/engine/XUnitTestEngine.php | 26 +- .../PhutilUnitTestEngineTestCase.php | 30 +- .../engine/phutil/ArcanistPhutilTestCase.php | 46 +-- .../parser/ArcanistGoTestResultParser.php | 1 - .../ArcanistPhpunitTestResultParser.php | 13 +- .../parser/ArcanistXUnitTestResultParser.php | 10 +- .../XUnitTestResultParserTestCase.php | 4 +- .../renderer/ArcanistUnitConsoleRenderer.php | 36 ++- src/workflow/ArcanistAliasWorkflow.php | 33 ++- src/workflow/ArcanistAmendWorkflow.php | 65 ++-- src/workflow/ArcanistBackoutWorkflow.php | 15 +- src/workflow/ArcanistBrowseWorkflow.php | 22 +- .../ArcanistCloseRevisionWorkflow.php | 39 ++- src/workflow/ArcanistCloseWorkflow.php | 37 ++- src/workflow/ArcanistCommitWorkflow.php | 77 +++-- src/workflow/ArcanistCoverWorkflow.php | 9 +- src/workflow/ArcanistDiffWorkflow.php | 19 +- src/workflow/ArcanistDownloadWorkflow.php | 26 +- src/workflow/ArcanistExportWorkflow.php | 55 ++-- src/workflow/ArcanistFeatureWorkflow.php | 15 +- src/workflow/ArcanistFlagWorkflow.php | 27 +- src/workflow/ArcanistGetConfigWorkflow.php | 4 +- src/workflow/ArcanistHelpWorkflow.php | 19 +- .../ArcanistInstallCertificateWorkflow.php | 40 +-- src/workflow/ArcanistLandWorkflow.php | 247 +++++++++------- src/workflow/ArcanistLiberateWorkflow.php | 74 +++-- src/workflow/ArcanistLintWorkflow.php | 109 ++++--- src/workflow/ArcanistLintersWorkflow.php | 6 +- src/workflow/ArcanistListWorkflow.php | 9 +- src/workflow/ArcanistPasteWorkflow.php | 2 +- src/workflow/ArcanistPatchWorkflow.php | 279 +++++++++++------- src/workflow/ArcanistRevertWorkflow.php | 4 +- src/workflow/ArcanistSetConfigWorkflow.php | 26 +- .../ArcanistShellCompleteWorkflow.php | 4 +- src/workflow/ArcanistTasksWorkflow.php | 27 +- src/workflow/ArcanistTodoWorkflow.php | 14 +- src/workflow/ArcanistUnitWorkflow.php | 57 ++-- src/workflow/ArcanistUpgradeWorkflow.php | 4 +- src/workflow/ArcanistUploadWorkflow.php | 10 +- src/workflow/ArcanistVersionWorkflow.php | 4 +- src/workflow/ArcanistWhichWorkflow.php | 69 +++-- src/workflow/ArcanistWorkflow.php | 262 +++++++++------- ...rcanistCapabilityNotSupportedException.php | 5 +- .../ArcanistWorkingCopyIdentity.php | 16 +- 110 files changed, 1783 insertions(+), 1150 deletions(-) diff --git a/src/configuration/ArcanistConfiguration.php b/src/configuration/ArcanistConfiguration.php index d232da3d..5755cc5e 100644 --- a/src/configuration/ArcanistConfiguration.php +++ b/src/configuration/ArcanistConfiguration.php @@ -46,8 +46,11 @@ class ArcanistConfiguration { if (isset($workflows_by_name[$name])) { $other = get_class($workflows_by_name[$name]); throw new Exception( - "Workflows {$class} and {$other} both implement workflows named ". - "{$name}."); + pht( + 'Workflows %s and %s both implement workflows named %s.', + $class, + $other, + $name)); } $workflows_by_name[$name] = $workflow; @@ -109,7 +112,8 @@ class ArcanistConfiguration { $shell_cmd = substr($full_alias, 1); $console->writeLog( - "[alias: 'arc %s' -> $ %s]", + "[%s: 'arc %s' -> $ %s]", + pht('alias'), $command, $shell_cmd); @@ -127,7 +131,8 @@ class ArcanistConfiguration { $workflow = $this->buildWorkflow($new_command); if ($workflow) { $console->writeLog( - "[alias: 'arc %s' -> 'arc %s']\n", + "[%s: 'arc %s' -> 'arc %s']\n", + pht('alias'), $command, $full_alias); $command = $new_command; @@ -168,7 +173,7 @@ class ArcanistConfiguration { } private function raiseUnknownCommand($command, array $maybe = array()) { - $message = pht("Unknown command '%s'. Try 'arc help'.", $command); + $message = pht("Unknown command '%s'. Try '%s'.", $command, 'arc help'); if ($maybe) { $message .= "\n\n".pht('Did you mean:')."\n"; sort($maybe); diff --git a/src/configuration/ArcanistConfigurationManager.php b/src/configuration/ArcanistConfigurationManager.php index ef9b0b4f..6195a1ec 100644 --- a/src/configuration/ArcanistConfigurationManager.php +++ b/src/configuration/ArcanistConfigurationManager.php @@ -180,11 +180,13 @@ final class ArcanistConfigurationManager { } if ($mode & 0177) { // Mode should allow only owner access. - $prompt = "File permissions on your ~/.arcrc are too open. ". - "Fix them by chmod'ing to 600?"; + $prompt = pht( + "File permissions on your %s are too open. ". + "Fix them by chmod'ing to 600?", + '~/.arcrc'); if (!phutil_console_confirm($prompt, $default_no = false)) { throw new ArcanistUsageException( - 'Set ~/.arcrc to file mode 600.'); + pht('Set %s to file mode 600.', '~/.arcrc')); } execx('chmod 600 %s', $user_config_path); @@ -200,7 +202,7 @@ final class ArcanistConfigurationManager { $user_config = phutil_json_decode($user_config_data); } catch (PhutilJSONParserException $ex) { throw new PhutilProxyException( - "Your '~/.arcrc' file is not a valid JSON file.", + pht("Your '%s' file is not a valid JSON file.", '~/.arcrc'), $ex); } } else { @@ -236,7 +238,7 @@ final class ArcanistConfigurationManager { public function setUserConfigurationFileLocation($custom_arcrc) { if (!Filesystem::pathExists($custom_arcrc)) { throw new Exception( - 'Custom arcrc file was specified, but it was not found!'); + pht('Custom %s file was specified, but it was not found!', 'arcrc')); } $this->customArcrcFilename = $custom_arcrc; @@ -318,8 +320,12 @@ final class ArcanistConfigurationManager { foreach ($options as $opt) { $opt_config = preg_split('/=/', $opt, 2); if (count($opt_config) !== 2) { - throw new ArcanistUsageException("Argument was '{$opt}', but must be ". - "'name=value'. For example, history.immutable=true"); + throw new ArcanistUsageException( + pht( + "Argument was '%s', but must be '%s'. For example, %s", + $opt, + 'name=value', + 'history.immutable=true')); } list($key, $value) = $opt_config; diff --git a/src/configuration/ArcanistSettings.php b/src/configuration/ArcanistSettings.php index ad5f7626..b6ede180 100644 --- a/src/configuration/ArcanistSettings.php +++ b/src/configuration/ArcanistSettings.php @@ -86,7 +86,7 @@ final class ArcanistSettings { 'help' => pht( 'The name of the default branch to land changes onto when '. '`%s` is run.', - 'arc land'), + 'arc land'), 'example' => '"develop"', ), 'arc.land.update.default' => array( diff --git a/src/configuration/__tests__/ArcanistBritishTestCase.php b/src/configuration/__tests__/ArcanistBritishTestCase.php index 8a5dde39..53517e46 100644 --- a/src/configuration/__tests__/ArcanistBritishTestCase.php +++ b/src/configuration/__tests__/ArcanistBritishTestCase.php @@ -53,7 +53,7 @@ final class ArcanistBritishTestCase extends ArcanistTestCase { $this->assertEqual( $expect, $result, - "Correction of {$input} against: {$commands}"); + pht('Correction of %s against: %s', $input, $commands)); } public function testArgumentCompletion() { @@ -91,7 +91,7 @@ final class ArcanistBritishTestCase extends ArcanistTestCase { $this->assertEqual( $expect, $result, - "Correction of {$input} against: {$arguments}"); + pht('Correction of %s against: %s', $input, $arguments)); } } diff --git a/src/difference/ArcanistDiffUtils.php b/src/difference/ArcanistDiffUtils.php index c789cddc..f3486d6f 100644 --- a/src/difference/ArcanistDiffUtils.php +++ b/src/difference/ArcanistDiffUtils.php @@ -26,7 +26,7 @@ final class ArcanistDiffUtils { $diff_options = "-L 'Old Value' -L 'New Value'") { if ((string)$old === (string)$new) { - $new .= "\n(Old and new values are identical.)"; + $new .= "\n".pht('(Old and new values are identical.)'); } $file_old = new TempFile(); diff --git a/src/differential/constants/ArcanistDifferentialRevisionStatus.php b/src/differential/constants/ArcanistDifferentialRevisionStatus.php index 017000e9..62c3eec7 100644 --- a/src/differential/constants/ArcanistDifferentialRevisionStatus.php +++ b/src/differential/constants/ArcanistDifferentialRevisionStatus.php @@ -21,7 +21,7 @@ final class ArcanistDifferentialRevisionStatus { self::IN_PREPARATION => pht('In Preparation'), ); - return idx($map, coalesce($status, '?'), 'Unknown'); + return idx($map, coalesce($status, '?'), pht('Unknown')); } } diff --git a/src/exception/usage/ArcanistUserAbortException.php b/src/exception/usage/ArcanistUserAbortException.php index d1aa1ee1..f87951f7 100644 --- a/src/exception/usage/ArcanistUserAbortException.php +++ b/src/exception/usage/ArcanistUserAbortException.php @@ -7,7 +7,7 @@ final class ArcanistUserAbortException extends ArcanistUsageException { public function __construct() { - parent::__construct('User aborted the workflow.'); + parent::__construct(pht('User aborted the workflow.')); } } diff --git a/src/hgdaemon/ArcanistHgClientChannel.php b/src/hgdaemon/ArcanistHgClientChannel.php index a1c803a5..82ce3002 100644 --- a/src/hgdaemon/ArcanistHgClientChannel.php +++ b/src/hgdaemon/ArcanistHgClientChannel.php @@ -57,7 +57,7 @@ final class ArcanistHgClientChannel extends PhutilProtocolChannel { */ protected function encodeMessage($argv) { if (!is_array($argv) || count($argv) !== 2) { - throw new Exception('Message should be .'); + throw new Exception(pht('Message should be %s.', '')); } $channel = head($argv); diff --git a/src/hgdaemon/ArcanistHgProxyClient.php b/src/hgdaemon/ArcanistHgProxyClient.php index 62c32b41..86053fc4 100644 --- a/src/hgdaemon/ArcanistHgProxyClient.php +++ b/src/hgdaemon/ArcanistHgProxyClient.php @@ -163,7 +163,10 @@ final class ArcanistHgProxyClient { if ($errno || !$socket) { throw new Exception( - "Unable to connect socket! Error #{$errno}: {$errstr}"); + pht( + 'Unable to connect socket! Error #%d: %s', + $errno, + $errstr)); } $channel = new PhutilSocketChannel($socket); diff --git a/src/hgdaemon/ArcanistHgProxyServer.php b/src/hgdaemon/ArcanistHgProxyServer.php index a6e19a25..9a2e8eb0 100644 --- a/src/hgdaemon/ArcanistHgProxyServer.php +++ b/src/hgdaemon/ArcanistHgProxyServer.php @@ -168,7 +168,7 @@ final class ArcanistHgProxyServer { $hg = $this->startMercurialProcess(); $clients = array(); - $this->log(null, 'Listening'); + $this->log(null, pht('Listening')); $this->idleSince = time(); while (true) { // Wait for activity on any active clients, the Mercurial process, or @@ -181,7 +181,7 @@ final class ArcanistHgProxyServer { )); if (!$hg->update()) { - throw new Exception('Server exited unexpectedly!'); + throw new Exception(pht('Server exited unexpectedly!')); } // Accept any new clients. @@ -190,7 +190,7 @@ final class ArcanistHgProxyServer { $key = last_key($clients); $client->setName($key); - $this->log($client, 'Connected'); + $this->log($client, pht('Connected')); $this->idleSince = time(); // Check if we've hit the client limit. If there's a configured @@ -216,7 +216,7 @@ final class ArcanistHgProxyServer { continue; } - $this->log($client, 'Disconnected'); + $this->log($client, pht('Disconnected')); unset($clients[$key]); // If we have a client limit and we've served that many clients, exit. @@ -224,7 +224,7 @@ final class ArcanistHgProxyServer { if ($this->clientLimit) { if ($this->lifetimeClientCount >= $this->clientLimit) { if (!$clients) { - $this->log(null, 'Exiting (Client Limit)'); + $this->log(null, pht('Exiting (Client Limit)')); return; } } @@ -236,11 +236,11 @@ final class ArcanistHgProxyServer { if ($this->idleLimit) { $remaining = $this->idleLimit - (time() - $this->idleSince); if ($remaining <= 0) { - $this->log(null, 'Exiting (Idle Limit)'); + $this->log(null, pht('Exiting (Idle Limit)')); return; } if ($remaining <= 5) { - $this->log(null, 'Exiting in '.$remaining.' seconds'); + $this->log(null, pht('Exiting in %d seconds', $remaining)); } } } @@ -312,7 +312,7 @@ final class ArcanistHgProxyServer { // Log the elapsed time. $t_end = microtime(true); $t = 1000000 * ($t_end - $t_start); - $this->log($client, '< '.number_format($t, 0).'us'); + $this->log($client, pht('< %sus', number_format($t, 0))); $this->idleSince = time(); @@ -349,12 +349,15 @@ final class ArcanistHgProxyServer { if ($errno || !$socket) { throw new Exception( - "Unable to start socket! Error #{$errno}: {$errstr}"); + pht( + 'Unable to start socket! Error #%d: %s', + $errno, + $errstr)); } $ok = stream_set_blocking($socket, 0); if ($ok === false) { - throw new Exception('Unable to set socket nonblocking!'); + throw new Exception(pht('Unable to set socket nonblocking!')); } return $socket; @@ -438,9 +441,15 @@ final class ArcanistHgProxyServer { } if ($client) { - $message = '[Client '.$client->getName().'] '.$message; + $message = sprintf( + '[%s] %s', + pht('Client %s', $client->getName()), + $message); } else { - $message = '[Server] '.$message; + $message = sprintf( + '[%s] %s', + pht('Server'), + $message); } echo $message."\n"; @@ -461,7 +470,7 @@ final class ArcanistHgProxyServer { $pid = pcntl_fork(); if ($pid === -1) { - throw new Exception('Unable to fork!'); + throw new Exception(pht('Unable to fork!')); } else if ($pid) { // We're the parent; exit. First, drop our reference to the socket so // our __destruct() doesn't tear it down; the child will tear it down diff --git a/src/hgdaemon/ArcanistHgServerChannel.php b/src/hgdaemon/ArcanistHgServerChannel.php index b16f3bd1..1850c9af 100644 --- a/src/hgdaemon/ArcanistHgServerChannel.php +++ b/src/hgdaemon/ArcanistHgServerChannel.php @@ -86,7 +86,8 @@ final class ArcanistHgServerChannel extends PhutilProtocolChannel { */ protected function encodeMessage($argv) { if (!is_array($argv)) { - throw new Exception('Message to Mercurial server should be an array.'); + throw new Exception( + pht('Message to Mercurial server should be an array.')); } $command = head($argv); diff --git a/src/lint/ArcanistLintPatcher.php b/src/lint/ArcanistLintPatcher.php index 1cea8dc3..5bbd2503 100644 --- a/src/lint/ArcanistLintPatcher.php +++ b/src/lint/ArcanistLintPatcher.php @@ -49,8 +49,10 @@ final class ArcanistLintPatcher { list($err) = exec_manual('mv -f %s %s', $lint, $path); if ($err) { throw new Exception( - "Unable to overwrite path `{$path}', patched version was left ". - "at `{$lint}'."); + pht( + "Unable to overwrite path '%s', patched version was left at '%s'.", + $path, + $lint)); } foreach ($this->applyMessages as $message) { @@ -114,7 +116,7 @@ final class ArcanistLintPatcher { } if ($line_num >= count($this->lineOffsets)) { - throw new Exception("Data has fewer than `{$line}' lines."); + throw new Exception(pht('Data has fewer than %d lines.', $line)); } return idx($this->lineOffsets, $line_num); diff --git a/src/lint/ArcanistLintSeverity.php b/src/lint/ArcanistLintSeverity.php index c34756d9..a8da738e 100644 --- a/src/lint/ArcanistLintSeverity.php +++ b/src/lint/ArcanistLintSeverity.php @@ -13,11 +13,11 @@ final class ArcanistLintSeverity { public static function getLintSeverities() { return array( - self::SEVERITY_ADVICE => 'Advice', - self::SEVERITY_AUTOFIX => 'Auto-Fix', - self::SEVERITY_WARNING => 'Warning', - self::SEVERITY_ERROR => 'Error', - self::SEVERITY_DISABLED => 'Disabled', + self::SEVERITY_ADVICE => pht('Advice'), + self::SEVERITY_AUTOFIX => pht('Auto-Fix'), + self::SEVERITY_WARNING => pht('Warning'), + self::SEVERITY_ERROR => pht('Error'), + self::SEVERITY_DISABLED => pht('Disabled'), ); } @@ -25,7 +25,7 @@ final class ArcanistLintSeverity { $map = self::getLintSeverities(); if (!array_key_exists($severity_code, $map)) { - throw new Exception("Unknown lint severity '{$severity_code}'!"); + throw new Exception(pht("Unknown lint severity '%s'!", $severity_code)); } return $map[$severity_code]; diff --git a/src/lint/engine/ArcanistLintEngine.php b/src/lint/engine/ArcanistLintEngine.php index 29cf13d6..e320fc0c 100644 --- a/src/lint/engine/ArcanistLintEngine.php +++ b/src/lint/engine/ArcanistLintEngine.php @@ -168,7 +168,7 @@ abstract class ArcanistLintEngine { final public function run() { $linters = $this->buildLinters(); if (!$linters) { - throw new ArcanistNoEffectException('No linters to run.'); + throw new ArcanistNoEffectException(pht('No linters to run.')); } foreach ($linters as $key => $linter) { @@ -189,7 +189,7 @@ abstract class ArcanistLintEngine { } if (!$have_paths) { - throw new ArcanistNoEffectException('No paths are lintable.'); + throw new ArcanistNoEffectException(pht('No paths are lintable.')); } $versions = array($this->getCacheVersion()); @@ -272,7 +272,9 @@ abstract class ArcanistLintEngine { } if ($exceptions) { - throw new PhutilAggregateException('Some linters failed:', $exceptions); + throw new PhutilAggregateException( + pht('Some linters failed:'), + $exceptions); } return $this->results; diff --git a/src/lint/linter/ArcanistBaseXHPASTLinter.php b/src/lint/linter/ArcanistBaseXHPASTLinter.php index a6279745..3549a353 100644 --- a/src/lint/linter/ArcanistBaseXHPASTLinter.php +++ b/src/lint/linter/ArcanistBaseXHPASTLinter.php @@ -132,8 +132,9 @@ abstract class ArcanistBaseXHPASTLinter extends ArcanistFutureLinter { throw new Exception( pht( 'Imbalanced calls to shared futures: each call to '. - 'buildSharedFutures() for a path must be paired with a call to '. - 'releaseSharedFutures().')); + '%s for a path must be paired with a call to %s.', + 'buildSharedFutures()', + 'releaseSharedFutures()')); } $this->refcount[$path]--; diff --git a/src/lint/linter/ArcanistCSharpLinter.php b/src/lint/linter/ArcanistCSharpLinter.php index 89c1f632..6120a07b 100644 --- a/src/lint/linter/ArcanistCSharpLinter.php +++ b/src/lint/linter/ArcanistCSharpLinter.php @@ -62,12 +62,14 @@ final class ArcanistCSharpLinter extends ArcanistLinter { foreach ($map as $code => $severity) { if (substr($code, 0, 2) === 'SA' && $severity == 'disabled') { throw new Exception( - "In order to keep StyleCop integration with IDEs and other tools ". - "consistent with Arcanist results, you aren't permitted to ". - "disable StyleCop rules within '.arclint'. ". - "Instead configure the severity using the StyleCop settings dialog ". - "(usually accessible from within your IDE). StyleCop settings ". - "for your project will be used when linting for Arcanist."); + pht( + "In order to keep StyleCop integration with IDEs and other tools ". + "consistent with Arcanist results, you aren't permitted to ". + "disable StyleCop rules within '%s'. Instead configure the ". + "severity using the StyleCop settings dialog (usually accessible ". + "from within your IDE). StyleCop settings for your project will ". + "be used when linting for Arcanist.", + '.arclint')); } } return parent::setCustomSeverityMap($map); @@ -92,7 +94,8 @@ final class ArcanistCSharpLinter extends ArcanistLinter { } else if (Filesystem::binaryExists('mono')) { $this->runtimeEngine = 'mono '; } else { - throw new Exception('Unable to find Mono and you are not on Windows!'); + throw new Exception( + pht('Unable to find Mono and you are not on Windows!')); } // Determine cslint path. @@ -102,7 +105,7 @@ final class ArcanistCSharpLinter extends ArcanistLinter { } else if (Filesystem::binaryExists('cslint.exe')) { $this->cslintEngine = 'cslint.exe'; } else { - throw new Exception('Unable to locate cslint.'); + throw new Exception(pht('Unable to locate %s.', 'cslint')); } // Determine cslint version. @@ -112,18 +115,27 @@ final class ArcanistCSharpLinter extends ArcanistLinter { list($err, $stdout, $stderr) = $ver_future->resolve(); if ($err !== 0) { throw new Exception( - 'You are running an old version of cslint. Please '. - 'upgrade to version '.self::SUPPORTED_VERSION.'.'); + pht( + 'You are running an old version of %s. Please '. + 'upgrade to version %s.', + 'cslint', + self::SUPPORTED_VERSION)); } $ver = (int)$stdout; if ($ver < self::SUPPORTED_VERSION) { throw new Exception( - 'You are running an old version of cslint. Please '. - 'upgrade to version '.self::SUPPORTED_VERSION.'.'); + pht( + 'You are running an old version of %s. Please '. + 'upgrade to version %s.', + 'cslint', + self::SUPPORTED_VERSION)); } else if ($ver > self::SUPPORTED_VERSION) { throw new Exception( - 'Arcanist does not support this version of cslint (it is '. - 'newer). You can try upgrading Arcanist with `arc upgrade`.'); + pht( + 'Arcanist does not support this version of %s (it is newer). '. + 'You can try upgrading Arcanist with `%s`.', + 'cslint', + 'arc upgrade')); } $this->loaded = true; diff --git a/src/lint/linter/ArcanistCppcheckLinter.php b/src/lint/linter/ArcanistCppcheckLinter.php index 830452a5..d5df5acb 100644 --- a/src/lint/linter/ArcanistCppcheckLinter.php +++ b/src/lint/linter/ArcanistCppcheckLinter.php @@ -14,7 +14,9 @@ final class ArcanistCppcheckLinter extends ArcanistExternalLinter { } public function getInfoDescription() { - return pht('Use `cppcheck` to perform static analysis on C/C++ code.'); + return pht( + 'Use `%s` to perform static analysis on C/C++ code.', + 'cppcheck'); } public function getLinterName() { @@ -49,7 +51,9 @@ final class ArcanistCppcheckLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install Cppcheck using `apt-get install cppcheck` or similar.'); + return pht( + 'Install Cppcheck using `%s` or similar.', + 'apt-get install cppcheck'); } protected function getMandatoryFlags() { diff --git a/src/lint/linter/ArcanistCpplintLinter.php b/src/lint/linter/ArcanistCpplintLinter.php index 7d8b4bbc..3587131d 100644 --- a/src/lint/linter/ArcanistCpplintLinter.php +++ b/src/lint/linter/ArcanistCpplintLinter.php @@ -25,8 +25,10 @@ final class ArcanistCpplintLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install cpplint.py using `wget http://google-styleguide.'. - 'googlecode.com/svn/trunk/cpplint/cpplint.py`.'); + return pht( + 'Install cpplint.py using `%s`.', + 'wget http://google-styleguide.googlecode.com'. + '/svn/trunk/cpplint/cpplint.py'); } protected function getDefaultFlags() { diff --git a/src/lint/linter/ArcanistFlake8Linter.php b/src/lint/linter/ArcanistFlake8Linter.php index 6c1c6d6f..4cdab661 100644 --- a/src/lint/linter/ArcanistFlake8Linter.php +++ b/src/lint/linter/ArcanistFlake8Linter.php @@ -16,8 +16,9 @@ final class ArcanistFlake8Linter extends ArcanistExternalLinter { public function getInfoDescription() { return pht( - 'Uses `flake8` to run several linters (PyFlakes, pep8, and a McCabe '. - 'complexity checker) on Python source files.'); + 'Uses `%s` to run several linters (PyFlakes, pep8, and a McCabe '. + 'complexity checker) on Python source files.', + 'flake8'); } public function getLinterName() { @@ -55,7 +56,7 @@ final class ArcanistFlake8Linter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install flake8 using `easy_install flake8`.'); + return pht('Install flake8 using `%s`.', 'easy_install flake8'); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { diff --git a/src/lint/linter/ArcanistGeneratedLinter.php b/src/lint/linter/ArcanistGeneratedLinter.php index 29c1e809..4d01bca7 100644 --- a/src/lint/linter/ArcanistGeneratedLinter.php +++ b/src/lint/linter/ArcanistGeneratedLinter.php @@ -11,8 +11,8 @@ final class ArcanistGeneratedLinter extends ArcanistLinter { public function getInfoDescription() { return pht( - 'Disables lint for files that are marked as "%s", indicating that they '. - 'contain generated code.', + 'Disables lint for files that are marked as "%s", '. + 'indicating that they contain generated code.', '@'.'generated'); } diff --git a/src/lint/linter/ArcanistGoLintLinter.php b/src/lint/linter/ArcanistGoLintLinter.php index e886e05c..0252d4c9 100644 --- a/src/lint/linter/ArcanistGoLintLinter.php +++ b/src/lint/linter/ArcanistGoLintLinter.php @@ -27,7 +27,9 @@ final class ArcanistGoLintLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install Golint using `go get github.com/golang/lint/golint`.'); + return pht( + 'Install Golint using `%s`.', + 'go get github.com/golang/lint/golint'); } public function shouldExpectCommandErrors() { diff --git a/src/lint/linter/ArcanistHLintLinter.php b/src/lint/linter/ArcanistHLintLinter.php index 6274e045..5a197ce4 100644 --- a/src/lint/linter/ArcanistHLintLinter.php +++ b/src/lint/linter/ArcanistHLintLinter.php @@ -30,7 +30,7 @@ final class ArcanistHLintLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install hlint with `cabal install hlint`.'); + return pht('Install hlint with `%s`.', 'cabal install hlint'); } protected function getMandatoryFlags() { @@ -50,7 +50,6 @@ final class ArcanistHLintLinter extends ArcanistExternalLinter { } protected function parseLinterOutput($path, $err, $stdout, $stderr) { - $json = phutil_json_decode($stdout); $messages = array(); foreach ($json as $fix) { @@ -71,13 +70,17 @@ final class ArcanistHLintLinter extends ArcanistExternalLinter { all necessary notes too. */ $notes = ''; foreach ($fix['note'] as $note) { - $notes .= ' **NOTE**: '.trim($note, '"').'.'; + $notes .= phutil_console_format( + ' **%s**: %s.', + pht('NOTE'), + trim($note, '"')); } $message->setDescription( pht( - 'In module `%s`, declaration `%s`.%s', - $fix['module'], $fix['decl'], $notes)); + 'In module `%s`, declaration `%s`.', + $fix['module'], + $fix['decl']).$notes); switch ($fix['severity']) { case 'Error': diff --git a/src/lint/linter/ArcanistJSHintLinter.php b/src/lint/linter/ArcanistJSHintLinter.php index 76efca9d..f175a144 100644 --- a/src/lint/linter/ArcanistJSHintLinter.php +++ b/src/lint/linter/ArcanistJSHintLinter.php @@ -17,7 +17,9 @@ final class ArcanistJSHintLinter extends ArcanistExternalLinter { } public function getInfoDescription() { - return pht('Use `jshint` to detect issues with JavaScript source files.'); + return pht( + 'Use `%s` to detect issues with JavaScript source files.', + 'jshint'); } public function getLinterName() { @@ -70,7 +72,7 @@ final class ArcanistJSHintLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install JSHint using `npm install -g jshint`.'); + return pht('Install JSHint using `%s`.', 'npm install -g jshint'); } protected function getMandatoryFlags() { diff --git a/src/lint/linter/ArcanistJSONLintLinter.php b/src/lint/linter/ArcanistJSONLintLinter.php index b4a65bdf..2ac0dbbe 100644 --- a/src/lint/linter/ArcanistJSONLintLinter.php +++ b/src/lint/linter/ArcanistJSONLintLinter.php @@ -14,7 +14,7 @@ final class ArcanistJSONLintLinter extends ArcanistExternalLinter { } public function getInfoDescription() { - return pht('Use `jsonlint` to detect syntax errors in JSON files.'); + return pht('Use `%s` to detect syntax errors in JSON files.', 'jsonlint'); } public function getLinterName() { @@ -44,7 +44,7 @@ final class ArcanistJSONLintLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install jsonlint using `npm install -g jsonlint`.'); + return pht('Install jsonlint using `%s`.', 'npm install -g jsonlint'); } protected function getMandatoryFlags() { diff --git a/src/lint/linter/ArcanistJscsLinter.php b/src/lint/linter/ArcanistJscsLinter.php index cc037214..6d8f2537 100644 --- a/src/lint/linter/ArcanistJscsLinter.php +++ b/src/lint/linter/ArcanistJscsLinter.php @@ -14,7 +14,9 @@ final class ArcanistJscsLinter extends ArcanistExternalLinter { } public function getInfoDescription() { - return pht('Use `jscs` to detect issues with Javascript source files.'); + return pht( + 'Use `%s` to detect issues with Javascript source files.', + 'jscs'); } public function getLinterName() { @@ -42,7 +44,7 @@ final class ArcanistJscsLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install JSCS using `npm install -g jscs`.'); + return pht('Install JSCS using `%s`.', 'npm install -g jscs'); } protected function getMandatoryFlags() { @@ -66,7 +68,7 @@ final class ArcanistJscsLinter extends ArcanistExternalLinter { $options = array( 'jscs.config' => array( 'type' => 'optional string', - 'help' => pht('Pass in a custom jscsrc file path.'), + 'help' => pht('Pass in a custom %s file path.', 'jscsrc'), ), 'jscs.preset' => array( 'type' => 'optional string', diff --git a/src/lint/linter/ArcanistLesscLinter.php b/src/lint/linter/ArcanistLesscLinter.php index 5516540b..f51660e2 100644 --- a/src/lint/linter/ArcanistLesscLinter.php +++ b/src/lint/linter/ArcanistLesscLinter.php @@ -20,7 +20,7 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter { private $strictUnits = false; public function getInfoName() { - return pht('Less'); + return 'Less'; } public function getInfoURI() { @@ -29,8 +29,10 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter { public function getInfoDescription() { return pht( - 'Use the `--lint` mode provided by `lessc` to detect errors in Less '. - 'source files.'); + 'Use the `%s` mode provided by `%s` to detect errors in '. + 'Less source files.', + '--lint', + 'lessc'); } public function getLinterName() { @@ -98,7 +100,7 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install lessc using `npm install -g less`.'); + return pht('Install lessc using `%s`.', 'npm install -g less'); } protected function getMandatoryFlags() { @@ -154,9 +156,10 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter { break; default: - throw new RuntimeException(pht( - 'Unrecognized lint message code "%s".', - $code)); + throw new RuntimeException( + pht( + 'Unrecognized lint message code "%s".', + $code)); } $code = $this->getLintCodeFromLinterConfigurationKey($matches['name']); diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php index 41e27c1c..aae1fbbd 100644 --- a/src/lint/linter/ArcanistLinter.php +++ b/src/lint/linter/ArcanistLinter.php @@ -382,7 +382,7 @@ abstract class ArcanistLinter { if (isset($map[$code])) { return $map[$code]; } - return 'Unknown lint message!'; + return pht('Unknown lint message!'); } final protected function addLintMessage(ArcanistLintMessage $message) { @@ -511,10 +511,10 @@ abstract class ArcanistLinter { public function setLinterConfigurationValue($key, $value) { $sev_map = array( - 'error' => ArcanistLintSeverity::SEVERITY_ERROR, - 'warning' => ArcanistLintSeverity::SEVERITY_WARNING, - 'autofix' => ArcanistLintSeverity::SEVERITY_AUTOFIX, - 'advice' => ArcanistLintSeverity::SEVERITY_ADVICE, + 'error' => ArcanistLintSeverity::SEVERITY_ERROR, + 'warning' => ArcanistLintSeverity::SEVERITY_WARNING, + 'autofix' => ArcanistLintSeverity::SEVERITY_AUTOFIX, + 'advice' => ArcanistLintSeverity::SEVERITY_ADVICE, 'disabled' => ArcanistLintSeverity::SEVERITY_DISABLED, ); @@ -566,7 +566,7 @@ abstract class ArcanistLinter { return; } - throw new Exception("Incomplete implementation: {$key}!"); + throw new Exception(pht('Incomplete implementation: %s!', $key)); } protected function canCustomizeLintSeverities() { @@ -637,9 +637,10 @@ abstract class ArcanistLinter { pht('Deprecation Warning'), pht( 'Configuration option "%s" is deprecated. Generally, linters should '. - 'now be configured using an `.arclint` file. See "Arcanist User '. + 'now be configured using an `%s` file. See "Arcanist User '. 'Guide: Lint" in the documentation for more information.', - $key)); + $key, + '.arclint')); return $result; } diff --git a/src/lint/linter/ArcanistPEP8Linter.php b/src/lint/linter/ArcanistPEP8Linter.php index 03811358..984e64bf 100644 --- a/src/lint/linter/ArcanistPEP8Linter.php +++ b/src/lint/linter/ArcanistPEP8Linter.php @@ -67,7 +67,7 @@ final class ArcanistPEP8Linter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install PEP8 using `easy_install pep8`.'); + return pht('Install PEP8 using `%s`.', 'easy_install pep8'); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { diff --git a/src/lint/linter/ArcanistPhpLinter.php b/src/lint/linter/ArcanistPhpLinter.php index bd6b8222..c272305e 100644 --- a/src/lint/linter/ArcanistPhpLinter.php +++ b/src/lint/linter/ArcanistPhpLinter.php @@ -94,7 +94,7 @@ final class ArcanistPhpLinter extends ArcanistExternalLinter { return self::LINT_FATAL_ERROR; default: - throw new Exception(pht('Unrecognized lint message code "%s"', $code)); + throw new Exception(pht('Unrecognized lint message code: "%s"', $code)); } } diff --git a/src/lint/linter/ArcanistPhpcsLinter.php b/src/lint/linter/ArcanistPhpcsLinter.php index 68d4d7f3..f05df5c5 100644 --- a/src/lint/linter/ArcanistPhpcsLinter.php +++ b/src/lint/linter/ArcanistPhpcsLinter.php @@ -30,7 +30,7 @@ final class ArcanistPhpcsLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install PHPCS with `pear install PHP_CodeSniffer`.'); + return pht('Install PHPCS with `%s`.', 'pear install PHP_CodeSniffer'); } public function getLinterConfigurationOptions() { @@ -152,7 +152,10 @@ final class ArcanistPhpcsLinter extends ArcanistExternalLinter { protected function getLintCodeFromLinterConfigurationKey($code) { if (!preg_match('/^PHPCS\\.(E|W)\\./', $code)) { throw new Exception( - "Invalid severity code '{$code}', should begin with 'PHPCS.'."); + pht( + "Invalid severity code '%s', should begin with '%s.'.", + $code, + 'PHPCS')); } return $code; } diff --git a/src/lint/linter/ArcanistPhutilXHPASTLinter.php b/src/lint/linter/ArcanistPhutilXHPASTLinter.php index 50897d53..69d1ba86 100644 --- a/src/lint/linter/ArcanistPhutilXHPASTLinter.php +++ b/src/lint/linter/ArcanistPhutilXHPASTLinter.php @@ -39,16 +39,13 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter { public function getLintNameMap() { return array( self::LINT_ARRAY_COMBINE => pht( - '%s Unreliable', - 'array_combine()'), + '%s Unreliable', 'array_combine()'), self::LINT_DEPRECATED_FUNCTION => pht( 'Use of Deprecated Function'), self::LINT_UNSAFE_DYNAMIC_STRING => pht( 'Unsafe Usage of Dynamic String'), self::LINT_RAGGED_CLASSTREE_EDGE => pht( - 'Class Not %s Or %s', - 'abstract', - 'final'), + 'Class Not %s Or %s', 'abstract', 'final'), ); } diff --git a/src/lint/linter/ArcanistPyFlakesLinter.php b/src/lint/linter/ArcanistPyFlakesLinter.php index 59d91995..b88a3322 100644 --- a/src/lint/linter/ArcanistPyFlakesLinter.php +++ b/src/lint/linter/ArcanistPyFlakesLinter.php @@ -50,7 +50,7 @@ final class ArcanistPyFlakesLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install pyflakes with `pip install pyflakes`.'); + return pht('Install pyflakes with `%s`.', 'pip install pyflakes'); } protected function parseLinterOutput($path, $err, $stdout, $stderr) { diff --git a/src/lint/linter/ArcanistPyLintLinter.php b/src/lint/linter/ArcanistPyLintLinter.php index 45ebf37f..ce1c60de 100644 --- a/src/lint/linter/ArcanistPyLintLinter.php +++ b/src/lint/linter/ArcanistPyLintLinter.php @@ -63,10 +63,13 @@ final class ArcanistPyLintLinter extends ArcanistLinter { if (!$error_regexp && !$warning_regexp && !$advice_regexp) { throw new ArcanistUsageException( - "You are invoking the PyLint linter but have not configured any of ". - "'lint.pylint.codes.error', 'lint.pylint.codes.warning', or ". - "'lint.pylint.codes.advice'. Consult the documentation for ". - "ArcanistPyLintLinter."); + pht( + "You are invoking the PyLint linter but have not configured any of ". + "'%s', '%s', or '%s'. Consult the documentation for %s.", + 'lint.pylint.codes.error', + 'lint.pylint.codes.warning', + 'lint.pylint.codes.advice', + __CLASS__)); } $code_map = array( @@ -109,10 +112,13 @@ final class ArcanistPyLintLinter extends ArcanistLinter { list($err) = exec_manual('which %s', $pylint_bin); if ($err) { throw new ArcanistMissingLinterException( - "PyLint does not appear to be installed on this system. Install it ". - "(e.g., with 'sudo easy_install pylint') or configure ". - "'lint.pylint.prefix' in your .arcconfig to point to the directory ". - "where it resides."); + pht( + "PyLint does not appear to be installed on this system. Install ". + "it (e.g., with '%s') or configure '%s' in your %s to point to ". + "the directory where it resides.", + 'sudo easy_install pylint', + 'lint.pylint.prefix', + '.arcconfig')); } } diff --git a/src/lint/linter/ArcanistRuboCopLinter.php b/src/lint/linter/ArcanistRuboCopLinter.php index 0647a7bc..c7585ca6 100644 --- a/src/lint/linter/ArcanistRuboCopLinter.php +++ b/src/lint/linter/ArcanistRuboCopLinter.php @@ -99,9 +99,9 @@ final class ArcanistRuboCopLinter extends ArcanistExternalLinter { return $messages; } - /* - Take the string from RuboCop's severity terminology and return an - ArcanistLintSeverity + /** + * Take the string from RuboCop's severity terminology and return an + * @{class:ArcanistLintSeverity}. */ protected function getDefaultMessageSeverity($code) { switch ($code) { diff --git a/src/lint/linter/ArcanistRubyLinter.php b/src/lint/linter/ArcanistRubyLinter.php index b2d76567..fb8ed25e 100644 --- a/src/lint/linter/ArcanistRubyLinter.php +++ b/src/lint/linter/ArcanistRubyLinter.php @@ -14,7 +14,9 @@ final class ArcanistRubyLinter extends ArcanistExternalLinter { } public function getInfoDescription() { - return pht('Use `ruby` to check for syntax errors in Ruby source files.'); + return pht( + 'Use `%s` to check for syntax errors in Ruby source files.', + 'ruby'); } public function getLinterName() { @@ -47,7 +49,7 @@ final class ArcanistRubyLinter extends ArcanistExternalLinter { } public function getInstallInstructions() { - return pht('Install `ruby` from .'); + return pht('Install `%s` from <%s>.', 'ruby', 'http://www.ruby-lang.org/'); } protected function getMandatoryFlags() { diff --git a/src/lint/linter/ArcanistScriptAndRegexLinter.php b/src/lint/linter/ArcanistScriptAndRegexLinter.php index c2422f47..8e8a1f5c 100644 --- a/src/lint/linter/ArcanistScriptAndRegexLinter.php +++ b/src/lint/linter/ArcanistScriptAndRegexLinter.php @@ -256,7 +256,7 @@ final class ArcanistScriptAndRegexLinter extends ArcanistLinter { 'code' => idx($match, 'code', $this->getLinterName()), 'severity' => $this->getMatchSeverity($match), 'name' => idx($match, 'name', 'Lint'), - 'description' => idx($match, 'message', 'Undefined Lint Message'), + 'description' => idx($match, 'message', pht('Undefined Lint Message')), ); $original = idx($match, 'original'); diff --git a/src/lint/linter/ArcanistXMLLinter.php b/src/lint/linter/ArcanistXMLLinter.php index a1274861..b48b19bc 100644 --- a/src/lint/linter/ArcanistXMLLinter.php +++ b/src/lint/linter/ArcanistXMLLinter.php @@ -45,7 +45,7 @@ final class ArcanistXMLLinter extends ArcanistLinter { ->setLine($error->line) ->setChar($error->column ? $error->column : null) ->setCode($this->getLintMessageFullCode($error->code)) - ->setName('LibXML Error') + ->setName(pht('LibXML Error')) ->setDescription(trim($error->message)); switch ($error->level) { diff --git a/src/lint/linter/__tests__/ArcanistCppcheckLinterTestCase.php b/src/lint/linter/__tests__/ArcanistCppcheckLinterTestCase.php index 75310761..8bf305b7 100644 --- a/src/lint/linter/__tests__/ArcanistCppcheckLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistCppcheckLinterTestCase.php @@ -4,7 +4,7 @@ final class ArcanistCppcheckLinterTestCase extends ArcanistExternalLinterTestCase { public function testLinter() { - return $this->executeTestsInDirectory(dirname(__FILE__).'/cppcheck/'); + $this->executeTestsInDirectory(dirname(__FILE__).'/cppcheck/'); } } diff --git a/src/lint/linter/__tests__/ArcanistCpplintLinterTestCase.php b/src/lint/linter/__tests__/ArcanistCpplintLinterTestCase.php index f178bb9f..7aef6db1 100644 --- a/src/lint/linter/__tests__/ArcanistCpplintLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistCpplintLinterTestCase.php @@ -4,7 +4,7 @@ final class ArcanistCpplintLinterTestCase extends ArcanistExternalLinterTestCase { public function testLinter() { - return $this->executeTestsInDirectory(dirname(__FILE__).'/cpplint/'); + $this->executeTestsInDirectory(dirname(__FILE__).'/cpplint/'); } } diff --git a/src/lint/linter/__tests__/ArcanistLinterTestCase.php b/src/lint/linter/__tests__/ArcanistLinterTestCase.php index 322dca7f..738269ae 100644 --- a/src/lint/linter/__tests__/ArcanistLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistLinterTestCase.php @@ -47,7 +47,10 @@ abstract class ArcanistLinterTestCase extends ArcanistPhutilTestCase { $this->assertTrue( ($test_count > 0), - pht('Expected to find some .lint-test tests in directory %s!', $root)); + pht( + 'Expected to find some %s tests in directory %s!', + '.lint-test', + $root)); } private function lintFile($file, ArcanistLinter $linter) { diff --git a/src/lint/linter/__tests__/ArcanistNoLintLinterTestCase.php b/src/lint/linter/__tests__/ArcanistNoLintLinterTestCase.php index dab24b2d..0c4cbd8d 100644 --- a/src/lint/linter/__tests__/ArcanistNoLintLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistNoLintLinterTestCase.php @@ -3,7 +3,7 @@ final class ArcanistNoLintLinterTestCase extends ArcanistLinterTestCase { public function testLinter() { - return $this->executeTestsInDirectory(dirname(__FILE__).'/nolint/'); + $this->executeTestsInDirectory(dirname(__FILE__).'/nolint/'); } } diff --git a/src/lint/linter/__tests__/ArcanistPhutilXHPASTLinterTestCase.php b/src/lint/linter/__tests__/ArcanistPhutilXHPASTLinterTestCase.php index 824b1b74..d773e1f5 100644 --- a/src/lint/linter/__tests__/ArcanistPhutilXHPASTLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistPhutilXHPASTLinterTestCase.php @@ -5,7 +5,7 @@ final class ArcanistPhutilXHPASTLinterTestCase extends ArcanistLinterTestCase { public function testLinter() { $linter = new ArcanistPhutilXHPASTLinter(); $linter->setDeprecatedFunctions(array( - 'deprecated_function' => 'This function is most likely deprecated.', + 'deprecated_function' => pht('This function is most likely deprecated.'), )); $this->executeTestsInDirectory(dirname(__FILE__).'/phlxhp/', $linter); diff --git a/src/lint/linter/__tests__/ArcanistPyLintLinterTestCase.php b/src/lint/linter/__tests__/ArcanistPyLintLinterTestCase.php index 4d93f648..bbff142b 100644 --- a/src/lint/linter/__tests__/ArcanistPyLintLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistPyLintLinterTestCase.php @@ -4,7 +4,7 @@ final class ArcanistPyLintLinterTestCase extends ArcanistExternalLinterTestCase { public function testLinter() { - return $this->executeTestsInDirectory(dirname(__FILE__).'/pylint/'); + $this->executeTestsInDirectory(dirname(__FILE__).'/pylint/'); } } diff --git a/src/lint/renderer/ArcanistConsoleLintRenderer.php b/src/lint/renderer/ArcanistConsoleLintRenderer.php index b1c32a51..6f3476b0 100644 --- a/src/lint/renderer/ArcanistConsoleLintRenderer.php +++ b/src/lint/renderer/ArcanistConsoleLintRenderer.php @@ -44,7 +44,9 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer { idx($location, 'path', $path). (!empty($location['line']) ? ":{$location['line']}" : ''); } - $description .= "\nOther locations: ".implode(', ', $locations); + $description .= "\n".pht( + 'Other locations: %s', + implode(', ', $locations)); } $text[] = phutil_console_format( @@ -60,7 +62,11 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer { } if ($text) { - $prefix = phutil_console_format("**>>>** Lint for __%s__:\n\n\n", $path); + $prefix = phutil_console_format( + "**>>>** %s\n\n\n", + pht( + 'Lint for %s:', + phutil_console_format('__%s__', $path))); return $prefix.implode("\n", $text); } else { return null; @@ -234,7 +240,9 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer { public function renderOkayResult() { return phutil_console_format( - "** OKAY ** No lint warnings.\n"); + "** %s ** %s\n", + pht('OKAY'), + pht('No lint warnings.')); } } diff --git a/src/lint/renderer/ArcanistSummaryLintRenderer.php b/src/lint/renderer/ArcanistSummaryLintRenderer.php index c7837494..92eed3a4 100644 --- a/src/lint/renderer/ArcanistSummaryLintRenderer.php +++ b/src/lint/renderer/ArcanistSummaryLintRenderer.php @@ -24,7 +24,9 @@ final class ArcanistSummaryLintRenderer extends ArcanistLintRenderer { public function renderOkayResult() { return phutil_console_format( - "** OKAY ** No lint warnings.\n"); + "** %s ** %s\n", + pht('OKAY'), + pht('No lint warnings.')); } } diff --git a/src/parser/ArcanistBaseCommitParser.php b/src/parser/ArcanistBaseCommitParser.php index 7927f6b6..a546b702 100644 --- a/src/parser/ArcanistBaseCommitParser.php +++ b/src/parser/ArcanistBaseCommitParser.php @@ -22,8 +22,10 @@ final class ArcanistBaseCommitParser { foreach ($spec as $rule) { if (strpos($rule, ':') === false) { throw new ArcanistUsageException( - "Rule '{$rule}' is invalid, it must have a type and name like ". - "'arc:upstream'."); + pht( + "Rule '%s' is invalid, it must have a type and name like '%s'.", + $rule, + 'arc:upstream')); } } @@ -61,16 +63,16 @@ final class ArcanistBaseCommitParser { $source = head($this->try); if (!idx($specs, $source)) { - $this->log("No rules left from source '{$source}'."); + $this->log(pht("No rules left from source '%s'.", $source)); array_shift($this->try); continue; } - $this->log("Trying rules from source '{$source}'."); + $this->log(pht("Trying rules from source '%s'.", $source)); $rules = &$specs[$source]; while ($rule = array_shift($rules)) { - $this->log("Trying rule '{$rule}'."); + $this->log(pht("Trying rule '%s'.", $rule)); $commit = $this->resolveRule($rule, $source); @@ -78,7 +80,10 @@ final class ArcanistBaseCommitParser { // If a rule returns false, it means to go to the next ruleset. break; } else if ($commit !== null) { - $this->log("Resolved commit '{$commit}' from rule '{$rule}'."); + $this->log(pht( + "Resolved commit '%s' from rule '%s'.", + $commit, + $rule)); return $commit; } } @@ -105,8 +110,11 @@ final class ArcanistBaseCommitParser { return $this->resolveArcRule($rule, $name, $source); default: throw new ArcanistUsageException( - "Base commit rule '{$rule}' (from source '{$source}') ". - "is not a recognized rule."); + pht( + "Base commit rule '%s' (from source '%s') ". + "is not a recognized rule.", + $rule, + $source)); } } @@ -120,12 +128,12 @@ final class ArcanistBaseCommitParser { switch ($name) { case 'verbose': $this->verbose = true; - $this->log('Enabled verbose mode.'); + $this->log(pht('Enabled verbose mode.')); break; case 'prompt': - $reason = 'it is what you typed when prompted.'; + $reason = pht('it is what you typed when prompted.'); $this->api->setBaseCommitExplanation($reason); - return phutil_console_prompt('Against which commit?'); + return phutil_console_prompt(pht('Against which commit?')); case 'local': case 'user': case 'project': @@ -133,17 +141,17 @@ final class ArcanistBaseCommitParser { case 'system': // Push the other source on top of the list. array_unshift($this->try, $name); - $this->log("Switching to source '{$name}'."); + $this->log(pht("Switching to source '%s'.", $name)); return false; case 'yield': // Cycle this source to the end of the list. $this->try[] = array_shift($this->try); - $this->log("Yielding processing of rules from '{$source}'."); + $this->log(pht("Yielding processing of rules from '%s'.", $source)); return false; case 'halt': // Dump the whole stack. $this->try = array(); - $this->log('Halting all rule processing.'); + $this->log(pht('Halting all rule processing.')); return false; case 'skip': return null; @@ -171,8 +179,11 @@ final class ArcanistBaseCommitParser { } throw new ArcanistUsageException( - "Base commit rule '{$rule}' (from source '{$source}') ". - "is not a recognized rule."); + pht( + "Base commit rule '%s' (from source '%s') ". + "is not a recognized rule.", + $rule, + $source)); } } @@ -183,7 +194,7 @@ final class ArcanistBaseCommitParser { ); $new_name = idx($updated, $name); if ($new_name) { - $this->log("translating legacy name '$name' to '$new_name'"); + $this->log(pht("Translating legacy name '%s' to '%s'", $name, $new_name)); return $new_name; } return $name; diff --git a/src/parser/ArcanistBundle.php b/src/parser/ArcanistBundle.php index 79bb574c..7324b8ea 100644 --- a/src/parser/ArcanistBundle.php +++ b/src/parser/ArcanistBundle.php @@ -124,7 +124,7 @@ final class ArcanistBundle { return phutil_is_windows() ? "\r\n" : "\n"; default: throw new Exception( - "Unknown patch type '{$patch_type}'!"); + pht("Unknown patch type '%s'!", $patch_type)); } } @@ -373,7 +373,9 @@ final class ArcanistBundle { if (!$decompose_okay) { throw new Exception( - 'Failed to decompose multicopy changeset in order to generate diff.'); + pht( + 'Failed to decompose multicopy changeset in '. + 'order to generate diff.')); } } @@ -687,9 +689,11 @@ final class ArcanistBundle { if ($this->conduit) { if ($name) { - $console->writeErr("Downloading binary data for '%s'...\n", $name); + $console->writeErr( + "%s\n", + pht("Downloading binary data for '%s'...", $name)); } else { - $console->writeErr("Downloading binary data...\n"); + $console->writeErr("%s\n", pht('Downloading binary data...')); } $data_base64 = $this->conduit->callMethodSynchronous( 'file.download', @@ -699,7 +703,7 @@ final class ArcanistBundle { return base64_decode($data_base64); } - throw new Exception("Nowhere to load blob '{$phid}' from!"); + throw new Exception(pht("Nowhere to load blob '%s' from!", $phid)); } private function buildBinaryChange(ArcanistDiffChange $change, $old_binary) { @@ -773,9 +777,10 @@ final class ArcanistBundle { if (!function_exists('gzcompress')) { throw new Exception( - 'This patch has binary data. The PHP zlib extension is required to '. - 'apply patches with binary data to git. Install the PHP zlib '. - 'extension to continue.'); + pht( + 'This patch has binary data. The PHP zlib extension is required to '. + 'apply patches with binary data to git. Install the PHP zlib '. + 'extension to continue.')); } // See emit_binary_diff_body() in diff.c for git's implementation. diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php index bbe01d0f..0e9627b7 100644 --- a/src/parser/ArcanistDiffParser.php +++ b/src/parser/ArcanistDiffParser.php @@ -165,7 +165,7 @@ final class ArcanistDiffParser { $origin->setType(ArcanistDiffChangeType::TYPE_COPY_AWAY); break; default: - throw new Exception("Bad origin state {$type}."); + throw new Exception(pht('Bad origin state %s.', $type)); } $type = $origin->getType(); @@ -179,7 +179,7 @@ final class ArcanistDiffParser { $change->setType(ArcanistDiffChangeType::TYPE_COPY_HERE); break; default: - throw new Exception("Bad origin state {$type}."); + throw new Exception(pht('Bad origin state %s.', $type)); } } @@ -188,7 +188,7 @@ final class ArcanistDiffParser { public function parseDiff($diff) { if (!strlen(trim($diff))) { - throw new Exception("Can't parse an empty diff!"); + throw new Exception(pht("Can't parse an empty diff!")); } // Detect `git-format-patch`, by looking for a "---" line somewhere in @@ -274,11 +274,16 @@ final class ArcanistDiffParser { if ($failed_parse) { $this->didFailParse( - "Expected a hunk header, like 'Index: /path/to/file.ext' (svn), ". - "'Property changes on: /path/to/file.ext' (svn properties), ". - "'commit 59bcc3ad6775562f845953cf01624225' (git show), ". - "'diff --git' (git diff), '--- filename' (unified diff), or ". - "'diff -r' (hg diff or patch)."); + pht( + "Expected a hunk header, like '%s' (svn), '%s' (svn properties), ". + "'%s' (git show), '%s' (git diff), '%s' (unified diff), or ". + "'%s' (hg diff or patch).", + 'Index: /path/to/file.ext', + 'Property changes on: /path/to/file.ext', + 'commit 59bcc3ad6775562f845953cf01624225', + 'diff --git', + '--- filename', + 'diff -r')); } if (isset($match['type'])) { @@ -332,7 +337,9 @@ final class ArcanistDiffParser { $line, $match); if (!$ok) { - $this->didFailParse("Expected '+++ filename' in unified diff."); + $this->didFailParse(pht( + "Expected '%s' in unified diff.", + '+++ filename')); } $change->setCurrentPath($match[1]); $line = $this->nextLine(); @@ -347,7 +354,7 @@ final class ArcanistDiffParser { $this->parseIndexHunk($change); break; default: - $this->didFailParse('Unknown diff type.'); + $this->didFailParse(pht('Unknown diff type.')); break; } } while ($this->getLine() !== null); @@ -380,12 +387,12 @@ final class ArcanistDiffParser { $line = $this->getLine(); if (!preg_match('/^Author: /', $line)) { - $this->didFailParse("Expected 'Author:'."); + $this->didFailParse(pht("Expected 'Author:'.")); } $line = $this->nextLine(); if (!preg_match('/^Date: /', $line)) { - $this->didFailParse("Expected 'Date:'."); + $this->didFailParse(pht("Expected 'Date:'.")); } while (($line = $this->nextLineTrimmed()) !== null) { @@ -410,7 +417,7 @@ final class ArcanistDiffParser { protected function parsePropertyHunk(ArcanistDiffChange $change) { $line = $this->getLineTrimmed(); if (!preg_match('/^_+$/', $line)) { - $this->didFailParse("Expected '______________________'."); + $this->didFailParse(pht("Expected '%s'.", '______________________')); } $line = $this->nextLine(); @@ -430,7 +437,7 @@ final class ArcanistDiffParser { $matches); if (!$ok) { $this->didFailParse( - "Expected 'Name', 'Added', 'Deleted', or 'Modified'."); + pht("Expected 'Name', 'Added', 'Deleted', or 'Modified'.")); } $op = $matches[1]; @@ -476,13 +483,17 @@ final class ArcanistDiffParser { } if ($trimline && $trimline[0] == '+') { if ($op == 'Deleted') { - $this->didFailParse('Unexpected "+" section in property deletion.'); + $this->didFailParse(pht( + 'Unexpected "%s" section in property deletion.', + '+')); } $target = 'new'; $line = substr($trimline, $prop_index); } else if ($trimline && $trimline[0] == '-') { if ($op == 'Added') { - $this->didFailParse('Unexpected "-" section in property addition.'); + $this->didFailParse(pht( + 'Unexpected "%s" section in property addition.', + '-')); } $target = 'old'; $line = substr($trimline, $prop_index); @@ -523,7 +534,7 @@ final class ArcanistDiffParser { protected function setIsGit($git) { if ($this->isGit !== null && $this->isGit != $git) { - throw new Exception('Git status has changed!'); + throw new Exception(pht('Git status has changed!')); } $this->isGit = $git; return $this; @@ -682,7 +693,9 @@ final class ArcanistDiffParser { if ($is_svn) { $ok = preg_match('/^=+\s*$/', $line); if (!$ok) { - $this->didFailParse("Expected '=======================' divider line."); + $this->didFailParse(pht( + "Expected '%s' divider line.", + '=======================')); } else { // Adding an empty file in SVN can produce an empty line here. $line = $this->nextNonemptyLine(); @@ -803,7 +816,8 @@ final class ArcanistDiffParser { $line = $this->getLine(); if (!preg_match('/^literal /', $line)) { - $this->didFailParse("Expected 'literal NNNN' to start git binary patch."); + $this->didFailParse( + pht("Expected '%s' to start git binary patch.", 'literal NNNN')); } do { $line = $this->nextLineTrimmed(); @@ -814,7 +828,8 @@ final class ArcanistDiffParser { $this->nextNonemptyLine(); return; } else if (!preg_match('/^[a-zA-Z]/', $line)) { - $this->didFailParse('Expected base85 line length character (a-zA-Z).'); + $this->didFailParse( + pht('Expected base85 line length character (a-zA-Z).')); } } while (true); } @@ -843,7 +858,9 @@ final class ArcanistDiffParser { if (!$ok) { $this->didFailParse( - "Expected hunk target '+++ path/to/file.ext (revision N)'."); + pht( + "Expected hunk target '%s'.", + '+++ path/to/file.ext (revision N)')); } $this->nextLine(); @@ -887,12 +904,14 @@ final class ArcanistDiffParser { $line = $this->nextNonemptyLine(); $ok = preg_match('/^Property changes on:/', $line); if (!$ok) { - $this->didFailParse('Confused by empty line'); + $this->didFailParse(pht('Confused by empty line')); } $line = $this->nextLine(); return $this->parsePropertyHunk($change); } - $this->didFailParse("Expected hunk header '@@ -NN,NN +NN,NN @@'."); + $this->didFailParse(pht( + "Expected hunk header '%s'.", + '@@ -NN,NN +NN,NN @@')); } $hunk->setOldOffset($matches[1]); @@ -930,7 +949,7 @@ final class ArcanistDiffParser { case '\\': if (!preg_match('@\\ No newline at end of file@', $line)) { $this->didFailParse( - "Expected '\ No newline at end of file'."); + pht("Expected '\ No newline at end of file'.")); } if ($new_len) { $real[] = $line; @@ -975,7 +994,7 @@ final class ArcanistDiffParser { } if ($old_len || $new_len) { - $this->didFailParse('Found the wrong number of hunk lines.'); + $this->didFailParse(pht('Found the wrong number of hunk lines.')); } $corpus = implode('', $real); @@ -991,8 +1010,10 @@ final class ArcanistDiffParser { $corpus = phutil_utf8_convert($corpus, 'UTF-8', $try_encoding); if (!phutil_is_utf8($corpus)) { throw new Exception( - "Failed to convert a hunk from '{$try_encoding}' to UTF-8. ". - "Check that the specified encoding is correct."); + pht( + "Failed to convert a hunk from '%s' to UTF-8. ". + "Check that the specified encoding is correct.", + $try_encoding)); } } } @@ -1362,11 +1383,13 @@ final class ArcanistDiffParser { if (!$matches) { throw new Exception( - "Input diff contains ambiguous line 'diff --git {$paths}'. This line ". - "is ambiguous because there are spaces in the file names, so the ". - "parser can not determine where the file names begin and end. To ". - "resolve this ambiguity, use standard prefixes ('a/' and 'b/') when ". - "generating diffs."); + pht( + "Input diff contains ambiguous line '%s'. This line is ambiguous ". + "because there are spaces in the file names, so the parser can not ". + "determine where the file names begin and end. To resolve this ". + "ambiguity, use standard prefixes ('a/' and 'b/') when ". + "generating diffs.", + "diff --git {$paths}")); } $old = $matches['old']; diff --git a/src/parser/__tests__/ArcanistBundleTestCase.php b/src/parser/__tests__/ArcanistBundleTestCase.php index 19f251d9..cbd6b41e 100644 --- a/src/parser/__tests__/ArcanistBundleTestCase.php +++ b/src/parser/__tests__/ArcanistBundleTestCase.php @@ -20,7 +20,11 @@ final class ArcanistBundleTestCase extends ArcanistTestCase { $this->assertEqual( 1, $err, - "Expect `diff` to find changes between '{$old}' and '{$new}'."); + pht( + "Expect `%s` to find changes between '%s' and '%s'.", + 'diff', + $old, + $new)); return $stdout; } @@ -36,7 +40,7 @@ final class ArcanistBundleTestCase extends ArcanistTestCase { */ public function testGitRepository() { if (phutil_is_windows()) { - $this->assertSkipped('This test is not supported under Windows.'); + $this->assertSkipped(pht('This test is not supported under Windows.')); } $archive = dirname(__FILE__).'/bundle.git.tgz'; @@ -111,8 +115,11 @@ final class ArcanistBundleTestCase extends ArcanistTestCase { } else { Filesystem::writeFile($expect_path.'.real', $patch); throw new Exception( - "Expected patch and actual patch for {$commit_hash} differ. ". - "Wrote actual patch to '{$expect_path}.real'."); + pht( + "Expected patch and actual patch for %s differ. ". + "Wrote actual patch to '%s.real'.", + $commit_hash, + $expect_path)); } try { @@ -125,8 +132,8 @@ final class ArcanistBundleTestCase extends ArcanistTestCase { Filesystem::writeFile($temp, $patch); PhutilConsole::getConsole()->writeErr( - "Wrote failing patch to '%s'.\n", - $temp); + "%s\n", + pht("Wrote failing patch to '%s'.", $temp)); throw $ex; } @@ -137,7 +144,7 @@ final class ArcanistBundleTestCase extends ArcanistTestCase { $this->assertEqual( $tree_hash, $result_hash, - "Commit {$commit_hash}: {$subject}"); + pht('Commit %s: %s', $commit_hash, $subject)); } } @@ -569,11 +576,11 @@ final class ArcanistBundleTestCase extends ArcanistTestCase { case '228d7be4840313ed805c25c15bba0f7b188af3e6': // "Add a text file." // This commit is never reached because we skip the 0th commit junk. - $this->assertTrue(true, 'This is never reached.'); + $this->assertTrue(true, pht('This is never reached.')); break; default: throw new Exception( - "Commit {$commit} has no change assertions!"); + pht('Commit %s has no change assertions!', $commit)); } } diff --git a/src/parser/__tests__/ArcanistDiffParserTestCase.php b/src/parser/__tests__/ArcanistDiffParserTestCase.php index 37801315..9322063c 100644 --- a/src/parser/__tests__/ArcanistDiffParserTestCase.php +++ b/src/parser/__tests__/ArcanistDiffParserTestCase.php @@ -602,7 +602,7 @@ EOTEXT $this->assertEqual('file with spaces.txt', $change->getOldPath()); break; default: - throw new Exception("No test block for diff file {$diff_file}."); + throw new Exception(pht('No test block for diff file %s.', $diff_file)); break; } } @@ -625,7 +625,7 @@ EOTEXT $this->assertEqual( $expect, ArcanistDiffParser::stripGitPathPrefix($input), - "Strip git prefix from '{$input}'."); + pht("Strip git prefix from '%s'.", $input)); } } @@ -663,7 +663,7 @@ EOTEXT $this->assertEqual( $expect, $result, - "Split: {$input}"); + pht('Split: %s', $input)); } @@ -680,7 +680,7 @@ EOTEXT } $this->assertTrue( ($caught instanceof Exception), - "Ambiguous: {$input}"); + pht('Ambiguous: %s', $input)); } } diff --git a/src/parser/diff/ArcanistDiffChange.php b/src/parser/diff/ArcanistDiffChange.php index c5e8de7e..06f68b6c 100644 --- a/src/parser/diff/ArcanistDiffChange.php +++ b/src/parser/diff/ArcanistDiffChange.php @@ -292,14 +292,14 @@ final class ArcanistDiffChange { public function getSymlinkTarget() { if ($this->getFileType() != ArcanistDiffChangeType::FILE_SYMLINK) { - throw new Exception('Not a symlink!'); + throw new Exception(pht('Not a symlink!')); } $hunks = $this->getHunks(); $hunk = reset($hunks); $corpus = $hunk->getCorpus(); $match = null; if (!preg_match('/^\+(?:link )?(.*)$/m', $corpus, $match)) { - throw new Exception('Failed to extract link target!'); + throw new Exception(pht('Failed to extract link target!')); } return trim($match[1]); } diff --git a/src/parser/diff/ArcanistDiffChangeType.php b/src/parser/diff/ArcanistDiffChangeType.php index ef84985a..36ea5a5c 100644 --- a/src/parser/diff/ArcanistDiffChangeType.php +++ b/src/parser/diff/ArcanistDiffChangeType.php @@ -94,19 +94,24 @@ final class ArcanistDiffChangeType { } public static function getFullNameForChangeType($type) { - static $types = array( - self::TYPE_ADD => 'Added', - self::TYPE_CHANGE => 'Modified', - self::TYPE_DELETE => 'Deleted', - self::TYPE_MOVE_AWAY => 'Moved Away', - self::TYPE_COPY_AWAY => 'Copied Away', - self::TYPE_MOVE_HERE => 'Moved Here', - self::TYPE_COPY_HERE => 'Copied Here', - self::TYPE_MULTICOPY => 'Deleted After Multiple Copy', - self::TYPE_MESSAGE => 'Commit Message', - self::TYPE_CHILD => 'Contents Modified', - ); - return idx($types, coalesce($type, '?'), 'Unknown'); + static $types = null; + + if ($types === null) { + $types = array( + self::TYPE_ADD => pht('Added'), + self::TYPE_CHANGE => pht('Modified'), + self::TYPE_DELETE => pht('Deleted'), + self::TYPE_MOVE_AWAY => pht('Moved Away'), + self::TYPE_COPY_AWAY => pht('Copied Away'), + self::TYPE_MOVE_HERE => pht('Moved Here'), + self::TYPE_COPY_HERE => pht('Copied Here'), + self::TYPE_MULTICOPY => pht('Deleted After Multiple Copy'), + self::TYPE_MESSAGE => pht('Commit Message'), + self::TYPE_CHILD => pht('Contents Modified'), + ); + } + + return idx($types, coalesce($type, '?'), pht('Unknown')); } } diff --git a/src/parser/diff/ArcanistDiffHunk.php b/src/parser/diff/ArcanistDiffHunk.php index f47dd242..cfd6d998 100644 --- a/src/parser/diff/ArcanistDiffHunk.php +++ b/src/parser/diff/ArcanistDiffHunk.php @@ -83,7 +83,7 @@ final class ArcanistDiffHunk { case 'cover': return $cover_map; default: - throw new Exception("Unknown line change type '{$type}'."); + throw new Exception(pht("Unknown line change type '%s'.", $type)); } } diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index 5377ebaf..7b0bd64b 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -92,8 +92,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { if ($this->repositoryHasNoCommits) { // Zero commits. throw new Exception( - "You can't get local commit information for a repository with no ". - "commits."); + pht( + "You can't get local commit information for a repository with no ". + "commits.")); } else if ($this->getBaseCommit() == self::GIT_MAGIC_ROOT_COMMIT) { // One commit. $against = 'HEAD'; @@ -200,7 +201,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { if ($symbolic_commit !== null) { if ($symbolic_commit == self::GIT_MAGIC_ROOT_COMMIT) { $this->setBaseCommitExplanation( - 'you explicitly specified the empty tree.'); + pht('you explicitly specified the empty tree.')); return $symbolic_commit; } @@ -210,19 +211,24 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $this->getHeadCommit()); if ($err) { throw new ArcanistUsageException( - "Unable to find any git commit named '{$symbolic_commit}' in ". - "this repository."); + pht( + "Unable to find any git commit named '%s' in this repository.", + $symbolic_commit)); } if ($this->symbolicHeadCommit === null) { $this->setBaseCommitExplanation( - "it is the merge-base of the explicitly specified base commit ". - "'{$symbolic_commit}' and HEAD."); + pht( + "it is the merge-base of the explicitly specified base commit ". + "'%s' and HEAD.", + $symbolic_commit)); } else { $this->setBaseCommitExplanation( - "it is the merge-base of the explicitly specified base commit ". - "'{$symbolic_commit}' and the explicitly specified head ". - "commit '{$this->symbolicHeadCommit}'."); + pht( + "it is the merge-base of the explicitly specified base commit ". + "'%s' and the explicitly specified head commit '%s'.", + $symbolic_commit, + $this->symbolicHeadCommit)); } return trim($merge_base); @@ -239,11 +245,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { } if ($this->repositoryHasNoCommits) { - $this->setBaseCommitExplanation( - 'the repository has no commits.'); + $this->setBaseCommitExplanation(pht('the repository has no commits.')); } else { $this->setBaseCommitExplanation( - 'the repository has only one commit.'); + pht('the repository has only one commit.')); } return self::GIT_MAGIC_ROOT_COMMIT; @@ -254,9 +259,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $base = $this->resolveBaseCommit(); if (!$base) { throw new ArcanistUsageException( - "None of the rules in your 'base' configuration matched a valid ". - "commit. Adjust rules or specify which commit you want to use ". - "explicitly."); + pht( + "None of the rules in your 'base' configuration matched a valid ". + "commit. Adjust rules or specify which commit you want to use ". + "explicitly.")); } return $base; } @@ -268,9 +274,12 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $default_relative = $working_copy->getProjectConfig( 'git.default-relative-commit'); $this->setBaseCommitExplanation( - "it is the merge-base of '{$default_relative}' and HEAD, as ". - "specified in 'git.default-relative-commit' in '.arcconfig'. This ". - "setting overrides other settings."); + pht( + "it is the merge-base of '%s' and HEAD, as specified in '%s' in ". + "'%s'. This setting overrides other settings.", + $default_relative, + 'git.default-relative-commit', + '.arcconfig')); } if (!$default_relative) { @@ -281,8 +290,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { if (!$err) { $default_relative = trim($upstream); $this->setBaseCommitExplanation( - "it is the merge-base of '{$default_relative}' (the Git upstream ". - "of the current branch) HEAD."); + pht( + "it is the merge-base of '%s' (the Git upstream ". + "of the current branch) HEAD.", + $default_relative)); } } @@ -291,8 +302,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $default_relative = trim($default_relative); if ($default_relative) { $this->setBaseCommitExplanation( - "it is the merge-base of '{$default_relative}' and HEAD, as ". - "specified in '.git/arc/default-relative-commit'."); + pht( + "it is the merge-base of '%s' and HEAD, as specified in '%s'.", + $default_relative, + '.git/arc/default-relative-commit')); } } @@ -303,23 +316,30 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { echo phutil_console_format( "** Select a Default Commit Range **\n\n"); echo phutil_console_wrap( - "You're running a command which operates on a range of revisions ". - "(usually, from some revision to HEAD) but have not specified the ". - "revision that should determine the start of the range.\n\n". - "Previously, arc assumed you meant 'HEAD^' when you did not specify ". - "a start revision, but this behavior does not make much sense in ". - "most workflows outside of Facebook's historic git-svn workflow.\n\n". - "arc no longer assumes 'HEAD^'. You must specify a relative commit ". - "explicitly when you invoke a command (e.g., `arc diff HEAD^`, not ". - "just `arc diff`) or select a default for this working copy.\n\n". - "In most cases, the best default is 'origin/master'. You can also ". - "select 'HEAD^' to preserve the old behavior, or some other remote ". - "or branch. But you almost certainly want to select ". - "'origin/master'.\n\n". - "(Technically: the merge-base of the selected revision and HEAD is ". - "used to determine the start of the commit range.)"); + pht( + "You're running a command which operates on a range of revisions ". + "(usually, from some revision to HEAD) but have not specified the ". + "revision that should determine the start of the range.\n\n". + "Previously, arc assumed you meant '%s' when you did not specify ". + "a start revision, but this behavior does not make much sense in ". + "most workflows outside of Facebook's historic %s workflow.\n\n". + "arc no longer assumes '%s'. You must specify a relative commit ". + "explicitly when you invoke a command (e.g., `%s`, not just `%s`) ". + "or select a default for this working copy.\n\nIn most cases, the ". + "best default is '%s'. You can also select '%s' to preserve the ". + "old behavior, or some other remote or branch. But you almost ". + "certainly want to select 'origin/master'.\n\n". + "(Technically: the merge-base of the selected revision and HEAD is ". + "used to determine the start of the commit range.)", + 'HEAD^', + 'git-svn', + 'HEAD^', + 'arc diff HEAD^', + 'arc diff', + 'origin/master', + 'HEAD^')); - $prompt = 'What default do you want to use? [origin/master]'; + $prompt = pht('What default do you want to use? [origin/master]'); $default = phutil_console_prompt($prompt); if (!strlen(trim($default))) { @@ -336,7 +356,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { if (trim($object_type) !== 'commit') { throw new Exception( - "Relative commit '{$default_relative}' is not the name of a commit!"); + pht( + "Relative commit '%s' is not the name of a commit!", + $default_relative)); } if ($do_write) { @@ -344,8 +366,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { // valid commit name. $this->writeScratchFile('default-relative-commit', $default_relative); $this->setBaseCommitExplanation( - "it is the merge-base of '{$default_relative}' and HEAD, as you ". - "just specified."); + pht( + "it is the merge-base of '%s' and HEAD, as you just specified.", + $default_relative)); } list($merge_base) = $this->execxLocal( @@ -382,8 +405,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { if ($err) { throw new ArcanistUsageException( - "Unable to find any git commit named '{$symbolic_commit}' in ". - "this repository."); + pht( + "Unable to find any git commit named '%s' in this repository.", + $symbolic_commit)); } return trim($commit_hash); @@ -547,7 +571,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $input); if (!$stdout) { throw new ArcanistUsageException( - "Cannot find the {$vcs} equivalent of {$input}."); + pht( + 'Cannot find the %s equivalent of %s.', + $vcs, + $input)); } // When git performs a partial-rebuild during svn // look-up, we need to parse the final line @@ -777,7 +804,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $line, $matches); if (!$ok) { - throw new Exception("Bad blame? `{$line}'"); + throw new Exception(pht("Bad blame? `%s'", $line)); } $revision = $matches[1]; $author = $matches[2]; @@ -812,7 +839,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $line, $matches); if (!$ok) { - throw new Exception('Failed to parse git ls-tree output!'); + throw new Exception(pht('Failed to parse %s output!', 'git ls-tree')); } $result[$matches[4]] = array( 'mode' => $matches[1], @@ -937,7 +964,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { public function performLocalBranchMerge($branch, $message) { if (!$branch) { throw new ArcanistUsageException( - 'Under git, you must specify the branch you want to merge.'); + pht('Under git, you must specify the branch you want to merge.')); } $err = phutil_passthru( '(cd %s && git merge --no-ff -m %s %s)', @@ -951,8 +978,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { } public function getFinalizedRevisionMessage() { - return "You may now push this commit upstream, as appropriate (e.g. with ". - "'git push', or 'git svn dcommit', or by printing and faxing it)."; + return pht( + "You may now push this commit upstream, as appropriate (e.g. with ". + "'%s', or '%s', or by printing and faxing it).", + 'git push', + 'git svn dcommit'); } public function getCommitMessage($commit) { @@ -996,8 +1026,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { foreach ($results as $key => $result) { $hash = substr($reason_map[$result['id']], 0, 16); - $results[$key]['why'] = - "Commit message for '{$hash}' has explicit 'Differential Revision'."; + $results[$key]['why'] = pht( + "Commit message for '%s' has explicit 'Differential Revision'.", + $hash); } return $results; @@ -1017,9 +1048,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { )); foreach ($results as $key => $result) { - $results[$key]['why'] = + $results[$key]['why'] = pht( 'A git commit or tree hash in the commit range is already attached '. - 'to the Differential revision.'; + 'to the Differential revision.'); } return $results; @@ -1032,7 +1063,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { public function getCommitSummary($commit) { if ($commit == self::GIT_MAGIC_ROOT_COMMIT) { - return '(The Empty Tree)'; + return pht('(The Empty Tree)'); } list($summary) = $this->execxLocal( @@ -1044,17 +1075,16 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { } public function backoutCommit($commit_hash) { - $this->execxLocal( - 'revert %s -n --no-edit', $commit_hash); + $this->execxLocal('revert %s -n --no-edit', $commit_hash); $this->reloadWorkingCopy(); if (!$this->getUncommittedStatus()) { throw new ArcanistUsageException( - "{$commit_hash} has already been reverted."); + pht('%s has already been reverted.', $commit_hash)); } } public function getBackoutMessage($commit_hash) { - return 'This reverts commit '.$commit_hash.'.'; + return pht('This reverts commit %s.', $commit_hash); } public function isGitSubversionRepo() { @@ -1073,9 +1103,12 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $matches[1]); if (!$err) { $this->setBaseCommitExplanation( - "it is the merge-base of '{$matches[1]}' and HEAD, as ". - "specified by '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "it is the merge-base of '%s' and HEAD, as specified by ". + "'%s' in your %s 'base' configuration.", + $matches[1], + $rule, + $source)); return trim($merge_base); } } else if (preg_match('/^branch-unique\((.+)\)$/', $name, $matches)) { @@ -1118,9 +1151,13 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { } $branches = implode(', ', $branches); $this->setBaseCommitExplanation( - "it is the first commit between '{$merge_base}' (the ". - "merge-base of '{$matches[1]}' and HEAD) which is also ". - "contained by another branch ({$branches})."); + pht( + "it is the first commit between '%s' (the merge-base of ". + "'%s' and HEAD) which is also contained by another branch ". + "(%s).", + $merge_base, + $matches[1], + $branches)); return $commit; } } @@ -1130,8 +1167,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $name); if (!$err) { $this->setBaseCommitExplanation( - "it is specified by '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "it is specified by '%s' in your %s 'base' configuration.", + $rule, + $source)); return $name; } } @@ -1140,8 +1179,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { switch ($name) { case 'empty': $this->setBaseCommitExplanation( - "you specified '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "you specified '%s' in your %s 'base' configuration.", + $rule, + $source)); return self::GIT_MAGIC_ROOT_COMMIT; case 'amended': $text = $this->getCommitMessage('HEAD'); @@ -1149,9 +1190,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $text); if ($message->getRevisionID()) { $this->setBaseCommitExplanation( - "HEAD has been amended with 'Differential Revision:', ". - "as specified by '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "HEAD has been amended with 'Differential Revision:', ". + "as specified by '%s' in your %s 'base' configuration.", + $rule, + $source)); return 'HEAD^'; } break; @@ -1166,16 +1209,21 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $upstream); $upstream_merge_base = rtrim($upstream_merge_base); $this->setBaseCommitExplanation( - "it is the merge-base of the upstream of the current branch ". - "and HEAD, and matched the rule '{$rule}' in your {$source} ". - "'base' configuration."); + pht( + "it is the merge-base of the upstream of the current branch ". + "and HEAD, and matched the rule '%s' in your %s ". + "'base' configuration.", + $rule, + $source)); return $upstream_merge_base; } break; case 'this': $this->setBaseCommitExplanation( - "you specified '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "you specified '%s' in your %s 'base' configuration.", + $rule, + $source)); return 'HEAD^'; } default: diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index efe51198..4abcea04 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -80,7 +80,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $string); if (!$stdout) { throw new ArcanistUsageException( - "Cannot find the HG equivalent of {$revision_id} given."); + pht('Cannot find the HG equivalent of %s given.', $revision_id)); } return $stdout; } @@ -92,7 +92,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { 'log -r %s --template {svnrev}', $hash); if (!$stdout) { throw new ArcanistUsageException( - "Cannot find the SVN equivalent of {$hash} given."); + pht('Cannot find the SVN equivalent of %s given.', $hash)); } return $stdout; } @@ -125,14 +125,16 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { hgsprintf('ancestor(%R,.)', $symbolic_commit)); } catch (Exception $ex) { throw new ArcanistUsageException( - "Commit '{$symbolic_commit}' is not a valid Mercurial commit ". - "identifier."); + pht( + "Commit '%s' is not a valid Mercurial commit identifier.", + $symbolic_commit)); } } $this->setBaseCommitExplanation( - 'it is the greatest common ancestor of the working directory '. - 'and the commit you specified explicitly.'); + pht( + 'it is the greatest common ancestor of the working directory '. + 'and the commit you specified explicitly.')); return $commit; } @@ -141,9 +143,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $base = $this->resolveBaseCommit(); if (!$base) { throw new ArcanistUsageException( - "None of the rules in your 'base' configuration matched a valid ". - "commit. Adjust rules or specify which commit you want to use ". - "explicitly."); + pht( + "None of the rules in your 'base' configuration matched a valid ". + "commit. Adjust rules or specify which commit you want to use ". + "explicitly.")); } return $base; } @@ -172,8 +175,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { if (!$logs) { $this->setBaseCommitExplanation( - 'you have no outgoing commits, so arc assumes you intend to submit '. - 'uncommitted changes in the working copy.'); + pht( + 'you have no outgoing commits, so arc assumes you intend to submit '. + 'uncommitted changes in the working copy.')); return $this->getWorkingCopyRevision(); } @@ -215,11 +219,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { if ($against == 'null') { $this->setBaseCommitExplanation( - 'this is a new repository (all changes are outgoing).'); + pht('this is a new repository (all changes are outgoing).')); } else { $this->setBaseCommitExplanation( - 'it is the first commit reachable from the working copy state '. - 'which is not outgoing.'); + pht( + 'it is the first commit reachable from the working copy state '. + 'which is not outgoing.')); } return $against; @@ -334,7 +339,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $ok = preg_match('/^\s*([^:]+?) ([a-f0-9]{12}):/', $line, $matches); if (!$ok) { - throw new Exception("Unable to parse Mercurial blame line: {$line}"); + throw new Exception( + pht( + 'Unable to parse Mercurial blame line: %s', + $line)); } $revision = $matches[2]; @@ -619,13 +627,15 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { } if ($err) { - throw new ArcanistUsageException('Merge failed!'); + throw new ArcanistUsageException(pht('Merge failed!')); } } public function getFinalizedRevisionMessage() { - return "You may now push this commit upstream, as appropriate (e.g. with ". - "'hg push' or by printing and faxing it)."; + return pht( + "You may now push this commit upstream, as appropriate (e.g. with ". + "'%s' or by printing and faxing it).", + 'hg push'); } public function getCommitMessageLog() { @@ -676,7 +686,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { foreach ($results as $key => $result) { $hash = substr($reason_map[$result['id']], 0, 16); $results[$key]['why'] = - "Commit message for '{$hash}' has explicit 'Differential Revision'."; + pht( + "Commit message for '%s' has explicit 'Differential Revision'.", + $hash); } return $results; @@ -700,9 +712,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { )); foreach ($results as $key => $hash) { - $results[$key]['why'] = + $results[$key]['why'] = pht( 'A mercurial commit hash in the commit range is already attached '. - 'to the Differential revision.'; + 'to the Differential revision.'); } return $results; @@ -795,7 +807,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { public function getCommitSummary($commit) { if ($commit == 'null') { - return '(The Empty Void)'; + return pht('(The Empty Void)'); } list($summary) = $this->execxLocal( @@ -808,17 +820,16 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { } public function backoutCommit($commit_hash) { - $this->execxLocal( - 'backout -r %s', $commit_hash); + $this->execxLocal('backout -r %s', $commit_hash); $this->reloadWorkingCopy(); if (!$this->getUncommittedStatus()) { throw new ArcanistUsageException( - "{$commit_hash} has already been reverted."); + pht('%s has already been reverted.', $commit_hash)); } } public function getBackoutMessage($commit_hash) { - return 'Backed out changeset '.$commit_hash.'.'; + return pht('Backed out changeset %s,', $commit_hash); } public function resolveBaseCommitRule($rule, $source) { @@ -838,9 +849,13 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { sprintf('ancestor(., %s)', $matches[1])); if (!$err) { $this->setBaseCommitExplanation( - "it is the greatest common ancestor of '{$matches[1]}' and ., as". - " specified by '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "it is the greatest common ancestor of '%s' and %s, as ". + "specified by '%s' in your %s 'base' configuration.", + $matches[1], + '.', + $rule, + $source)); return trim($merge_base); } } else { @@ -855,8 +870,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { } if (!$err) { $this->setBaseCommitExplanation( - "it is specified by '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "it is specified by '%s' in your %s 'base' configuration.", + $rule, + $source)); return trim($commit); } } @@ -865,8 +882,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { switch ($name) { case 'empty': $this->setBaseCommitExplanation( - "you specified '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "you specified '%s' in your %s 'base' configuration.", + $rule, + $source)); return 'null'; case 'outgoing': list($err, $outgoing_base) = $this->execManualLocal( @@ -874,9 +893,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { 'limit(reverse(ancestors(.) - outgoing()), 1)'); if (!$err) { $this->setBaseCommitExplanation( - "it is the first ancestor of the working copy that is not ". - "outgoing, and it matched the rule {$rule} in your {$source} ". - "'base' configuration."); + pht( + "it is the first ancestor of the working copy that is not ". + "outgoing, and it matched the rule %s in your %s ". + "'base' configuration.", + $rule, + $source)); return trim($outgoing_base); } case 'amended': @@ -885,9 +907,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $text); if ($message->getRevisionID()) { $this->setBaseCommitExplanation( - "'.' has been amended with 'Differential Revision:', ". - "as specified by '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "'%s' has been amended with 'Differential Revision:', ". + "as specified by '%s' in your %s 'base' configuration.", + '.'. + $rule, + $source)); // NOTE: This should be safe because Mercurial doesn't support // amend until 2.2. return $this->getCanonicalRevisionName('.^'); @@ -906,16 +931,22 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $revset); if (!$err) { $this->setBaseCommitExplanation( - "it is the first ancestor of . that either has a bookmark, or ". - "is already in the remote and it matched the rule {$rule} in ". - "your {$source} 'base' configuration"); + pht( + "it is the first ancestor of %s that either has a bookmark, ". + "or is already in the remote and it matched the rule %s in ". + "your %s 'base' configuration", + '.', + $rule, + $source)); return trim($bookmark_base); } break; case 'this': $this->setBaseCommitExplanation( - "you specified '{$rule}' in your {$source} 'base' ". - "configuration."); + pht( + "you specified '%s' in your %s 'base' configuration.", + $rule, + $source)); return $this->getCanonicalRevisionName('.^'); default: if (preg_match('/^nodiff\((.+)\)$/', $name, $matches)) { @@ -936,10 +967,14 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $desc); if ($message->getRevisionID()) { $this->setBaseCommitExplanation( - "it is the first ancestor of . that has a diff ". - "and is the gca or a descendant of the gca with ". - "'{$matches[1]}', specified by '{$rule}' in your ". - "{$source} 'base' configuration."); + pht( + "it is the first ancestor of %s that has a diff and is ". + "the gca or a descendant of the gca with '%s', ". + "specified by '%s' in your %s 'base' configuration.", + '.', + $matches[1], + $rule, + $source)); return $node; } } diff --git a/src/repository/api/ArcanistRepositoryAPI.php b/src/repository/api/ArcanistRepositoryAPI.php index d5a3b540..56c7a931 100644 --- a/src/repository/api/ArcanistRepositoryAPI.php +++ b/src/repository/api/ArcanistRepositoryAPI.php @@ -63,7 +63,8 @@ abstract class ArcanistRepositoryAPI { if (!$working_copy) { throw new Exception( pht( - 'Trying to create a RepositoryAPI without a working copy!')); + 'Trying to create a %s without a working copy!', + __CLASS__)); } $root = $working_copy->getProjectRoot(); diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php index 9b529c08..e9536111 100644 --- a/src/repository/api/ArcanistSubversionAPI.php +++ b/src/repository/api/ArcanistSubversionAPI.php @@ -37,7 +37,6 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { } protected function buildLocalFuture(array $argv) { - $argv[0] = 'svn '.$argv[0]; $future = newv('ExecFuture', $argv); @@ -106,7 +105,9 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { $mask |= self::FLAG_MODIFIED; break; default: - throw new Exception("Unrecognized property status '{$props}'."); + throw new Exception(pht( + "Unrecognized property status '%s'.", + $props)); } $mask |= $this->parseSVNStatus($item); @@ -177,7 +178,7 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { case 'incomplete': return self::FLAG_INCOMPLETE; default: - throw new Exception("Unrecognized item status '{$item}'."); + throw new Exception(pht("Unrecognized item status '%s'.", $item)); } } @@ -332,7 +333,7 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { list($err, $stdout) = $this->svnInfoRaw[$path]; if ($err) { throw new Exception( - "Error #{$err} executing svn info against '{$path}'."); + pht("Error #%d executing svn info against '%s'.", $err, $path)); } // TODO: Hack for Windows. @@ -364,7 +365,7 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI { } if (empty($result)) { - throw new Exception('Unable to parse SVN info.'); + throw new Exception(pht('Unable to parse SVN info.')); } $this->svnInfo[$path] = $result; @@ -431,9 +432,12 @@ EODIFF; // happy about it. SVN will exit with code 1 and return the string below. if ($err != 0 && $stderr !== "svn: 'diff' returned 2\n") { throw new Exception( - "svn diff returned unexpected error code: $err\n". - "stdout: $stdout\n". - "stderr: $stderr"); + pht( + "%s returned unexpected error code: %d\nstdout: %s\nstderr: %s", + 'svn diff', + $err, + $stdout, + $stderr)); } if ($err == 0 && empty($stdout)) { @@ -568,7 +572,7 @@ EODIFF; foreach (explode("\n", $stdout) as $line) { $m = array(); if (!preg_match('/^\s*(\d+)\s+(\S+)/', $line, $m)) { - throw new Exception("Bad blame? `{$line}'"); + throw new Exception(pht("Bad blame? `%s'", $line)); } $revision = $m[1]; $author = $m[2]; @@ -665,8 +669,8 @@ EODIFF; } foreach ($results as $key => $result) { - $results[$key]['why'] = - 'Matching arcanist project name and working copy directory path.'; + $results[$key]['why'] = pht( + 'Matching arcanist project name and working copy directory path.'); } return $results; diff --git a/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php b/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php index ed13af09..236f46c7 100644 --- a/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php +++ b/src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php @@ -6,7 +6,7 @@ final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase { if (Filesystem::binaryExists('git')) { $this->parseState('git_basic.git.tgz'); } else { - $this->assertSkipped('Git is not installed'); + $this->assertSkipped(pht('Git is not installed')); } } @@ -14,7 +14,7 @@ final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase { if (Filesystem::binaryExists('hg')) { $this->parseState('hg_basic.hg.tgz'); } else { - $this->assertSkipped('Mercurial is not installed'); + $this->assertSkipped(pht('Mercurial is not installed')); } } @@ -22,7 +22,7 @@ final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase { if (Filesystem::binaryExists('svn')) { $this->parseState('svn_basic.svn.tgz'); } else { - $this->assertSkipped('Subversion is not installed'); + $this->assertSkipped(pht('Subversion is not installed')); } } @@ -116,7 +116,7 @@ final class ArcanistRepositoryAPIStateTestCase extends ArcanistTestCase { break; default: throw new Exception( - "No test cases for working copy '{$test}'!"); + pht("No test cases for working copy '%s'!", $test)); } } diff --git a/src/repository/parser/ArcanistMercurialParser.php b/src/repository/parser/ArcanistMercurialParser.php index d5d2bf13..b9044500 100644 --- a/src/repository/parser/ArcanistMercurialParser.php +++ b/src/repository/parser/ArcanistMercurialParser.php @@ -34,7 +34,10 @@ final class ArcanistMercurialParser { foreach ($lines as $line) { $flags = 0; if ($line[1] !== ' ') { - throw new Exception("Unparsable Mercurial status line '{$line}'."); + throw new Exception( + pht( + "Unparsable Mercurial status line '%s'.", + $line)); } $code = $line[0]; $path = substr($line, 2); @@ -66,12 +69,15 @@ final class ArcanistMercurialParser { // parsed to set its source. if ($last_path === null) { throw new Exception( - "Unexpected copy source in hg status, '{$line}'."); + pht( + "Unexpected copy source in %s, '%s'.", + 'hg status', + $line)); } $result[$last_path]['from'] = $path; continue 2; default: - throw new Exception("Unknown Mercurial status '{$code}'."); + throw new Exception(pht("Unknown Mercurial status '%s'.", $code)); } $result[$path] = array( @@ -169,7 +175,8 @@ final class ArcanistMercurialParser { $commit['bookmark'] = $value; break; default: - throw new Exception("Unknown Mercurial log field '{$name}'!"); + throw new Exception( + pht("Unknown Mercurial log field '%s'!", $name)); } } $result[] = $commit; @@ -211,7 +218,11 @@ final class ArcanistMercurialParser { $regexp = '/^(\S+(?:\s+\S+)*)\s+(\d+):([a-f0-9]+)(\s+\\(inactive\\))?$/'; if (!preg_match($regexp, $line, $matches)) { - throw new Exception("Failed to parse 'hg branches' output: {$line}"); + throw new Exception( + pht( + "Failed to parse '%s' output: %s", + 'hg branches', + $line)); } $branches[$matches[1]] = array( 'local' => $matches[2], diff --git a/src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php b/src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php index 2129448d..6ff5f426 100644 --- a/src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php +++ b/src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php @@ -82,7 +82,8 @@ final class ArcanistMercurialParserTestCase extends ArcanistTestCase { idx($output, 'copy_source')); break; default: - throw new Exception("No test information for test data '{$name}'!"); + throw new Exception( + pht("No test information for test data '%s'!", $name)); } } diff --git a/src/unit/engine/ArcanistUnitTestEngine.php b/src/unit/engine/ArcanistUnitTestEngine.php index c449ed6f..8dd6e672 100644 --- a/src/unit/engine/ArcanistUnitTestEngine.php +++ b/src/unit/engine/ArcanistUnitTestEngine.php @@ -17,9 +17,11 @@ abstract class ArcanistUnitTestEngine { public function setRunAllTests($run_all_tests) { if (!$this->supportsRunAllTests() && $run_all_tests) { - $class = get_class($this); throw new Exception( - "Engine '{$class}' does not support --everything."); + pht( + "Engine '%s' does not support %s.", + get_class($this), + '--everything')); } $this->runAllTests = $run_all_tests; @@ -53,7 +55,7 @@ abstract class ArcanistUnitTestEngine { if ($this instanceof ArcanistBaseUnitTestEngine) { phutil_deprecated( 'ArcanistBaseUnitTestEngine', - 'You should extend from `ArcanistUnitTestEngine` instead.'); + pht('You should extend from `%s` instead.', __CLASS__)); } $this->workingCopy = $working_copy; diff --git a/src/unit/engine/CSharpToolsTestEngine.php b/src/unit/engine/CSharpToolsTestEngine.php index 03ad75bb..7fd23e0d 100644 --- a/src/unit/engine/CSharpToolsTestEngine.php +++ b/src/unit/engine/CSharpToolsTestEngine.php @@ -37,15 +37,20 @@ final class CSharpToolsTestEngine extends XUnitTestEngine { // Determine coverage path. if ($this->cscoverHintPath === null) { throw new Exception( - "Unable to locate cscover. Configure it with ". - "the `unit.csharp.coverage.binary' option in .arcconfig"); + pht( + "Unable to locate %s. Configure it with the '%s' option in %s.", + 'cscover', + 'unit.csharp.coverage.binary', + '.arcconfig')); } $cscover = $this->projectRoot.DIRECTORY_SEPARATOR.$this->cscoverHintPath; if (file_exists($cscover)) { $this->coverEngine = Filesystem::resolvePath($cscover); } else { throw new Exception( - 'Unable to locate cscover coverage runner (have you built yet?)'); + pht( + 'Unable to locate %s coverage runner (have you built yet?)', + 'cscover')); } } diff --git a/src/unit/engine/NoseTestEngine.php b/src/unit/engine/NoseTestEngine.php index c5c95e3e..9af83c56 100644 --- a/src/unit/engine/NoseTestEngine.php +++ b/src/unit/engine/NoseTestEngine.php @@ -75,17 +75,19 @@ final class NoseTestEngine extends ArcanistUnitTestEngine { $cover_tmp = $tmpfiles[$test_path]['cover']; $this->parser = new ArcanistXUnitTestResultParser(); - $results[] = $this->parseTestResults($source_path, - $xunit_tmp, - $cover_tmp); + $results[] = $this->parseTestResults( + $source_path, + $xunit_tmp, + $cover_tmp); } return array_mergev($results); } public function buildTestFuture($path, $xunit_tmp, $cover_tmp) { - $cmd_line = csprintf('nosetests --with-xunit --xunit-file=%s', - $xunit_tmp); + $cmd_line = csprintf( + 'nosetests --with-xunit --xunit-file=%s', + $xunit_tmp); if ($this->getEnableCoverage() !== false) { $cmd_line .= csprintf( diff --git a/src/unit/engine/PhpunitTestEngine.php b/src/unit/engine/PhpunitTestEngine.php index eb545fb1..8206b787 100644 --- a/src/unit/engine/PhpunitTestEngine.php +++ b/src/unit/engine/PhpunitTestEngine.php @@ -42,7 +42,7 @@ final class PhpunitTestEngine extends ArcanistUnitTestEngine { } if (empty($this->affectedTests)) { - throw new ArcanistNoEffectException('No tests to run.'); + throw new ArcanistNoEffectException(pht('No tests to run.')); } $this->prepareConfigFile(); @@ -260,8 +260,10 @@ final class PhpunitTestEngine extends ArcanistUnitTestEngine { if (Filesystem::pathExists($project_root.$config)) { $this->configFile = $project_root.$config; } else { - throw new Exception('PHPUnit configuration file was not '. - 'found in '.$project_root.$config); + throw new Exception( + pht( + 'PHPUnit configuration file was not found in %s', + $project_root.$config)); } } $bin = $this->getConfigurationManager()->getConfigFromAnySource( diff --git a/src/unit/engine/PhutilUnitTestEngine.php b/src/unit/engine/PhutilUnitTestEngine.php index c2a255c3..ae790600 100644 --- a/src/unit/engine/PhutilUnitTestEngine.php +++ b/src/unit/engine/PhutilUnitTestEngine.php @@ -25,8 +25,11 @@ final class PhutilUnitTestEngine extends ArcanistUnitTestEngine { if (!function_exists('xdebug_start_code_coverage')) { if ($enable_coverage === true) { throw new ArcanistUsageException( - 'You specified --coverage but xdebug is not available, so '. - 'coverage can not be enabled for PhutilUnitTestEngine.'); + pht( + 'You specified %s but xdebug is not available, so '. + 'coverage can not be enabled for %s.', + '--coverage', + __CLASS__)); } } else { $enable_coverage = true; @@ -114,14 +117,20 @@ final class PhutilUnitTestEngine extends ArcanistUnitTestEngine { if (!$library_name) { throw new Exception( - "Attempting to run unit tests on a libphutil library which has not ". - "been loaded, at:\n\n". - " {$library_root}\n\n". - "This probably means one of two things:\n\n". - " - You may need to add this library to .arcconfig.\n". - " - You may be running tests on a copy of libphutil or arcanist\n". - " using a different copy of libphutil or arcanist. This\n". - " operation is not supported."); + sprintf( + "%s\n\n %s\n\n%s\n\n - %s\n - %s\n", + pht( + 'Attempting to run unit tests on a libphutil library '. + 'which has not been loaded, at:'), + $library_root, + pht('This probably means one of two things:'), + pht( + 'You may need to add this library to %s.', + '.arcconfig.'), + pht( + 'You may be running tests on a copy of libphutil or '. + 'arcanist using a different copy of libphutil or arcanist. '. + 'This operation is not supported.'))); } $path = Filesystem::resolvePath($path, $project_root); diff --git a/src/unit/engine/PytestTestEngine.php b/src/unit/engine/PytestTestEngine.php index 11315e3f..e5fa7370 100644 --- a/src/unit/engine/PytestTestEngine.php +++ b/src/unit/engine/PytestTestEngine.php @@ -17,7 +17,7 @@ final class PytestTestEngine extends ArcanistUnitTestEngine { if (!Filesystem::pathExists($junit_tmp)) { throw new CommandException( - "Command failed with error #{$err}!", + pht('Command failed with error #%s!', $err), $future->getCommand(), $err, $stdout, diff --git a/src/unit/engine/XUnitTestEngine.php b/src/unit/engine/XUnitTestEngine.php index 1824b5b8..cec076c5 100644 --- a/src/unit/engine/XUnitTestEngine.php +++ b/src/unit/engine/XUnitTestEngine.php @@ -42,7 +42,12 @@ class XUnitTestEngine extends ArcanistUnitTestEngine { } else if (Filesystem::binaryExists('xbuild')) { $this->buildEngine = 'xbuild'; } else { - throw new Exception('Unable to find msbuild or xbuild in PATH!'); + throw new Exception( + pht( + 'Unable to find %s or %s in %s!', + 'msbuild', + 'xbuild', + 'PATH')); } // Determine runtime engine (.NET or Mono). @@ -51,7 +56,8 @@ class XUnitTestEngine extends ArcanistUnitTestEngine { } else if (Filesystem::binaryExists('mono')) { $this->runtimeEngine = Filesystem::resolveBinary('mono'); } else { - throw new Exception('Unable to find Mono and you are not on Windows!'); + throw new Exception( + pht('Unable to find Mono and you are not on Windows!')); } // Read the discovery rules. @@ -60,8 +66,11 @@ class XUnitTestEngine extends ArcanistUnitTestEngine { 'unit.csharp.discovery'); if ($this->discoveryRules === null) { throw new Exception( - 'You must configure discovery rules to map C# files '. - 'back to test projects (`unit.csharp.discovery` in .arcconfig).'); + pht( + 'You must configure discovery rules to map C# files '. + 'back to test projects (`%s` in %s).', + 'unit.csharp.discovery', + '.arcconfig')); } // Determine xUnit test runner path. @@ -77,8 +86,11 @@ class XUnitTestEngine extends ArcanistUnitTestEngine { $this->testEngine = 'xunit.console.clr4.exe'; } else { throw new Exception( - "Unable to locate xUnit console runner. Configure ". - "it with the `unit.csharp.xunit.binary' option in .arcconfig"); + pht( + "Unable to locate xUnit console runner. Configure ". + "it with the `%s' option in %s.", + 'unit.csharp.xunit.binary', + '.arcconfig')); } } @@ -234,7 +246,7 @@ class XUnitTestEngine extends ArcanistUnitTestEngine { $this->projectRoot)); $results = array(); $result = new ArcanistUnitTestResult(); - $result->setName("(regenerate projects for $platform)"); + $result->setName(pht('(regenerate projects for %s)', $platform)); try { $regenerate_future->resolvex(); diff --git a/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php b/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php index aa055910..561e108b 100644 --- a/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php +++ b/src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php @@ -18,7 +18,9 @@ final class PhutilUnitTestEngineTestCase extends ArcanistTestCase { $this->assertEqual( 1, self::$allTestsCounter, - 'Expect willRunTests() has been called once.'); + pht( + 'Expect %s has been called once.', + 'willRunTests()')); self::$allTestsCounter--; @@ -27,21 +29,27 @@ final class PhutilUnitTestEngineTestCase extends ArcanistTestCase { $this->assertEqual( $actual_test_count, count(self::$distinctWillRunTests), - 'Expect willRunOneTest() was called once for each test.'); + pht( + 'Expect %s was called once for each test.', + 'willRunOneTest()')); $this->assertEqual( $actual_test_count, count(self::$distinctDidRunTests), - 'Expect didRunOneTest() was called once for each test.'); + pht( + 'Expect %s was called once for each test.', + 'didRunOneTest()')); $this->assertEqual( self::$distinctWillRunTests, self::$distinctDidRunTests, - 'Expect same tests had pre- and post-run callbacks invoked.'); + pht('Expect same tests had pre-run and post-run callbacks invoked.')); } public function __destruct() { if (self::$allTestsCounter !== 0) { throw new Exception( - 'didRunTests() was not called correctly after tests completed!'); + pht( + '%s was not called correctly after tests completed!', + 'didRunTests()')); } } @@ -54,14 +62,14 @@ final class PhutilUnitTestEngineTestCase extends ArcanistTestCase { $this->assertEqual( 1, self::$oneTestCounter, - 'Expect willRunOneTest depth to be one.'); + pht('Expect %s depth to be one.', 'willRunOneTest()')); self::$distinctDidRunTests[$test] = true; self::$oneTestCounter--; } public function testPass() { - $this->assertEqual(1, 1, 'This test is expected to pass.'); + $this->assertEqual(1, 1, pht('This test is expected to pass.')); } public function testFailSkip() { @@ -74,11 +82,11 @@ final class PhutilUnitTestEngineTestCase extends ArcanistTestCase { } else if ($result->getResult() == ArcanistUnitTestResult::RESULT_SKIP) { $skipped++; } else { - $this->assertFailure('These tests should either fail or skip.'); + $this->assertFailure(pht('These tests should either fail or skip.')); } } - $this->assertEqual(1, $failed, 'One test was expected to fail.'); - $this->assertEqual(1, $skipped, 'One test was expected to skip.'); + $this->assertEqual(1, $failed, pht('One test was expected to fail.')); + $this->assertEqual(1, $skipped, pht('One test was expected to skip.')); } public function testTryTestCases() { @@ -105,7 +113,7 @@ final class PhutilUnitTestEngineTestCase extends ArcanistTestCase { protected function throwIfFalsey($input) { if (!$input) { - throw new Exception('This is a negative test case!'); + throw new Exception(pht('This is a negative test case!')); } } diff --git a/src/unit/engine/phutil/ArcanistPhutilTestCase.php b/src/unit/engine/phutil/ArcanistPhutilTestCase.php index 96b9fdeb..3e10052b 100644 --- a/src/unit/engine/phutil/ArcanistPhutilTestCase.php +++ b/src/unit/engine/phutil/ArcanistPhutilTestCase.php @@ -111,14 +111,14 @@ abstract class ArcanistPhutilTestCase { $output .= "\n"; if (strpos($expect, "\n") === false && strpos($result, "\n") === false) { - $output .= "Expected: {$expect}\n"; - $output .= " Actual: {$result}"; + $output .= pht("Expected: %s\n Actual: %s", $expect, $result); } else { - $output .= "Expected vs Actual Output Diff\n"; - $output .= ArcanistDiffUtils::renderDifferences( - $expect, - $result, - $lines = 0xFFFF); + $output .= pht( + "Expected vs Actual Output Diff\n%s", + ArcanistDiffUtils::renderDifferences( + $expect, + $result, + $lines = 0xFFFF)); } $this->failTest($output); @@ -216,7 +216,7 @@ abstract class ArcanistPhutilTestCase { if (count($inputs) !== count($expect)) { $this->assertFailure( - 'Input and expectations must have the same number of values.'); + pht('Input and expectations must have the same number of values.')); } $labels = array_keys($inputs); @@ -243,18 +243,23 @@ abstract class ArcanistPhutilTestCase { if ($expect === $actual) { if ($expect) { - $message = "Test case '{$label}' did not throw, as expected."; + $message = pht("Test case '%s' did not throw, as expected.", $label); } else { - $message = "Test case '{$label}' threw, as expected."; + $message = pht("Test case '%s' threw, as expected.", $label); } } else { if ($expect) { - $message = "Test case '{$label}' was expected to succeed, but it ". - "raised an exception of class ".get_class($ex)." with ". - "message: ".$ex->getMessage(); + $message = pht( + "Test case '%s' was expected to succeed, but it ". + "raised an exception of class %s with message: %s", + $label, + get_class($ex), + $ex->getMessage()); } else { - $message = "Test case '{$label}' was expected to raise an ". - "exception, but it did not throw anything."; + $message = pht( + "Test case '%s' was expected to raise an ". + "exception, but it did not throw anything.", + $label); } } @@ -498,7 +503,7 @@ abstract class ArcanistPhutilTestCase { throw head($exceptions); } else { throw new PhutilAggregateException( - 'Multiple exceptions were raised during test execution.', + pht('Multiple exceptions were raised during test execution.'), $exceptions); } } @@ -518,7 +523,12 @@ abstract class ArcanistPhutilTestCase { $ex_class = get_class($ex); $ex_message = $ex->getMessage(); $ex_trace = $ex->getTraceAsString(); - $message = "EXCEPTION ({$ex_class}): {$ex_message}\n{$ex_trace}"; + $message = sprintf( + "%s (%s): %s\n%s", + pht('EXCEPTION'), + $ex_class, + $ex_message, + $ex_trace); $this->failTest($message); } } @@ -599,7 +609,7 @@ abstract class ArcanistPhutilTestCase { final private function assertCoverageAvailable() { if (!function_exists('xdebug_start_code_coverage')) { throw new Exception( - "You've enabled code coverage but XDebug is not installed."); + pht("You've enabled code coverage but XDebug is not installed.")); } } diff --git a/src/unit/parser/ArcanistGoTestResultParser.php b/src/unit/parser/ArcanistGoTestResultParser.php index 41463f10..fa0a2672 100644 --- a/src/unit/parser/ArcanistGoTestResultParser.php +++ b/src/unit/parser/ArcanistGoTestResultParser.php @@ -122,7 +122,6 @@ final class ArcanistGoTestResultParser extends ArcanistTestResultParser { } private function fixNames($test_case_results, $test_case_name) { - foreach ($test_case_results as &$result) { $test_name = $result->getName(); $result->setName('Go::Test::'.$test_case_name.'::'.$test_name); diff --git a/src/unit/parser/ArcanistPhpunitTestResultParser.php b/src/unit/parser/ArcanistPhpunitTestResultParser.php index 1710f71a..314c8265 100644 --- a/src/unit/parser/ArcanistPhpunitTestResultParser.php +++ b/src/unit/parser/ArcanistPhpunitTestResultParser.php @@ -170,12 +170,13 @@ final class ArcanistPhpunitTestResultParser extends ArcanistTestResultParser { private function getJsonReport($json) { if (empty($json)) { - throw new Exception('JSON report file is empty, '. - 'it probably means that phpunit failed to run tests. '. - 'Try running arc unit with --trace option and then run '. - 'generated phpunit command yourself, you might get the '. - 'answer.' - ); + throw new Exception( + pht( + 'JSON report file is empty, it probably means that phpunit '. + 'failed to run tests. Try running %s with %s option and then run '. + 'generated phpunit command yourself, you might get the answer.', + 'arc unit', + '--trace')); } $json = preg_replace('/}{\s*"/', '},{"', $json); diff --git a/src/unit/parser/ArcanistXUnitTestResultParser.php b/src/unit/parser/ArcanistXUnitTestResultParser.php index fead0ab0..3f1f447d 100644 --- a/src/unit/parser/ArcanistXUnitTestResultParser.php +++ b/src/unit/parser/ArcanistXUnitTestResultParser.php @@ -16,7 +16,10 @@ final class ArcanistXUnitTestResultParser { public function parseTestResults($test_results) { if (!strlen($test_results)) { throw new Exception( - 'test_results argument to parseTestResults must not be empty'); + pht( + '%s argument to %s must not be empty', + 'test_results', + 'parseTestResults()')); } // xunit xsd: https://gist.github.com/959290 @@ -28,7 +31,10 @@ final class ArcanistXUnitTestResultParser { ->setMaximumGlyphs(150) ->truncateString($test_results); throw new Exception( - "Failed to load XUnit report; Input starts with:\n\n {$input_start}"); + sprintf( + "%s\n\n%s", + pht('Failed to load XUnit report; Input starts with:'), + $input_start)); } $results = array(); diff --git a/src/unit/parser/__tests__/XUnitTestResultParserTestCase.php b/src/unit/parser/__tests__/XUnitTestResultParserTestCase.php index 2157a80b..84c93dca 100644 --- a/src/unit/parser/__tests__/XUnitTestResultParserTestCase.php +++ b/src/unit/parser/__tests__/XUnitTestResultParserTestCase.php @@ -28,7 +28,7 @@ final class XUnitTestResultParserTestCase extends ArcanistTestCase { $parsed_results = id(new ArcanistXUnitTestResultParser()) ->parseTestResults(''); - $this->failTest('Should throw on empty input'); + $this->failTest(pht('Should throw on empty input')); } catch (Exception $e) { // OK } @@ -43,7 +43,7 @@ final class XUnitTestResultParserTestCase extends ArcanistTestCase { $parsed_results = id(new ArcanistXUnitTestResultParser()) ->parseTestResults($stubbed_results); - $this->failTest('Should throw on non-xml input'); + $this->failTest(pht('Should throw on non-xml input')); } catch (Exception $e) { // OK } diff --git a/src/unit/renderer/ArcanistUnitConsoleRenderer.php b/src/unit/renderer/ArcanistUnitConsoleRenderer.php index 0f93aad0..c2e95c01 100644 --- a/src/unit/renderer/ArcanistUnitConsoleRenderer.php +++ b/src/unit/renderer/ArcanistUnitConsoleRenderer.php @@ -36,16 +36,32 @@ final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer { } private function getFormattedResult($result) { - static $status_codes = array( - ArcanistUnitTestResult::RESULT_PASS => '** PASS **', - ArcanistUnitTestResult::RESULT_FAIL => '** FAIL **', - ArcanistUnitTestResult::RESULT_SKIP => '** SKIP **', - ArcanistUnitTestResult::RESULT_BROKEN => '** BROKEN **', - ArcanistUnitTestResult::RESULT_UNSOUND => '** UNSOUND **', - ArcanistUnitTestResult::RESULT_POSTPONED => - '** POSTPONED **', - ); - return phutil_console_format($status_codes[$result]); + switch ($result) { + case ArcanistUnitTestResult::RESULT_PASS: + return phutil_console_format('** %s **', pht('PASS')); + + case ArcanistUnitTestResult::RESULT_FAIL: + return phutil_console_format('** %s **', pht('FAIL')); + + case ArcanistUnitTestResult::RESULT_SKIP: + return phutil_console_format('** %s **', pht('SKIP')); + + case ArcanistUnitTestResult::RESULT_BROKEN: + return phutil_console_format('** %s **', pht('BROKEN')); + + case ArcanistUnitTestResult::RESULT_UNSOUND: + return phutil_console_format( + '** %s **', + pht('UNSOUND')); + + case ArcanistUnitTestResult::RESULT_POSTPONED: + return phutil_console_format( + '** %s **', + pht('POSTPONED')); + + default: + return null; + } } private function formatTestDuration($seconds) { diff --git a/src/workflow/ArcanistAliasWorkflow.php b/src/workflow/ArcanistAliasWorkflow.php index 40cf9a94..9762821d 100644 --- a/src/workflow/ArcanistAliasWorkflow.php +++ b/src/workflow/ArcanistAliasWorkflow.php @@ -91,22 +91,24 @@ EOTEXT implode(' ' , $binding)); } } else { - echo "You haven't defined any aliases yet.\n"; + echo pht("You haven't defined any aliases yet.")."\n"; } } else if (count($argv) == 1) { if (empty($aliases[$argv[0]])) { - echo "No alias '{$argv[0]}' to remove.\n"; + echo pht("No alias '%s' to remove.", $argv[0])."\n"; } else { - echo phutil_console_format( - "'**arc %s**' is currently aliased to '**arc %s**'.", - $argv[0], - implode(' ', $aliases[$argv[0]])); - $ok = phutil_console_confirm('Delete this alias?'); + echo pht( + "'%s' is currently aliased to '%s'.", + phutil_console_format('**arc %s**', $argv[0]), + phutil_console_format( + '**arc %s**', + implode(' ', $aliases[$argv[0]]))); + $ok = phutil_console_confirm(pht('Delete this alias?')); if ($ok) { $was = implode(' ', $aliases[$argv[0]]); unset($aliases[$argv[0]]); $this->writeAliases($aliases); - echo "Unaliased '{$argv[0]}' (was '{$was}').\n"; + echo pht("Unaliased '%s' (was '%s').", $argv[0], $was)."\n"; } else { throw new ArcanistUserAbortException(); } @@ -116,15 +118,18 @@ EOTEXT if ($arc_config->buildWorkflow($argv[0])) { throw new ArcanistUsageException( - "You can not create an alias for '{$argv[0]}' because it is a ". - "builtin command. 'arc alias' can only create new commands."); + pht( + "You can not create an alias for '%s' because it is a ". + "builtin command. '%s' can only create new commands.", + $argv[0], + 'arc alias')); } $aliases[$argv[0]] = array_slice($argv, 1); - echo phutil_console_format( - "Aliased '**arc %s**' to '**arc %s**'.\n", - $argv[0], - implode(' ', $aliases[$argv[0]])); + echo pht( + "Aliased '%s' to '%s'.\n", + phutil_console_format('**arc %s**', $argv[0]), + phutil_console_format('**arc %s**', implode(' ', $aliases[$argv[0]]))); $this->writeAliases($aliases); } diff --git a/src/workflow/ArcanistAmendWorkflow.php b/src/workflow/ArcanistAmendWorkflow.php index 334ff9d2..e660d890 100644 --- a/src/workflow/ArcanistAmendWorkflow.php +++ b/src/workflow/ArcanistAmendWorkflow.php @@ -67,21 +67,25 @@ EOTEXT if (!$is_show) { if (!$repository_api->supportsAmend()) { throw new ArcanistUsageException( - "You may only run 'arc amend' in a git or hg (version ". - "2.2 or newer) working copy."); + pht( + "You may only run '%s' in a git or hg ". + "(version 2.2 or newer) working copy.", + 'arc amend')); } if ($this->isHistoryImmutable()) { throw new ArcanistUsageException( - 'This project is marked as adhering to a conservative history '. - 'mutability doctrine (having an immutable local history), which '. - 'precludes amending commit messages.'); + pht( + 'This project is marked as adhering to a conservative history '. + 'mutability doctrine (having an immutable local history), which '. + 'precludes amending commit messages.')); } if ($repository_api->getUncommittedChanges()) { throw new ArcanistUsageException( - 'You have uncommitted changes in this branch. Stage and commit (or '. - 'revert) them before proceeding.'); + pht( + 'You have uncommitted changes in this branch. Stage and commit '. + '(or revert) them before proceeding.')); } } @@ -101,14 +105,18 @@ EOTEXT if (!$revision_id) { if (count($in_working_copy) == 0) { throw new ArcanistUsageException( - "No revision specified with '--revision', and no revisions found ". - "in the working copy. Use '--revision ' to specify which ". - "revision you want to amend."); + pht( + "No revision specified with '%s', and no revisions found ". + "in the working copy. Use '%s' to specify which revision ". + "you want to amend.", + '--revision', + '--revision ')); } else if (count($in_working_copy) > 1) { - $message = "More than one revision was found in the working copy:\n". - $this->renderRevisionList($in_working_copy)."\n". - "Use '--revision ' to specify which revision you want to ". - "amend."; + $message = pht( + "More than one revision was found in the working copy:\n%s\n". + "Use '%s' to specify which revision you want to amend.", + $this->renderRevisionList($in_working_copy), + '--revision '); throw new ArcanistUsageException($message); } else { $revision_id = key($in_working_copy); @@ -123,9 +131,11 @@ EOTEXT $other_author = $other_author[$revision['authorPHID']]; $rev_title = $revision['title']; $ok = phutil_console_confirm( - "You are amending the revision 'D{$revision_id}: {$rev_title}' ". - "but you are not the author. Amend this revision by ". - "{$other_author}?"); + pht( + "You are amending the revision '%s' but you are not ". + "the author. Amend this revision by %s?", + "D{$revision_id}: {$rev_title}", + $other_author)); if (!$ok) { throw new ArcanistUserAbortException(); } @@ -146,7 +156,7 @@ EOTEXT throw $ex; } else { throw new ArcanistUsageException( - "Revision D{$revision_id} does not exist." + pht("Revision '%s' does not exist.", "D{$revision_id}") ); } } @@ -158,7 +168,7 @@ EOTEXT )); if (empty($revision)) { throw new Exception( - "Failed to lookup information for 'D{$revision_id}'!"); + pht("Failed to lookup information for '%s'!", "D{$revision_id}")); } $revision = head($revision); $revision_title = $revision['title']; @@ -166,9 +176,11 @@ EOTEXT if (!$is_show) { if ($revision_id && empty($in_working_copy[$revision_id])) { $ok = phutil_console_confirm( - "The revision 'D{$revision_id}' does not appear to be in the ". - "working copy. Are you sure you want to amend HEAD with the ". - "commit message for 'D{$revision_id}: {$revision_title}'?"); + pht( + "The revision '%s' does not appear to be in the working copy. Are ". + "you sure you want to amend HEAD with the commit message for '%s'?", + "D{$revision_id}", + "D{$revision_id}: {$revision_title}")); if (!$ok) { throw new ArcanistUserAbortException(); } @@ -178,9 +190,12 @@ EOTEXT if ($is_show) { echo $message."\n"; } else { - echo phutil_console_format( - "Amending commit message to reflect revision **%s**.\n", - "D{$revision_id}: {$revision_title}"); + echo pht( + "Amending commit message to reflect revision %s.\n", + phutil_console_format( + '**D%d: %s**', + $revision_id, + $revision_title)); $repository_api->amendCommit($message); } diff --git a/src/workflow/ArcanistBackoutWorkflow.php b/src/workflow/ArcanistBackoutWorkflow.php index f4667a35..bd554e18 100644 --- a/src/workflow/ArcanistBackoutWorkflow.php +++ b/src/workflow/ArcanistBackoutWorkflow.php @@ -61,16 +61,16 @@ EOTEXT )); if (!$revisions) { throw new ArcanistUsageException( - 'The revision you provided does not exist!'); + pht('The revision you provided does not exist!')); } $revision = $revisions[0]; $commits = $revision['commits']; if (!$commits) { throw new ArcanistUsageException( - 'This revision has not been committed yet!'); + pht('This revision has not been committed yet!')); } else if (count($commits) > 1) { throw new ArcanistUsageException( - 'The revision you provided has multiple commits!'); + pht('The revision you provided has multiple commits!')); } $commit_phid = $commits[0]; $commit = $conduit->callMethodSynchronous( @@ -144,11 +144,11 @@ EOTEXT $repository_api->isHgSubversionRepo(); $revision_id = null; - $console->writeOut("Starting backout\n"); + $console->writeOut(pht('Starting backout.')."\n"); $input = $this->getArgument('input'); if (!$input || count($input) != 1) { throw new ArcanistUsageException( - 'You must specify one commit to backout!'); + pht('You must specify one commit to backout!')); } // Input looks like a Differential revision, so @@ -175,14 +175,15 @@ EOTEXT // Run 'backout'. $subject = $repository_api->getCommitSummary($commit_hash); - $console->writeOut("Backing out commit {$commit_hash} {$subject} \n"); + $console->writeOut( + pht('Backing out commit %s %s', $commit_hash, $subject)."\n"); $repository_api->backoutCommit($commit_hash); // Create commit message and execute the commit $message = $this->buildCommitMessage($commit_hash); $repository_api->doCommit($message); - $console->writeOut("Double-check the commit and push when ready\n"); + $console->writeOut(pht('Double-check the commit and push when ready.')."\n"); } } diff --git a/src/workflow/ArcanistBrowseWorkflow.php b/src/workflow/ArcanistBrowseWorkflow.php index 9653affe..76aa66dd 100644 --- a/src/workflow/ArcanistBrowseWorkflow.php +++ b/src/workflow/ArcanistBrowseWorkflow.php @@ -37,7 +37,8 @@ EOTEXT 'branch' => array( 'param' => 'branch_name', 'help' => pht( - 'Default branch name to view on server. Defaults to "master".'), + 'Default branch name to view on server. Defaults to "%s".', + 'master'), ), 'force' => array( 'help' => pht( @@ -74,7 +75,8 @@ EOTEXT throw new ArcanistUsageException( pht( 'Specify one or more paths or objects to browse. Use the command '. - '"arc browse ." if you want to browse this directory.')); + '"%s" if you want to browse this directory.', + 'arc browse .')); } $things = array_fuse($things); @@ -182,21 +184,25 @@ EOTEXT } else { if ($things) { $console->writeOut( + "%s\n", pht( "The current working directory is not a repository working ". "copy, so remaining arguments can not be resolved as paths or ". "commits. To browse paths or symbolic commits in Diffusion, run ". - "'arc browse' from inside a working copy.")."\n"); + "'%s' from inside a working copy.", + 'arc browse')); } } foreach ($things as $thing) { $console->writeOut( + "%s\n", pht( 'Unable to find an object named **%s**, no such commit exists in '. 'the remote, and no such path exists in the working copy. Use '. - '__--force__ to treat this as a path anyway.', - $thing)."\n"); + '__%s__ to treat this as a path anyway.', + $thing, + '--force')); } if ($uris) { @@ -212,8 +218,10 @@ EOTEXT throw new ArcanistUsageException( pht( 'arc is unable to determine which repository in Diffusion '. - 'this working copy belongs to. Use "arc which" to understand how '. - 'arc looks for a repository.')); + 'this working copy belongs to. Use "%s" to understand how '. + '%s looks for a repository.', + 'arc which', + 'arc')); } $branch = $this->getArgument('branch', 'master'); diff --git a/src/workflow/ArcanistCloseRevisionWorkflow.php b/src/workflow/ArcanistCloseRevisionWorkflow.php index 5e234284..af1e3031 100644 --- a/src/workflow/ArcanistCloseRevisionWorkflow.php +++ b/src/workflow/ArcanistCloseRevisionWorkflow.php @@ -32,13 +32,14 @@ EOTEXT public function getArguments() { return array( 'finalize' => array( - 'help' => + 'help' => pht( "Close only if the repository is untracked and the revision is ". "accepted. Continue even if the close can't happen. This is a soft ". - "version of 'close-revision' used by other workflows.", + "version of '' used by other workflows.", + 'close-revision'), ), 'quiet' => array( - 'help' => 'Do not print a success message.', + 'help' => pht('Do not print a success message.'), ), '*' => 'revision', ); @@ -68,11 +69,15 @@ EOTEXT $revision_list = $this->getArgument('revision', array()); if (!$revision_list) { throw new ArcanistUsageException( - 'close-revision requires a revision number.'); + pht( + '%s requires a revision number.', + 'close-revision')); } if (count($revision_list) != 1) { throw new ArcanistUsageException( - 'close-revision requires exactly one revision.'); + pht( + '%s requires exactly one revision.', + 'close-revision')); } $revision_id = reset($revision_list); $revision_id = $this->normalizeRevisionID($revision_id); @@ -86,8 +91,9 @@ EOTEXT if (!$revision && !$is_finalize) { throw new ArcanistUsageException( - "Revision D{$revision_id} does not exist." - ); + pht( + 'Revision %s does not exist.', + "D{$revision_id}")); } $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; @@ -95,14 +101,18 @@ EOTEXT if (!$is_finalize && $revision['status'] != $status_accepted) { throw new ArcanistUsageException( - "Revision D{$revision_id} can not be closed. You can only close ". - "revisions which have been 'accepted'."); + pht( + "Revision %s can not be closed. You can only close ". + "revisions which have been 'accepted'.", + "D{$revision_id}")); } if ($revision) { if (!$is_finalize && $revision['authorPHID'] != $this->getUserPHID()) { - $prompt = "You are not the author of revision D{$revision_id}, ". - 'are you sure you want to close it?'; + $prompt = pht( + 'You are not the author of revision %s, '. + 'are you sure you want to close it?', + "D{$revision_id}"); if (!phutil_console_confirm($prompt)) { throw new ArcanistUserAbortException(); } @@ -118,7 +128,10 @@ EOTEXT if ($actually_close) { $revision_name = $revision['title']; - echo "Closing revision D{$revision_id} '{$revision_name}'...\n"; + echo pht( + "Closing revision %s '%s'...\n", + "D{$revision_id}", + $revision_name); $conduit->callMethodSynchronous( 'differential.close', @@ -143,7 +156,7 @@ EOTEXT $message = $this->getRepositoryAPI()->getFinalizedRevisionMessage(); echo phutil_console_wrap($message)."\n"; } else { - echo "Done.\n"; + echo pht('Done.')."\n"; } } diff --git a/src/workflow/ArcanistCloseWorkflow.php b/src/workflow/ArcanistCloseWorkflow.php index 083ec355..b32b9caa 100644 --- a/src/workflow/ArcanistCloseWorkflow.php +++ b/src/workflow/ArcanistCloseWorkflow.php @@ -18,13 +18,13 @@ final class ArcanistCloseWorkflow extends ArcanistWorkflow { private function getStatusOptions() { if ($this->statusData === null) { - throw new Exception('loadStatusData first!'); + throw new Exception(pht('Call %s first!', 'loadStatusData()')); } return idx($this->statusData, 'statusMap'); } private function getDefaultClosedStatus() { if ($this->statusData === null) { - throw new Exception('loadStatusData first!'); + throw new Exception(pht('Call %s first!', 'loadStatusData()')); } return idx($this->statusData, 'defaultClosedStatus'); } @@ -73,10 +73,11 @@ EOTEXT 'short' => 's', 'help' => pht( 'Specify a new status. Valid status options can be '. - 'seen with the `list-statuses` argument.'), + 'seen with the `%s` argument.', + 'list-statuses'), ), 'list-statuses' => array( - 'help' => 'Show available status options and exit.', + 'help' => pht('Show available status options and exit.'), ), ); } @@ -85,9 +86,11 @@ EOTEXT $this->loadStatusData(); $list_statuses = $this->getArgument('list-statuses'); if ($list_statuses) { - echo phutil_console_format(pht( - "Valid status options are:\n". - "\t%s\n", implode($this->getStatusOptions(), ', '))); + echo phutil_console_format( + "%s\n", + pht( + "Valid status options are:\n\t%s", + implode($this->getStatusOptions(), ', '))); return 0; } $ids = $this->getArgument('task_id'); @@ -102,23 +105,33 @@ EOTEXT if (!isset($status_options[$status])) { $options = array_keys($status_options); $last = array_pop($options); - echo "Invalid status {$status}, valid options are ". - implode(', ', $options).", or {$last}.\n"; + echo pht( + "Invalid status %s, valid options are %s, or %s.\n", + $status, + implode(', ', $options), + $last); + return; } foreach ($ids as $id) { if (!preg_match('/^T?\d+$/', $id)) { - echo "Invalid Task ID: {$id}.\n"; + echo pht('Invalid Task ID: %s.', $id)."\n"; return 1; } $id = ltrim($id, 'T'); $result = $this->closeTask($id, $status, $message); $current_status = $status_options[$status]; if ($result) { - echo "T{$id}'s status is now set to {$current_status}.\n"; + echo pht( + "%s's status is now set to %s.\n", + "T{$id}", + $current_status); } else { - echo "T{$id} is already set to {$current_status}.\n"; + echo pht( + "%s is already set to %s.\n", + "T{$id}", + $current_status); } } return 0; diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php index 6c727b5a..72dae0ff 100644 --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -49,15 +49,15 @@ EOTEXT public function getArguments() { return array( 'show' => array( - 'help' => + 'help' => pht( 'Show the command which would be issued, but do not actually '. - 'commit anything.', + 'commit anything.'), ), 'revision' => array( 'param' => 'revision_id', - 'help' => + 'help' => pht( 'Commit a specific revision. If you do not specify a revision, '. - 'arc will look for committable revisions.', + 'arc will look for committable revisions.'), ), ); } @@ -76,13 +76,17 @@ EOTEXT if (count($revisions) == 0) { throw new ArcanistUsageException( - "Unable to identify the revision in the working copy. Use ". - "'--revision ' to select a revision."); + pht( + "Unable to identify the revision in the working copy. Use ". + "'%s' to select a revision.", + '--revision ')); } else if (count($revisions) > 1) { throw new ArcanistUsageException( - "More than one revision exists in the working copy:\n\n". - $this->renderRevisionList($revisions)."\n". - "Use '--revision ' to select a revision."); + pht( + "More than one revision exists in the working copy:\n\n%s\n". + "Use '%s' to select a revision.", + $this->renderRevisionList($revisions), + '--revision ')); } } else { @@ -94,7 +98,9 @@ EOTEXT if (count($revisions) == 0) { throw new ArcanistUsageException( - "Revision 'D{$revision_id}' does not exist."); + pht( + "Revision '%s' does not exist.", + "D{$revision_id}")); } } @@ -129,7 +135,10 @@ EOTEXT } $revision_title = $revision['title']; - echo "Committing 'D{$revision_id}: {$revision_title}'...\n"; + echo pht( + "Committing '%s: %s'...\n", + "D{$revision_id}", + $revision_title); $files = $this->getCommitFileList($revision); @@ -151,7 +160,7 @@ EOTEXT $err = phutil_passthru('%C', $command); if ($err) { - throw new Exception("Executing 'svn commit' failed!"); + throw new Exception(pht("Executing '%s' failed!", 'svn commit')); } $this->askForRepositoryUpdate(); @@ -199,12 +208,15 @@ EOTEXT foreach ($commit_paths as $will_commit => $ignored) { if (Filesystem::isDescendant($path, $will_commit)) { throw new ArcanistUsageException( - "This commit includes the directory '{$will_commit}', but ". - "it contains a modified path ('{$path}') which is NOT included ". - "in the commit. Subversion can not handle this operation and ". - "will commit the path anyway. You need to sort out the working ". - "copy changes to '{$path}' before you may proceed with the ". - "commit."); + pht( + "This commit includes the directory '%s', but it contains a ". + "modified path ('%s') which is NOT included in the commit. ". + "Subversion can not handle this operation and will commit the ". + "path anyway. You need to sort out the working copy changes to ". + "'%s' before you may proceed with the commit.", + $will_commit, + $path, + $path)); } } $modified_but_not_included[] = $path; @@ -249,7 +261,9 @@ EOTEXT if (empty($files)) { throw new ArcanistUsageException( - 'There is nothing left to commit. None of the modified paths exist.'); + pht( + 'There is nothing left to commit. '. + 'None of the modified paths exist.')); } return $files; @@ -303,24 +317,29 @@ EOTEXT $confirm = array(); if ($revision['status'] != ArcanistDifferentialRevisionStatus::ACCEPTED) { - $confirm[] = - "Revision 'D{$revision_id}: {$revision_title}' has not been accepted. ". - "Commit this revision anyway?"; + $confirm[] = pht( + "Revision '%s: %s' has not been accepted. Commit this revision anyway?", + "D{$revision_id}", + $revision_title); } if ($revision['authorPHID'] != $this->getUserPHID()) { - $confirm[] = - "You are not the author of 'D{$revision_id}: {$revision_title}'. ". - "Commit this revision anyway?"; + $confirm[] = pht( + "You are not the author of '%s: %s'. Commit this revision anyway?", + "D{$revision_id}", + $revision_title); } $revision_source = idx($revision, 'branch'); $current_source = $repository_api->getBranchName(); if ($revision_source != $current_source) { - $confirm[] = - "Revision 'D{$revision_id}: {$revision_title}' was generated from ". - "'{$revision_source}', but current working copy root is ". - "'{$current_source}'. Commit this revision anyway?"; + $confirm[] = pht( + "Revision '%s: %s' was generated from '%s', but current working ". + "copy root is '%s'. Commit this revision anyway?", + "D{$revision_id}", + $revision_title, + $revision_source, + $current_source); } foreach ($confirm as $thing) { diff --git a/src/workflow/ArcanistCoverWorkflow.php b/src/workflow/ArcanistCoverWorkflow.php index 5e984cf9..35c3c891 100644 --- a/src/workflow/ArcanistCoverWorkflow.php +++ b/src/workflow/ArcanistCoverWorkflow.php @@ -31,13 +31,13 @@ EOTEXT return array( 'rev' => array( 'param' => 'revision', - 'help' => 'Cover changes since a specific revision.', + 'help' => pht('Cover changes since a specific revision.'), 'supports' => array( 'git', 'hg', ), 'nosupport' => array( - 'svn' => 'cover does not currently support --rev in svn.', + 'svn' => pht('cover does not currently support %s in svn.', '--rev'), ), ), '*' => 'paths', @@ -78,7 +78,7 @@ EOTEXT if (!$paths) { throw new ArcanistNoEffectException( - "You're covered, you didn't change anything."); + pht("You're covered, you didn't change anything.")); } $covers = array(); @@ -126,7 +126,8 @@ EOTEXT } } } else { - echo "You're covered, your changes didn't touch anyone else's code.\n"; + echo pht( + "You're covered, your changes didn't touch anyone else's code.\n"); } return 0; diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 78621a73..34754966 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -2395,9 +2395,12 @@ EOTEXT $title = $revision['title']; throw new ArcanistUsageException( - "You don't own revision D{$id} '{$title}'. You can only update ". - "revisions you own. You can 'Commandeer' this revision from the web ". - "interface if you want to become the owner."); + pht( + "You don't own revision %s '%s'. You can only update revisions ". + "you own. You can 'Commandeer' this revision from the web ". + "interface if you want to become the owner.", + "D{$id}", + $title)); } @@ -2524,12 +2527,14 @@ EOTEXT $change->setMetadata("{$type}:binary-phid", $phid); echo pht("Uploaded '%s' (%s).", $name, $type)."\n"; } catch (Exception $e) { - echo "Failed to upload {$type} binary '{$name}'.\n\n"; + echo pht("Failed to upload %s binary '%s'.", $type, $name)."\n\n"; echo $e->getMessage()."\n"; - if (!phutil_console_confirm('Continue?', $default_no = false)) { + if (!phutil_console_confirm(pht('Continue?'), $default_no = false)) { throw new ArcanistUsageException( - 'Aborted due to file upload failure. You can use --skip-binaries '. - 'to skip binary uploads.'); + pht( + 'Aborted due to file upload failure. You can use %s '. + 'to skip binary uploads.', + '--skip-binaries')); } } } diff --git a/src/workflow/ArcanistDownloadWorkflow.php b/src/workflow/ArcanistDownloadWorkflow.php index bb320af3..49cb8117 100644 --- a/src/workflow/ArcanistDownloadWorkflow.php +++ b/src/workflow/ArcanistDownloadWorkflow.php @@ -34,15 +34,18 @@ EOTEXT return array( 'show' => array( 'conflicts' => array( - 'as' => - 'Use --show to direct the file to stdout, or --as to direct '. + 'as' => pht( + 'Use %s to direct the file to stdout, or %s to direct '. 'it to a named location.', + '--show', + '--as'), ), - 'help' => 'Write file to stdout instead of to disk.', + 'help' => pht('Write file to stdout instead of to disk.'), ), 'as' => array( 'param' => 'name', - 'help' => 'Save the file with a specific name rather than the default.', + 'help' => pht( + 'Save the file with a specific name rather than the default.'), ), '*' => 'argv', ); @@ -51,15 +54,17 @@ EOTEXT protected function didParseArguments() { $argv = $this->getArgument('argv'); if (!$argv) { - throw new ArcanistUsageException('Specify a file to download.'); + throw new ArcanistUsageException(pht('Specify a file to download.')); } if (count($argv) > 1) { - throw new ArcanistUsageException('Specify exactly one file to download.'); + throw new ArcanistUsageException( + pht('Specify exactly one file to download.')); } $file = reset($argv); if (!preg_match('/^F?\d+$/', $file)) { - throw new ArcanistUsageException('Specify file by ID, e.g. F123.'); + throw new ArcanistUsageException( + pht('Specify file by ID, e.g. %s.', 'F123')); } $this->id = (int)ltrim($file, 'F'); @@ -72,10 +77,9 @@ EOTEXT } public function run() { - $conduit = $this->getConduit(); - $this->writeStatusMessage("Getting file information...\n"); + $this->writeStatusMessage(pht('Getting file information...')."\n"); $info = $conduit->callMethodSynchronous( 'file.info', array( @@ -88,7 +92,7 @@ EOTEXT $desc = "'".$info['name']."' ".$desc; } - $this->writeStatusMessage("Downloading file {$desc}...\n"); + $this->writeStatusMessage(pht('Downloading file %s...', $desc)."\n"); $data = $conduit->callMethodSynchronous( 'file.download', array( @@ -103,7 +107,7 @@ EOTEXT $path = Filesystem::writeUniqueFile( nonempty($this->saveAs, $info['name'], 'file'), $data); - $this->writeStatusMessage("Saved file as '{$path}'.\n"); + $this->writeStatusMessage(pht("Saved file as '%s'.", $path)."\n"); } return 0; diff --git a/src/workflow/ArcanistExportWorkflow.php b/src/workflow/ArcanistExportWorkflow.php index 01abb79f..d3e3b396 100644 --- a/src/workflow/ArcanistExportWorkflow.php +++ b/src/workflow/ArcanistExportWorkflow.php @@ -44,39 +44,44 @@ EOTEXT public function getArguments() { return array( 'git' => array( - 'help' => + 'help' => pht( "Export change as a git patch. This format is more complete than ". "unified, but less complete than arc bundles. These patches can be ". - "applied with 'git apply' or 'arc patch'.", + "applied with '%s' or '%s'.", + 'git apply', + 'arc patch'), ), 'unified' => array( - 'help' => + 'help' => pht( "Export change as a unified patch. This format is less complete ". "than git patches or arc bundles. These patches can be applied with ". - "'patch' or 'arc patch'.", + "'%s' or '%s'.", + 'patch', + 'arc patch'), ), 'arcbundle' => array( 'param' => 'file', - 'help' => + 'help' => pht( "Export change as an arc bundle. This format can represent all ". - "changes. These bundles can be applied with 'arc patch'.", + "changes. These bundles can be applied with '%s'.", + 'arc patch'), ), 'encoding' => array( 'param' => 'encoding', - 'help' => - 'Attempt to convert non UTF-8 patch into specified encoding.', + 'help' => pht( + 'Attempt to convert non UTF-8 patch into specified encoding.'), ), 'revision' => array( 'param' => 'revision_id', - 'help' => + 'help' => pht( 'Instead of exporting changes from the working copy, export them '. - 'from a Differential revision.', + 'from a Differential revision.'), ), 'diff' => array( 'param' => 'diff_id', - 'help' => + 'help' => pht( 'Instead of exporting changes from the working copy, export them '. - 'from a Differential diff.', + 'from a Differential diff.'), ), '*' => 'paths', ); @@ -102,8 +107,11 @@ EOTEXT if ($requested > 1) { throw new ArcanistUsageException( - "Options '--revision' and '--diff' are not compatible. Choose exactly ". - "one change source."); + pht( + "Options '%s' and '%s' are not compatible. Choose exactly ". + "one change source.", + '--revision', + '--diff')); } $format = null; @@ -123,12 +131,19 @@ EOTEXT if ($requested === 0) { throw new ArcanistUsageException( - "Specify one of '--git', '--unified' or '--arcbundle ' to ". - "choose an export format."); + pht( + "Specify one of '%s', '%s' or '%s' to choose an export format.", + '--git', + '--unified', + '--arcbundle ')); } else if ($requested > 1) { throw new ArcanistUsageException( - "Options '--git', '--unified' and '--arcbundle' are not compatible. ". - "Choose exactly one export format."); + pht( + "Options '%s', '%s' and '%s' are not compatible. ". + "Choose exactly one export format.", + '--git', + '--unified', + '--arcbundle')); } $this->format = $format; @@ -260,9 +275,9 @@ EOTEXT break; case self::FORMAT_BUNDLE: $path = $this->getArgument('arcbundle'); - echo "Writing bundle to '{$path}'...\n"; + echo pht("Writing bundle to '%s'...", $path)."\n"; $bundle->writeToDisk($path); - echo "done.\n"; + echo pht('Done.')."\n"; break; } diff --git a/src/workflow/ArcanistFeatureWorkflow.php b/src/workflow/ArcanistFeatureWorkflow.php index b69074a0..2fc70aad 100644 --- a/src/workflow/ArcanistFeatureWorkflow.php +++ b/src/workflow/ArcanistFeatureWorkflow.php @@ -53,17 +53,19 @@ EOTEXT public function getArguments() { return array( 'view-all' => array( - 'help' => 'Include closed and abandoned revisions.', + 'help' => pht('Include closed and abandoned revisions.'), ), 'by-status' => array( - 'help' => 'Sort branches by status instead of time.', + 'help' => pht('Sort branches by status instead of time.'), ), 'output' => array( 'param' => 'format', 'support' => array( 'json', ), - 'help' => "With 'json', show features in machine-readable JSON format.", + 'help' => pht( + "With '%s', show features in machine-readable JSON format.", + 'json'), ), '*' => 'branch', ); @@ -79,14 +81,15 @@ EOTEXT $names = $this->getArgument('branch'); if ($names) { if (count($names) > 2) { - throw new ArcanistUsageException('Specify only one branch.'); + throw new ArcanistUsageException(pht('Specify only one branch.')); } return $this->checkoutBranch($names); } $branches = $repository_api->getAllBranches(); if (!$branches) { - throw new ArcanistUsageException('No branches in this working copy.'); + throw new ArcanistUsageException( + pht('No branches in this working copy.')); } $branches = $this->loadCommitInfo($branches); @@ -302,7 +305,7 @@ EOTEXT $status = $revision['statusName']; } else { $desc = $branch['desc']; - $status = 'No Revision'; + $status = pht('No Revision'); } if (!$this->getArgument('view-all') && !$branch['current']) { diff --git a/src/workflow/ArcanistFlagWorkflow.php b/src/workflow/ArcanistFlagWorkflow.php index 2a7e06c2..d8420728 100644 --- a/src/workflow/ArcanistFlagWorkflow.php +++ b/src/workflow/ArcanistFlagWorkflow.php @@ -57,18 +57,18 @@ EOTEXT return array( '*' => 'objects', 'clear' => array( - 'help' => 'Delete the flag on an object.', + 'help' => pht('Delete the flag on an object.'), ), 'edit' => array( - 'help' => 'Edit the flag on an object.', + 'help' => pht('Edit the flag on an object.'), ), 'color' => array( 'param' => 'color', - 'help' => 'Set the color of a flag.', + 'help' => pht('Set the color of a flag.'), ), 'note' => array( 'param' => 'note', - 'help' => 'Set the note on a flag.', + 'help' => pht('Set the note on a flag.'), ), ); } @@ -114,10 +114,11 @@ EOTEXT $editing = $edit || ($color != -1) || $note; if ($editing && $clear) { - throw new ArcanistUsageException("You can't both edit and clear a flag."); + throw new ArcanistUsageException( + pht("You can't both edit and clear a flag.")); } if (($editing || $clear) && count($objects) != 1) { - throw new ArcanistUsageException('Specify exactly one object.'); + throw new ArcanistUsageException(pht('Specify exactly one object.')); } if (!empty($objects)) { @@ -131,7 +132,9 @@ EOTEXT if (isset($handles[$object])) { $phids[$object] = $handles[$object]['phid']; } else { - echo phutil_console_format("**%s** doesn't exist.\n", $object); + echo pht( + "%s doesn't exist.\n", + phutil_console_format('**%s**', $object)); } } if (empty($phids)) { @@ -153,7 +156,9 @@ EOTEXT 'objectPHID' => head($phids), )); if (!$flag) { - echo phutil_console_format("**%s** has no flag to clear.\n", $object); + echo pht( + "%s has no flag to clear.\n", + phutil_console_format('**%s**', $object)); } else { self::flagWasEdited($flag, 'deleted'); } @@ -186,7 +191,9 @@ EOTEXT 'objectPHID'); foreach ($phids as $object => $phid) { if (!isset($flags[$phid])) { - echo phutil_console_format("**%s** has no flag.\n", $object); + echo pht( + "%s has no flag.\n", + phutil_console_format('**%s**', $object)); } } @@ -196,7 +203,7 @@ EOTEXT // If the user passed object names, we already told them all their // objects are nonexistent or unflagged. if (empty($objects)) { - echo "You have no flagged objects.\n"; + echo pht('You have no flagged objects.')."\n"; } } else { // Print ALL the flags. With fancy formatting. Because fancy formatting diff --git a/src/workflow/ArcanistGetConfigWorkflow.php b/src/workflow/ArcanistGetConfigWorkflow.php index be5af003..565856bd 100644 --- a/src/workflow/ArcanistGetConfigWorkflow.php +++ b/src/workflow/ArcanistGetConfigWorkflow.php @@ -163,8 +163,8 @@ EOTEXT if (!$verbose) { $console->writeOut( - "%s\n", - pht('(Run with --verbose for more details.)')); + "(%s)\n", + pht('Run with %s for more details.', '--verbose')); } return 0; diff --git a/src/workflow/ArcanistHelpWorkflow.php b/src/workflow/ArcanistHelpWorkflow.php index 0a4af166..2792afde 100644 --- a/src/workflow/ArcanistHelpWorkflow.php +++ b/src/workflow/ArcanistHelpWorkflow.php @@ -46,7 +46,10 @@ EOTEXT $target = head($this->getArgument('command')); if (empty($workflows[$target])) { throw new ArcanistUsageException( - "Unrecognized command '{$target}'. Try 'arc help'."); + pht( + "Unrecognized command '%s'. Try '%s'.", + $target, + 'arc help')); } } @@ -109,19 +112,19 @@ EOTEXT } if (isset($config_arguments[$argument])) { - $optref[] = ' (This is a custom option for this '. - 'project.)'; + $optref[] = ' '. + pht('(This is a custom option for this project.)'); } if (isset($spec['supports'])) { - $optref[] = ' Supports: '. - implode(', ', $spec['supports']); + $optref[] = ' '. + pht('Supports: %s', implode(', ', $spec['supports'])); } if (isset($spec['help'])) { $docs = $spec['help']; } else { - $docs = 'This option is not documented.'; + $docs = pht('This option is not documented.'); } $docs = phutil_console_wrap($docs, 14); $optref[] = "{$docs}\n"; @@ -163,7 +166,9 @@ EOTEXT ); if (!$this->getArgument('full')) { - echo "Run 'arc help --full' to get commands and options descriptions.\n"; + echo pht( + "Run '%s' to get commands and options descriptions.\n", + 'arc help --full'); return; } diff --git a/src/workflow/ArcanistInstallCertificateWorkflow.php b/src/workflow/ArcanistInstallCertificateWorkflow.php index ae68f4f2..41f0726e 100644 --- a/src/workflow/ArcanistInstallCertificateWorkflow.php +++ b/src/workflow/ArcanistInstallCertificateWorkflow.php @@ -89,17 +89,17 @@ EOTEXT // Ignore. } - echo phutil_console_format("**LOGIN TO PHABRICATOR**\n"); - echo "Open this page in your browser and login to Phabricator if ". - "necessary:\n"; - echo "\n"; - echo " {$token_uri}\n"; - echo "\n"; - echo 'Then paste the API Token on that page below.'; - + echo phutil_console_format("**%s**\n", pht('LOGIN TO PHABRICATOR')); + echo phutil_console_format( + "%s\n\n%s\n\n%s", + pht( + 'Open this page in your browser and login to '. + 'Phabricator if necessary:'), + $token_uri, + pht('Then paste the API Token on that page below.')); do { - $token = phutil_console_prompt('Paste API Token from that page:'); + $token = phutil_console_prompt(pht('Paste API Token from that page:')); $token = trim($token); if (strlen($token)) { break; @@ -142,7 +142,7 @@ EOTEXT ); } else { echo "\n"; - echo "Downloading authentication certificate...\n"; + echo pht('Downloading authentication certificate...')."\n"; $info = $conduit->callMethodSynchronous( 'conduit.getcertificate', array( @@ -151,22 +151,26 @@ EOTEXT )); $user = $info['username']; - echo "Installing certificate for '{$user}'...\n"; + echo pht("Installing certificate for '%s'...", $user)."\n"; $config['hosts'][$uri] = array( 'user' => $user, 'cert' => $info['certificate'], ); } - echo "Writing ~/.arcrc...\n"; + echo pht('Writing %s...', '~/.arcrc')."\n"; $configuration_manager->writeUserConfigurationFile($config); if ($is_token_auth) { echo phutil_console_format( - "** SUCCESS! ** API Token installed.\n"); + "** %s ** %s\n", + pht('SUCCESS!'), + pht('API Token installed.')); } else { echo phutil_console_format( - "** SUCCESS! ** Certificate installed.\n"); + "** %s ** %s\n", + pht('SUCCESS!'), + pht('Certificate installed.')); } return 0; @@ -175,15 +179,17 @@ EOTEXT private function determineConduitURI() { $uri = $this->getArgument('uri'); if (count($uri) > 1) { - throw new ArcanistUsageException('Specify at most one URI.'); + throw new ArcanistUsageException(pht('Specify at most one URI.')); } else if (count($uri) == 1) { $uri = reset($uri); } else { $conduit_uri = $this->getConduitURI(); if (!$conduit_uri) { throw new ArcanistUsageException( - 'Specify an explicit URI or run this command from within a project '. - 'which is configured with a .arcconfig.'); + pht( + 'Specify an explicit URI or run this command from within a '. + 'project which is configured with a %s.', + '.arcconfig')); } $uri = $conduit_uri; } diff --git a/src/workflow/ArcanistLandWorkflow.php b/src/workflow/ArcanistLandWorkflow.php index 69c498ec..8f72f439 100644 --- a/src/workflow/ArcanistLandWorkflow.php +++ b/src/workflow/ArcanistLandWorkflow.php @@ -83,8 +83,10 @@ EOTEXT 'help' => pht( "Land feature branch onto a branch other than the default ". "('master' in git, 'default' in hg). You can change the default ". - "by setting 'arc.land.onto.default' with `arc set-config` or ". - "for the entire project in .arcconfig."), + "by setting '%s' with `%s` or for the entire project in %s.", + 'arc.land.onto.default', + 'arc set-config', + '.arcconfig'), ), 'hold' => array( 'help' => pht( @@ -102,22 +104,31 @@ EOTEXT ), 'merge' => array( 'help' => pht( - 'Perform a --no-ff merge, not a --squash merge. If the project '. + 'Perform a %s merge, not a %s merge. If the project '. 'is marked as having an immutable history, this is the default '. - 'behavior.'), + 'behavior.', + '--no-ff', + '--squash'), 'supports' => array( 'git', ), 'nosupport' => array( - 'hg' => pht('Use the --squash strategy when landing in mercurial.'), + 'hg' => pht( + 'Use the %s strategy when landing in mercurial.', + '--squash'), ), ), 'squash' => array( 'help' => pht( - 'Perform a --squash merge, not a --no-ff merge. If the project is '. - 'marked as having a mutable history, this is the default behavior.'), + 'Perform a %s merge, not a %s merge. If the project is '. + 'marked as having a mutable history, this is the default behavior.', + '--squash', + '--no-ff'), 'conflicts' => array( - 'merge' => '--merge and --squash are conflicting merge strategies.', + 'merge' => pht( + '%s and %s are conflicting merge strategies.', + '--merge', + '--squash'), ), ), 'delete-remote' => array( @@ -131,12 +142,16 @@ EOTEXT 'help' => pht( "When updating the feature branch, use rebase instead of merge. ". "This might make things work better in some cases. Set ". - "arc.land.update.default to 'rebase' to make this the default."), + "%s to '%s' to make this the default.", + 'arc.land.update.default', + 'rebase'), 'conflicts' => array( 'merge' => pht( - 'The --merge strategy does not update the feature branch.'), + 'The %s strategy does not update the feature branch.', + '--merge'), 'update-with-merge' => pht( - 'Cannot be used with --update-with-merge.'), + 'Cannot be used with %s.', + '--update-with-merge'), ), 'supports' => array( 'git', @@ -145,13 +160,17 @@ EOTEXT 'update-with-merge' => array( 'help' => pht( "When updating the feature branch, use merge instead of rebase. ". - "This is the default behavior. Setting arc.land.update.default to ". - "'merge' can also be used to make this the default."), + "This is the default behavior. Setting %s to '%s' can also be ". + "used to make this the default.", + 'arc.land.update.default', + 'merge'), 'conflicts' => array( 'merge' => pht( - 'The --merge strategy does not update the feature branch.'), + 'The %s strategy does not update the feature branch.', + '--merge'), 'update-with-rebase' => pht( - 'Cannot be used with --update-with-rebase.'), + 'Cannot be used with %s.', + '--update-with-rebase'), ), 'supports' => array( 'git', @@ -329,7 +348,7 @@ EOTEXT $this->branch, $this->onto); if (!$this->isHistoryImmutable()) { - $message .= ' '.pht("You may be able to 'arc amend' instead."); + $message .= ' '.pht("You may be able to '%s' instead.", 'arc amend'); } throw new ArcanistUsageException($message); } @@ -339,23 +358,26 @@ EOTEXT if (!$repository_api->supportsRebase()) { throw new ArcanistUsageException( pht( - 'You must enable the rebase extension to use the --squash '. - 'strategy.')); + 'You must enable the rebase extension to use the %s strategy.', + '--squash')); } } if ($this->branchType != $this->ontoType) { throw new ArcanistUsageException(pht( 'Source %s is a %s but destination %s is a %s. When landing a '. - '%s, the destination must also be a %s. Use --onto to specify a %s, '. - 'or set arc.land.onto.default in .arcconfig.', + '%s, the destination must also be a %s. Use %s to specify a %s, '. + 'or set %s in %s.', $this->branch, $this->branchType, $this->onto, $this->ontoType, $this->branchType, $this->branchType, - $this->branchType)); + '--onto', + $this->branchType, + 'arc.land.onto.default', + '.arcconfig')); } } @@ -376,16 +398,15 @@ EOTEXT private function checkoutBranch() { $repository_api = $this->getRepositoryAPI(); if ($this->getBranchOrBookmark() != $this->branch) { - $repository_api->execxLocal( - 'checkout %s', - $this->branch); + $repository_api->execxLocal('checkout %s', $this->branch); } echo phutil_console_format( - pht('Switched to %s **%s**. Identifying and merging...', - $this->branchType, - $this->branch). - "\n"); + "%s\n", + pht( + 'Switched to %s **%s**. Identifying and merging...', + $this->branchType, + $this->branch)); } private function printPendingCommits() { @@ -417,7 +438,7 @@ EOTEXT if (!trim($out)) { $this->restoreBranch(); throw new ArcanistUsageException( - pht('No commits to land from %s.', $this->branch)); + pht('No commits to land from %s.', $this->branch)); } echo pht("The following commit(s) will be landed:\n\n%s", $out), "\n"; @@ -451,11 +472,13 @@ EOTEXT throw new ArcanistUsageException(pht( "arc can not identify which revision exists on %s '%s'. Update the ". "revision with recent changes to synchronize the %s name and hashes, ". - "or use 'arc amend' to amend the commit message at HEAD, or use ". - "'--revision ' to select a revision explicitly.", + "or use '%s' to amend the commit message at HEAD, or use ". + "'%s' to select a revision explicitly.", $this->branchType, $this->branch, - $this->branchType)); + $this->branchType, + 'arc amend', + '--revision ')); } else if (count($revisions) > 1) { $message = pht( "There are multiple revisions on feature %s '%s' which are not ". @@ -531,9 +554,10 @@ EOTEXT } $open_revs = implode("\n", $open_revs); - echo pht("Revision '%s' depends on open revisions:\n\n%s", - "D{$rev_id}: {$rev_title}", - $open_revs); + echo pht( + "Revision '%s' depends on open revisions:\n\n%s", + "D{$rev_id}: {$rev_title}", + $open_revs); $ok = phutil_console_confirm(pht('Continue anyway?')); if (!$ok) { @@ -552,8 +576,9 @@ EOTEXT $this->messageFile = new TempFile(); Filesystem::writeFile($this->messageFile, $message); - echo pht("Landing revision '%s'...", - "D{$rev_id}: {$rev_title}"), "\n"; + echo pht( + "Landing revision '%s'...", + "D{$rev_id}: {$rev_title}")."\n"; $diff_phid = idx($this->revision, 'activeDiffPHID'); if ($diff_phid) { @@ -590,9 +615,7 @@ EOTEXT } } else if ($this->isHg) { - echo phutil_console_format(pht( - 'Updating **%s**...', - $this->onto)."\n"); + echo phutil_console_format(pht('Updating **%s**...', $this->onto)."\n"); try { list($out, $err) = $repository_api->execxLocal('pull'); @@ -602,10 +625,11 @@ EOTEXT throw new ArcanistUsageException(phutil_console_format(pht( "Local bookmark **%s** has diverged from the server's **%s** ". "(now labeled **%s**). Please resolve this divergence and run ". - "'arc land' again.", + "'%s' again.", $this->onto, $this->onto, - $divergedbookmark))); + $divergedbookmark, + 'arc land'))); } } catch (CommandException $ex) { $err = $ex->getError(); @@ -659,13 +683,14 @@ EOTEXT throw new ArcanistUsageException(pht( "Local %s '%s' is ahead of remote %s '%s', so landing a feature ". "%s would push additional changes. Push or reset the changes in '%s' ". - "before running 'arc land'.", + "before running '%s'.", $this->ontoType, $this->onto, $this->ontoType, $this->ontoRemoteBranch, $this->ontoType, - $this->onto)); + $this->onto, + 'arc land')); } } @@ -682,11 +707,13 @@ EOTEXT $err = phutil_passthru('git rebase %s', $this->onto); if ($err) { throw new ArcanistUsageException(pht( - "'git rebase %s' failed. You can abort with 'git rebase ". - "--abort', or resolve conflicts and use 'git rebase --continue' ". - "to continue forward. After resolving the rebase, run 'arc land' ". - "again.", - $this->onto)); + "'%s' failed. You can abort with '%s', or resolve conflicts ". + "and use '%s' to continue forward. After resolving the rebase, ". + "run '%s' again.", + sprintf('git rebase %s', $this->onto), + 'git rebase --abort', + 'git rebase --continue', + 'arc land')); } } else { echo phutil_console_format(pht( @@ -696,21 +723,20 @@ EOTEXT $err = phutil_passthru( 'git merge --no-stat %s -m %s', $this->onto, - pht("Automatic merge by 'arc land'")); + pht("Automatic merge by '%s'", 'arc land')); if ($err) { throw new ArcanistUsageException(pht( - "'git merge %s' failed. ". - "To continue: resolve the conflicts, commit the changes, then run ". - "'arc land' again. To abort: run 'git merge --abort'.", - $this->onto)); + "'%s' failed. To continue: resolve the conflicts, commit ". + "the changes, then run '%s' again. To abort: run '%s'.", + sprintf('git merge %s', $this->onto), + 'arc land', + 'git merge --abort')); } } } else if ($this->isHg) { $onto_tip = $repository_api->getCanonicalRevisionName($this->onto); $common_ancestor = $repository_api->getCanonicalRevisionName( - hgsprintf('ancestor(%s, %s)', - $this->onto, - $this->branch)); + hgsprintf('ancestor(%s, %s)', $this->onto, $this->branch)); // Only rebase if the local branch is not at the tip of the onto branch. if ($onto_tip != $common_ancestor) { @@ -719,17 +745,17 @@ EOTEXT 'rebase -d %s --keepbranches', $this->onto); if ($err) { - echo phutil_console_format("Aborting rebase\n"); - $repository_api->execManualLocal( - 'rebase --abort'); + echo phutil_console_format("%s\n", pht('Aborting rebase')); + $repository_api->execManualLocal('rebase --abort'); $this->restoreBranch(); throw new ArcanistUsageException(pht( - "'hg rebase %s' failed and the rebase was aborted. ". - "This is most likely due to conflicts. Manually rebase %s onto ". - "%s, resolve the conflicts, then run 'arc land' again.", - $this->onto, + "'%s' failed and the rebase was aborted. This is most ". + "likely due to conflicts. Manually rebase %s onto %s, resolve ". + "the conflicts, then run '%s' again.", + sprintf('hg rebase %s', $this->onto), $this->branch, - $this->onto)); + $this->onto, + 'arc land')); } } } @@ -789,12 +815,14 @@ EOTEXT $this->onto); if ($err) { - $repository_api->execManualLocal( - 'rebase --abort'); + $repository_api->execManualLocal('rebase --abort'); $this->restoreBranch(); throw new ArcanistUsageException( - "Squashing the commits under {$this->branch} failed. ". - "Manually squash your commits and run 'arc land' again."); + pht( + "Squashing the commits under %s failed. ". + "Manually squash your commits and run '%s' again.", + $this->branch, + 'arc land')); } if ($repository_api->isBookmark($this->branch)) { @@ -903,10 +931,11 @@ EOTEXT $branch_string = implode("\n", $alt_branches); echo "\n", - pht("Remove the %s starting at these revisions and ". - "run arc land again:\n%s", - $this->branchType.'s', - $branch_string), + pht( + "Remove the %s starting at these revisions and run %s again:\n%s", + $this->branchType.'s', + $branch_string, + 'arc land'), "\n\n"; throw new ArcanistUserAbortException(); } else { @@ -931,9 +960,11 @@ EOTEXT if ($err) { throw new ArcanistUsageException(pht( - "'git merge' failed. Your working copy has been left in a partially ". - "merged state. You can: abort with 'git merge --abort'; or follow ". - "the instructions to complete the merge.")); + "'%s' failed. Your working copy has been left in a partially ". + "merged state. You can: abort with '%s'; or follow the ". + "instructions to complete the merge.", + 'git merge', + 'git merge --abort')); } } else if ($this->isHg) { // HG arc land currently doesn't support --merge. @@ -943,20 +974,18 @@ EOTEXT // until there is a demand for it. // The user should never reach this line, since --merge is // forbidden at the command line argument level. - throw new ArcanistUsageException(pht( - '--merge is not currently supported for hg repos.')); + throw new ArcanistUsageException( + pht('%s is not currently supported for hg repos.', '--merge')); } } private function push() { $repository_api = $this->getRepositoryAPI(); - // these commands can fail legitimately (e.g. commit hooks) + // These commands can fail legitimately (e.g. commit hooks) try { if ($this->isGit) { - $repository_api->execxLocal( - 'commit -F %s', - $this->messageFile); + $repository_api->execxLocal('commit -F %s', $this->messageFile); if (phutil_is_windows()) { // Occasionally on large repositories on Windows, Git can exit with // an unclean working copy here. This prevents reverts from being @@ -995,18 +1024,13 @@ EOTEXT $err = phutil_passthru('git svn dcommit'); $cmd = 'git svn dcommit'; } else if ($this->isGit) { - $err = phutil_passthru( - 'git push %s %s', - $this->remote, - $this->onto); + $err = phutil_passthru('git push %s %s', $this->remote, $this->onto); $cmd = 'git push'; } else if ($this->isHgSvn) { // hg-svn doesn't support 'push -r', so we do a normal push // which hg-svn modifies to only push the current branch and // ancestors. - $err = $repository_api->execPassthru( - 'push %s', - $this->remote); + $err = $repository_api->execPassthru('push %s', $this->remote); $cmd = 'hg push'; } else if ($this->isHg) { $err = $repository_api->execPassthru( @@ -1017,13 +1041,15 @@ EOTEXT } if ($err) { - $failed_str = pht('PUSH FAILED!'); - echo phutil_console_format("** %s **\n", $failed_str); + echo phutil_console_format( + "** %s **\n", + pht('PUSH FAILED!')); $this->executeCleanupAfterFailedPush(); if ($this->isGit) { throw new ArcanistUsageException(pht( - "'%s' failed! Fix the error and run 'arc land' again.", - $cmd)); + "'%s' failed! Fix the error and run '%s' again.", + $cmd, + 'arc land')); } throw new ArcanistUsageException(pht( "'%s' failed! Fix the error and push this change manually.", @@ -1072,14 +1098,10 @@ EOTEXT $this->branch, $ref); echo pht('(Use `%s` if you want it back.)', $recovery_command), "\n"; - $repository_api->execxLocal( - 'branch -D %s', - $this->branch); + $repository_api->execxLocal('branch -D %s', $this->branch); } else if ($this->isHg) { $common_ancestor = $repository_api->getCanonicalRevisionName( - hgsprintf('ancestor(%s,%s)', - $this->onto, - $this->branch)); + hgsprintf('ancestor(%s,%s)', $this->onto, $this->branch)); $branch_root = $repository_api->getCanonicalRevisionName( hgsprintf('first((%s::%s)-%s)', @@ -1092,9 +1114,7 @@ EOTEXT $branch_root); if ($repository_api->isBookmark($this->branch)) { - $repository_api->execxLocal( - 'bookmark -d %s', - $this->branch); + $repository_api->execxLocal('bookmark -d %s', $this->branch); } } @@ -1106,8 +1126,10 @@ EOTEXT $this->branch); if ($err) { - echo pht('No remote feature %s to clean up.', - $this->branchType), "\n"; + echo pht( + 'No remote feature %s to clean up.', + $this->branchType); + echo "\n"; } else { // NOTE: In Git, you delete a remote branch by pushing it with a @@ -1166,16 +1188,14 @@ EOTEXT */ private function restoreBranch() { $repository_api = $this->getRepositoryAPI(); - $repository_api->execxLocal( - 'checkout %s', - $this->oldBranch); + $repository_api->execxLocal('checkout %s', $this->oldBranch); if ($this->isGit) { - $repository_api->execxLocal( - 'submodule update --init --recursive'); + $repository_api->execxLocal('submodule update --init --recursive'); } - echo phutil_console_format( - "Switched back to {$this->branchType} **%s**.\n", - $this->oldBranch); + echo pht( + "Switched back to %s %s.\n", + $this->branchType, + phutil_console_format('**%s**', $this->oldBranch)); } @@ -1212,8 +1232,7 @@ EOTEXT $console->writeOut( "** %s ** %s\n", pht('BUILDS PASSED'), - pht( - 'Harbormaster builds for the active diff completed successfully.')); + pht('Harbormaster builds for the active diff completed successfully.')); return; } diff --git a/src/workflow/ArcanistLiberateWorkflow.php b/src/workflow/ArcanistLiberateWorkflow.php index 176bc8bc..c7fe1bd9 100644 --- a/src/workflow/ArcanistLiberateWorkflow.php +++ b/src/workflow/ArcanistLiberateWorkflow.php @@ -34,35 +34,35 @@ EOTEXT public function getArguments() { return array( 'all' => array( - 'help' => + 'help' => pht( 'Drop the module cache before liberating. This will completely '. - 'reanalyze the entire library. Thorough, but slow!', + 'reanalyze the entire library. Thorough, but slow!'), ), 'force-update' => array( - 'help' => + 'help' => pht( 'Force the library map to be updated, even in the presence of '. - 'lint errors.', + 'lint errors.'), ), 'library-name' => array( 'param' => 'name', 'help' => - 'Use a flag for library name rather than awaiting user input.', + pht('Use a flag for library name rather than awaiting user input.'), ), 'remap' => array( 'hide' => true, - 'help' => + 'help' => pht( 'Internal. Run the remap step of liberation. You do not need to '. - 'run this unless you are debugging the workflow.', + 'run this unless you are debugging the workflow.'), ), 'verify' => array( 'hide' => true, - 'help' => + 'help' => pht( 'Internal. Run the verify step of liberation. You do not need to '. - 'run this unless you are debugging the workflow.', + 'run this unless you are debugging the workflow.'), ), 'upgrade' => array( 'hide' => true, - 'help' => 'Experimental. Upgrade library to v2.', + 'help' => pht('Experimental. Upgrade library to v2.'), ), '*' => 'argv', ); @@ -72,8 +72,10 @@ EOTEXT $argv = $this->getArgument('argv'); if (count($argv) > 1) { throw new ArcanistUsageException( - "Provide only one path to 'arc liberate'. The path should be a ". - "directory where you want to create or update a libphutil library."); + pht( + "Provide only one path to '%s'. The path should be a directory ". + "where you want to create or update a libphutil library.", + 'arc liberate')); } else if (count($argv) == 0) { $path = getcwd(); } else { @@ -96,8 +98,9 @@ EOTEXT if ($init) { if (count($init) > 1) { throw new ArcanistUsageException( - 'Specified directory contains more than one libphutil library. Use '. - 'a more specific path.'); + pht( + 'Specified directory contains more than one libphutil library. '. + 'Use a more specific path.')); } $path = Filesystem::resolvePath(dirname(reset($init)), $path); } else { @@ -110,7 +113,7 @@ EOTEXT } } if (!$found) { - echo "No library currently exists at that path...\n"; + echo pht("No library currently exists at that path...\n"); $this->liberateCreateDirectory($path); $this->liberateCreateLibrary($path); return; @@ -124,17 +127,19 @@ EOTEXT return $this->upgradeLibrary($path); } throw new ArcanistUsageException( - "This library is using libphutil v1, which is no longer supported. ". - "Run 'arc liberate --upgrade' to upgrade to v2."); + pht( + "This library is using libphutil v1, which is no ". + "longer supported. Run '%s' to upgrade to v2.", + 'arc liberate --upgrade')); case 2: if ($this->getArgument('upgrade')) { throw new ArcanistUsageException( - "Can't upgrade a v2 library!"); + pht("Can't upgrade a v2 library!")); } return $this->liberateVersion2($path); default: throw new ArcanistUsageException( - "Unknown library version '{$version}'!"); + pht("Unknown library version '%s'!", $version)); } } @@ -171,12 +176,12 @@ EOTEXT ->withType('f') ->find(); - echo "Removing __init__.php files...\n"; + echo pht('Removing %s files...', '__init__.php')."\n"; foreach ($inits as $init) { Filesystem::remove($path.'/'.$init); } - echo "Upgrading library to v2...\n"; + echo pht('Upgrading library to v2...')."\n"; $this->liberateVersion2($path); } @@ -184,14 +189,15 @@ EOTEXT if (Filesystem::pathExists($path)) { if (!is_dir($path)) { throw new ArcanistUsageException( - 'Provide a directory to create or update a libphutil library in.'); + pht( + 'Provide a directory to create or update a libphutil library in.')); } return; } - echo "The directory '{$path}' does not exist."; - if (!phutil_console_confirm('Do you want to create it?')) { - throw new ArcanistUsageException('Cancelled.'); + echo pht("The directory '%s' does not exist.", $path); + if (!phutil_console_confirm(pht('Do you want to create it?'))) { + throw new ArcanistUsageException(pht('Canceled.')); } execx('mkdir -p %s', $path); @@ -203,21 +209,22 @@ EOTEXT return; } - echo "Creating new libphutil library in '{$path}'.\n"; + echo pht("Creating new libphutil library in '%s'.", $path)."\n"; do { $name = $this->getArgument('library-name'); if ($name === null) { - echo "Choose a name for the new library.\n"; - $name = phutil_console_prompt('What do you want to name this library?'); + echo pht('Choose a name for the new library.')."\n"; + $name = phutil_console_prompt( + pht('What do you want to name this library?')); } else { - echo "Using library name {$name}.\n"; + echo pht('Using library name %s.', $name)."\n"; } if (preg_match('/^[a-z-]+$/', $name)) { break; } else { - echo "Library name should contain only lowercase letters and ". - "hyphens.\n"; + echo pht( + 'Library name should contain only lowercase letters and hyphens.')."\n"; } } while (true); @@ -225,7 +232,10 @@ EOTEXT "liberateVersion2($path); } diff --git a/src/workflow/ArcanistLintWorkflow.php b/src/workflow/ArcanistLintWorkflow.php index 187a0fac..a824a080 100644 --- a/src/workflow/ArcanistLintWorkflow.php +++ b/src/workflow/ArcanistLintWorkflow.php @@ -60,99 +60,104 @@ EOTEXT public function getArguments() { return array( 'lintall' => array( - 'help' => - 'Show all lint warnings, not just those on changed lines. When '. - 'paths are specified, this is the default behavior.', + 'help' => pht( + 'Show all lint warnings, not just those on changed lines. When '. + 'paths are specified, this is the default behavior.'), 'conflicts' => array( 'only-changed' => true, ), ), 'only-changed' => array( - 'help' => - 'Show lint warnings just on changed lines. When no paths are '. - 'specified, this is the default. This differs from only-new '. - 'in cases where line modifications introduce lint on other '. - 'unmodified lines.', + 'help' => pht( + 'Show lint warnings just on changed lines. When no paths are '. + 'specified, this is the default. This differs from only-new '. + 'in cases where line modifications introduce lint on other '. + 'unmodified lines.'), 'conflicts' => array( 'lintall' => true, ), ), 'rev' => array( 'param' => 'revision', - 'help' => 'Lint changes since a specific revision.', + 'help' => pht('Lint changes since a specific revision.'), 'supports' => array( 'git', 'hg', ), 'nosupport' => array( - 'svn' => 'Lint does not currently support --rev in SVN.', + 'svn' => pht('Lint does not currently support %s in SVN.', '--rev'), ), ), 'output' => array( 'param' => 'format', - 'help' => + 'help' => pht( "With 'summary', show lint warnings in a more compact format. ". "With 'json', show lint warnings in machine-readable JSON format. ". "With 'none', show no lint warnings. ". "With 'compiler', show lint warnings in suitable for your editor. ". - "With 'xml', show lint warnings in the Checkstyle XML format.", + "With 'xml', show lint warnings in the Checkstyle XML format."), ), 'only-new' => array( 'param' => 'bool', 'supports' => array('git', 'hg'), // TODO: svn - 'help' => 'Display only messages not present in the original code.', + 'help' => pht( + 'Display only messages not present in the original code.'), ), 'engine' => array( 'param' => 'classname', - 'help' => - 'Override configured lint engine for this project.', + 'help' => pht('Override configured lint engine for this project.'), ), 'apply-patches' => array( - 'help' => + 'help' => pht( 'Apply patches suggested by lint to the working copy without '. - 'prompting.', + 'prompting.'), 'conflicts' => array( 'never-apply-patches' => true, ), ), 'never-apply-patches' => array( - 'help' => 'Never apply patches suggested by lint.', + 'help' => pht('Never apply patches suggested by lint.'), 'conflicts' => array( 'apply-patches' => true, ), ), 'amend-all' => array( - 'help' => - 'When linting git repositories, amend HEAD with all patches '. - 'suggested by lint without prompting.', + 'help' => pht( + 'When linting git repositories, amend HEAD with all patches '. + 'suggested by lint without prompting.'), ), 'amend-autofixes' => array( - 'help' => + 'help' => pht( 'When linting git repositories, amend HEAD with autofix '. - 'patches suggested by lint without prompting.', + 'patches suggested by lint without prompting.'), ), 'everything' => array( - 'help' => 'Lint all files in the project.', + 'help' => pht('Lint all files in the project.'), 'conflicts' => array( - 'cache' => '--everything lints all files', - 'rev' => '--everything lints all files', + 'cache' => pht('%s lints all files', '--everything'), + 'rev' => pht('%s lints all files', '--everything'), ), ), 'severity' => array( 'param' => 'string', - 'help' => - "Set minimum message severity. One of: '". - implode( - "', '", - array_keys(ArcanistLintSeverity::getLintSeverities())). - "'. Defaults to '".self::DEFAULT_SEVERITY."'.", + 'help' => pht( + "Set minimum message severity. One of: %s. Defaults to '%s'.", + sprintf( + "'%s'", + implode( + "', '", + array_keys(ArcanistLintSeverity::getLintSeverities()))), + self::DEFAULT_SEVERITY), ), 'cache' => array( 'param' => 'bool', - 'help' => - "0 to disable cache, 1 to enable. The default value is ". - "determined by 'arc.lint.cache' in configuration, which defaults ". - "to off. See notes in 'arc.lint.cache'.", + 'help' => pht( + "%d to disable cache, %d to enable. The default value is determined ". + "by '%s' in configuration, which defaults to off. See notes in '%s'.", + 0, + 1, + 'arc.lint.cache', + 'arc.lint.cache'), ), '*' => 'paths', ); @@ -191,8 +196,10 @@ EOTEXT $everything = $this->getArgument('everything'); if ($everything && $paths) { throw new ArcanistUsageException( - 'You can not specify paths with --everything. The --everything '. - 'flag lints every file.'); + pht( + 'You can not specify paths with %s. The %s flag lints every file.', + '--everything', + '--everything')); } if ($use_cache === null) { $use_cache = (bool)$configuration_manager->getConfigFromAnySource( @@ -201,7 +208,8 @@ EOTEXT } if ($rev && $paths) { - throw new ArcanistUsageException('Specify either --rev or paths.'); + throw new ArcanistUsageException( + pht('Specify either %s or paths.', '--rev')); } @@ -252,7 +260,10 @@ EOTEXT if ($cached) { $console->writeErr( - pht("Using lint cache, use '--cache 0' to disable it.")."\n"); + "%s\n", + pht( + "Using lint cache, use '%s' to disable it.", + '--cache 0')); } $engine->setCachedResults($cached); @@ -491,9 +502,9 @@ EOTEXT $console->writeOut('%s', $stdout); $console->writeErr('%s', $stderr); - $prompt = phutil_console_format( - 'Apply this patch to __%s__?', - $result->getPath()); + $prompt = pht( + 'Apply this patch to %s?', + phutil_console_format('__%s__', $result->getPath())); if (!$console->confirm($prompt, $default_no = false)) { continue; } @@ -511,11 +522,12 @@ EOTEXT if ($this->shouldAmendWithoutPrompt || ($this->shouldAmendAutofixesWithoutPrompt && $all_autofix)) { $console->writeOut( - "** LINT NOTICE ** Automatically amending HEAD ". - "with lint patches.\n"); + "** %s ** %s\n", + pht('LINT NOTICE'), + pht('Automatically amending HEAD with lint patches.')); $amend = true; } else { - $amend = $console->confirm('Amend HEAD with lint patches?'); + $amend = $console->confirm(pht('Amend HEAD with lint patches?')); } if ($amend) { @@ -527,8 +539,9 @@ EOTEXT $repository_api->amendCommit(); } else { throw new ArcanistUsageException( - 'Sort out the lint changes that were applied to the working '. - 'copy and relint.'); + pht( + 'Sort out the lint changes that were applied to the working '. + 'copy and relint.')); } } diff --git a/src/workflow/ArcanistLintersWorkflow.php b/src/workflow/ArcanistLintersWorkflow.php index c2d8cef7..b872e300 100644 --- a/src/workflow/ArcanistLintersWorkflow.php +++ b/src/workflow/ArcanistLintersWorkflow.php @@ -178,7 +178,7 @@ EOTEXT if (!$this->getArgument('verbose')) { $console->writeOut( "%s\n", - pht('(Run `arc linters --verbose` for more details.)')); + pht('(Run `%s` for more details.)', 'arc linters --verbose')); } } @@ -191,8 +191,8 @@ EOTEXT private function getStatusMap() { $text_map = array( 'configured' => pht('CONFIGURED'), - 'available' => pht('AVAILABLE'), - 'error' => pht('ERROR'), + 'available' => pht('AVAILABLE'), + 'error' => pht('ERROR'), ); $sizes = array(); diff --git a/src/workflow/ArcanistListWorkflow.php b/src/workflow/ArcanistListWorkflow.php index 5ed6fb22..ff6f0c6e 100644 --- a/src/workflow/ArcanistListWorkflow.php +++ b/src/workflow/ArcanistListWorkflow.php @@ -55,7 +55,7 @@ EOTEXT )); if (!$revisions) { - echo "You have no open Differential revisions.\n"; + echo pht('You have no open Differential revisions.')."\n"; return 0; } @@ -93,9 +93,12 @@ EOTEXT $table->addRow(array( 'exists' => $spec['exists'] ? phutil_console_format('**%s**', '*') : '', 'status' => phutil_console_format( - "%s", $spec['statusName']), + "%s", + $spec['statusName']), 'title' => phutil_console_format( - '**D%d:** %s', $revision['id'], $revision['title']), + '**D%d:** %s', + $revision['id'], + $revision['title']), )); } diff --git a/src/workflow/ArcanistPasteWorkflow.php b/src/workflow/ArcanistPasteWorkflow.php index 27981b62..f7f1bbff 100644 --- a/src/workflow/ArcanistPasteWorkflow.php +++ b/src/workflow/ArcanistPasteWorkflow.php @@ -123,7 +123,7 @@ EOTEXT $conduit = $this->getConduit(); if (!function_exists('posix_isatty') || posix_isatty(STDIN)) { - $this->writeStatusMessage("Reading paste from stdin...\n"); + $this->writeStatusMessage(pht('Reading paste from stdin...')."\n"); } $info = $conduit->callMethodSynchronous( diff --git a/src/workflow/ArcanistPatchWorkflow.php b/src/workflow/ArcanistPatchWorkflow.php index fb3d0e06..4fbc9cf0 100644 --- a/src/workflow/ArcanistPatchWorkflow.php +++ b/src/workflow/ArcanistPatchWorkflow.php @@ -42,37 +42,42 @@ EOTEXT 'revision' => array( 'param' => 'revision_id', 'paramtype' => 'complete', - 'help' => + 'help' => pht( "Apply changes from a Differential revision, using the most recent ". - "diff that has been attached to it. You can run 'arc patch D12345' ". - "as a shorthand.", + "diff that has been attached to it. You can run '%s' as a shorthand.", + 'arc patch D12345'), ), 'diff' => array( 'param' => 'diff_id', - 'help' => + 'help' => pht( 'Apply changes from a Differential diff. Normally you want to use '. - '--revision to get the most recent changes, but you can '. - 'specifically apply an out-of-date diff or a diff which was never '. - 'attached to a revision by using this flag.', + '%s to get the most recent changes, but you can specifically apply '. + 'an out-of-date diff or a diff which was never attached to a '. + 'revision by using this flag.', + '--revision'), ), 'arcbundle' => array( 'param' => 'bundlefile', 'paramtype' => 'file', - 'help' => - "Apply changes from an arc bundle generated with 'arc export'.", + 'help' => pht( + "Apply changes from an arc bundle generated with '%s'.", + 'arc export'), ), 'patch' => array( 'param' => 'patchfile', 'paramtype' => 'file', - 'help' => 'Apply changes from a git patchfile or unified patchfile.', + 'help' => pht( + 'Apply changes from a git patchfile or unified patchfile.'), ), 'encoding' => array( 'param' => 'encoding', - 'help' => 'Attempt to convert non UTF-8 patch into specified encoding.', + 'help' => pht( + 'Attempt to convert non UTF-8 patch into specified encoding.'), ), 'update' => array( 'supports' => array('git', 'svn', 'hg'), - 'help' => 'Update the local working copy before applying the patch.', + 'help' => pht( + 'Update the local working copy before applying the patch.'), 'conflicts' => array( 'nobranch' => true, 'bookmark' => true, @@ -80,30 +85,30 @@ EOTEXT ), 'nocommit' => array( 'supports' => array('git', 'hg'), - 'help' => + 'help' => pht( 'Normally under git/hg, if the patch is successful, the changes '. - 'are committed to the working copy. This flag prevents the commit.', + 'are committed to the working copy. This flag prevents the commit.'), ), 'skip-dependencies' => array( 'supports' => array('git', 'hg'), - 'help' => + 'help' => pht( 'Normally, if a patch has dependencies that are not present in the '. 'working copy, arc tries to apply them as well. This flag prevents '. - 'such work.', + 'such work.'), ), 'nobranch' => array( 'supports' => array('git', 'hg'), - 'help' => + 'help' => pht( 'Normally, a new branch (git) or bookmark (hg) is created and then '. 'the patch is applied and committed in the new branch/bookmark. '. 'This flag cherry-picks the resultant commit onto the original '. - 'branch and deletes the temporary branch.', + 'branch and deletes the temporary branch.'), 'conflicts' => array( 'update' => true, ), ), 'force' => array( - 'help' => 'Do not run any sanity checks.', + 'help' => pht('Do not run any sanity checks.'), ), '*' => 'name', ); @@ -133,7 +138,8 @@ EOTEXT if ($this->getArgument('name')) { $namev = $this->getArgument('name'); if (count($namev) > 1) { - throw new ArcanistUsageException('Specify at most one revision name.'); + throw new ArcanistUsageException( + pht('Specify at most one revision name.')); } $source = self::SOURCE_REVISION; $requested++; @@ -143,15 +149,26 @@ EOTEXT if ($requested === 0) { throw new ArcanistUsageException( - "Specify one of 'D12345', '--revision ' (to select the ". - "current changes attached to a Differential revision), ". - "'--diff ' (to select a specific, out-of-date diff or a ". - "diff which is not attached to a revision), '--arcbundle ' ". - "or '--patch ' to choose a patch source."); + pht( + "Specify one of '%s', '%s' (to select the current changes attached ". + "to a Differential revision), '%s' (to select a specific, ". + "out-of-date diff or a diff which is not attached to a revision), ". + "'%s' or '%s' to choose a patch source.", + 'D12345', + '--revision ', + '--diff ', + '--arcbundle ', + '--patch ')); } else if ($requested > 1) { throw new ArcanistUsageException( - "Options 'D12345', '--revision', '--diff', '--arcbundle' and ". - "'--patch' are not compatible. Choose exactly one patch source."); + pht( + "Options '%s', '%s', '%s', '%s' and '%s' are not compatible. ". + "Choose exactly one patch source.", + 'D12345', + '--revision', + '--diff', + '--arcbundle', + '--patch')); } $this->source = $source; @@ -218,7 +235,10 @@ EOTEXT // no error means git rev-parse found a branch if (!$err) { echo phutil_console_format( - "Branch name {$proposed_name} already exists; trying a new name.\n"); + "%s\n", + pht( + 'Branch name %s already exists; trying a new name.', + $proposed_name)); continue; } else { $branch_name = $proposed_name; @@ -228,9 +248,9 @@ EOTEXT if (!$branch_name) { throw new Exception( - 'Arc was unable to automagically make a name for this patch. '. - 'Please clean up your working copy and try again.' - ); + pht( + 'Arc was unable to automagically make a name for this patch. '. + 'Please clean up your working copy and try again.')); } return $branch_name; @@ -256,8 +276,10 @@ EOTEXT // no error means hg log found a bookmark if (!$err) { echo phutil_console_format( - "Bookmark name %s already exists; trying a new name.\n", - $proposed_name); + "%s\n", + pht( + 'Bookmark name %s already exists; trying a new name.', + $proposed_name)); continue; } else { $bookmark_name = $proposed_name; @@ -267,9 +289,9 @@ EOTEXT if (!$bookmark_name) { throw new Exception( - 'Arc was unable to automagically make a name for this patch. '. - 'Please clean up your working copy and try again.' - ); + pht( + 'Arc was unable to automagically make a name for this patch. '. + 'Please clean up your working copy and try again.')); } return $bookmark_name; @@ -289,14 +311,14 @@ EOTEXT $branch_name, $base_revision); } else { - $repository_api->execxLocal( - 'checkout -b %s', - $branch_name); + $repository_api->execxLocal('checkout -b %s', $branch_name); } echo phutil_console_format( - "Created and checked out branch %s.\n", - $branch_name); + "%s\n", + pht( + 'Created and checked out branch %s.', + $branch_name)); } else if ($repository_api instanceof ArcanistMercurialAPI) { $branch_name = $this->getBookmarkName($bundle); $base_revision = $bundle->getBaseRevision(); @@ -305,17 +327,17 @@ EOTEXT $base_revision = $repository_api->getCanonicalRevisionName( $base_revision); - echo "Updating to the revision's base commit\n"; - $repository_api->execPassthru( - 'update %s', - $base_revision); + echo pht("Updating to the revision's base commit")."\n"; + $repository_api->execPassthru('update %s', $base_revision); } $repository_api->execxLocal('bookmark %s', $branch_name); echo phutil_console_format( - "Created and checked out bookmark %s.\n", - $branch_name); + "%s\n", + pht( + 'Created and checked out bookmark %s.', + $branch_name)); } return $branch_name; @@ -330,9 +352,9 @@ EOTEXT } private function updateWorkingCopy() { - echo "Updating working copy...\n"; + echo pht('Updating working copy...')."\n"; $this->getRepositoryAPI()->updateWorkingCopy(); - echo "Done.\n"; + echo pht('Done.')."\n"; } public function run() { @@ -345,7 +367,7 @@ EOTEXT $patch = @file_get_contents('php://stdin'); if (!strlen($patch)) { throw new ArcanistUsageException( - 'Failed to read patch from stdin!'); + pht('Failed to read patch from stdin!')); } } else { $patch = Filesystem::readFile($param); @@ -469,8 +491,10 @@ EOTEXT $fpath = $repository_api->getPath($path); if (!@file_exists($fpath)) { $ok = phutil_console_confirm( - "Patch deletes file '{$path}', but the file does not exist in ". - "the working copy. Continue anyway?"); + pht( + "Patch deletes file '%s', but the file does not exist in ". + "the working copy. Continue anyway?", + $path)); if (!$ok) { throw new ArcanistUserAbortException(); } @@ -486,13 +510,17 @@ EOTEXT if (!@file_exists($fpath)) { $cpath = $change->getCurrentPath(); if ($type == ArcanistDiffChangeType::TYPE_COPY_HERE) { - $verbs = 'copies'; + $verbs = pht('copies'); } else { - $verbs = 'moves'; + $verbs = pht('moves'); } $ok = phutil_console_confirm( - "Patch {$verbs} '{$path}' to '{$cpath}', but source path ". - "does not exist in the working copy. Continue anyway?"); + pht( + "Patch %s '%s' to '%s', but source path does not exist ". + "in the working copy. Continue anyway?", + $verbs, + $path, + $cpath)); if (!$ok) { throw new ArcanistUserAbortException(); } @@ -634,18 +662,26 @@ EOTEXT if ($patch_err == 0) { echo phutil_console_format( - "** OKAY ** Successfully applied patch ". - "to the working copy.\n"); + "** %s ** %s\n", + pht('OKAY'), + pht('Successfully applied patch to the working copy.')); } else { echo phutil_console_format( - "\n\n** WARNING ** Some hunks could not be applied ". - "cleanly by the unix 'patch' utility. Your working copy may be ". - "different from the revision's base, or you may be in the wrong ". - "subdirectory. You can export the raw patch file using ". - "'arc export --unified', and then try to apply it by fiddling with ". - "options to 'patch' (particularly, -p), or manually. The output ". - "above, from 'patch', may be helpful in figuring out what went ". - "wrong.\n"); + "\n\n** %s ** %s\n", + pht('WARNING'), + pht( + "Some hunks could not be applied cleanly by the unix '%s' ". + "utility. Your working copy may be different from the revision's ". + "base, or you may be in the wrong subdirectory. You can export ". + "the raw patch file using '%s', and then try to apply it by ". + "fiddling with options to '%s' (particularly, %s), or manually. ". + "The output above, from '%s', may be helpful in ". + "figuring out what went wrong.", + 'patch', + 'arc export --unified', + 'patch', + '-p', + 'patch')); } return $patch_err; @@ -662,19 +698,19 @@ EOTEXT if ($err) { echo phutil_console_format( - "\n** Patch Failed! **\n"); + "\n** %s **\n", + pht('Patch Failed!')); // NOTE: Git patches may fail if they change the case of a filename // (for instance, from 'example.c' to 'Example.c'). As of now, Git // can not apply these patches on case-insensitive filesystems and // there is no way to build a patch which works. - throw new ArcanistUsageException('Unable to apply patch!'); + throw new ArcanistUsageException(pht('Unable to apply patch!')); } // in case there were any submodule changes involved - $repository_api->execpassthru( - 'submodule update --init --recursive'); + $repository_api->execpassthru('submodule update --init --recursive'); if ($this->shouldCommit()) { if ($bundle->getFullAuthor()) { @@ -689,9 +725,9 @@ EOTEXT $author_cmd); $future->write($commit_message); $future->resolvex(); - $verb = 'committed'; + $verb = pht('committed'); } else { - $verb = 'applied'; + $verb = pht('applied'); } if ($this->canBranch() && @@ -707,33 +743,39 @@ EOTEXT $repository_api->execxLocal('branch -D %s', $new_branch); if ($ex) { echo phutil_console_format( - "\n** Cherry Pick Failed!**\n"); + "\n** %s**\n", + pht('Cherry Pick Failed!')); throw $ex; } } echo phutil_console_format( - "** OKAY ** Successfully {$verb} patch.\n"); + "** %s ** %s\n", + pht('OKAY'), + pht('Successfully %s patch.', $verb)); } else if ($repository_api instanceof ArcanistMercurialAPI) { - - $future = $repository_api->execFutureLocal( - 'import --no-commit -'); + $future = $repository_api->execFutureLocal('import --no-commit -'); $future->write($bundle->toGitPatch()); try { $future->resolvex(); } catch (CommandException $ex) { echo phutil_console_format( - "\n** Patch Failed! **\n"); + "\n** %s **\n", + pht('Patch Failed!')); $stderr = $ex->getStdErr(); if (preg_match('/case-folding collision/', $stderr)) { echo phutil_console_wrap( phutil_console_format( - "\n** WARNING ** This patch may have failed ". - "because it attempts to change the case of a filename (for ". - "instance, from 'example.c' to 'Example.c'). Mercurial cannot ". - "apply patches like this on case-insensitive filesystems. You ". - "must apply this patch manually.\n")); + "\n** %s ** %s\n", + pht('WARNING'), + pht( + "This patch may have failed because it attempts to change ". + "the case of a filename (for instance, from '%s' to '%s'). ". + "Mercurial cannot apply patches like this on case-insensitive ". + "filesystems. You must apply this patch manually.", + 'example.c', + 'Example.c'))); } throw $ex; } @@ -770,21 +812,24 @@ EOTEXT $repository_api->execxLocal('bookmark --delete %s', $new_branch); if ($err) { $repository_api->execManualLocal('rebase --abort'); - throw new ArcanistUsageException(phutil_console_format( - "\n** Rebase onto $original_branch failed!**\n")); + throw new ArcanistUsageException( + phutil_console_format( + "\n** %s**\n", + pht('Rebase onto %s failed!', $original_branch))); } } - $verb = 'committed'; + $verb = pht('committed'); } else { - $verb = 'applied'; + $verb = pht('applied'); } echo phutil_console_format( - "** OKAY ** Successfully {$verb} patch.\n"); - + "** %s ** %s\n", + pht('OKAY'), + pht('Successfully %s patch.', $verb)); } else { - throw new Exception('Unknown version control system.'); + throw new Exception(pht('Unknown version control system.')); } return 0; @@ -806,20 +851,23 @@ EOTEXT array( 'revision_id' => $revision_id, )); - $prompt_message = " Note arcanist failed to load the commit message ". - "from differential for revision D{$revision_id}."; + $prompt_message = pht( + ' Note arcanist failed to load the commit message '. + 'from differential for revision %s.', + "D{$revision_id}"); } // no revision id or failed to fetch commit message so get it from the // user on the command line if (!$commit_message) { - $template = - "\n\n". - "# Enter a commit message for this patch. If you just want to apply ". - "the patch to the working copy without committing, re-run arc patch ". - "with the --nocommit flag.". - $prompt_message. - "\n"; + $template = sprintf( + "\n\n# %s%s\n", + pht( + 'Enter a commit message for this patch. If you just want to apply '. + 'the patch to the working copy without committing, re-run arc patch '. + 'with the %s flag.', + '--nocommit'), + $prompt_message); $commit_message = $this->newInteractiveEditor($template) ->setName('arcanist-patch-commit-message') @@ -848,8 +896,9 @@ EOTEXT $cycle_phids = $graph->detectCycles($start_phid); if ($cycle_phids) { $phids = array_keys($graph->getNodes()); - $issue = 'The dependencies for this patch have a cycle. Applying them '. - 'is not guaranteed to work. Continue anyway?'; + $issue = pht( + 'The dependencies for this patch have a cycle. Applying them '. + 'is not guaranteed to work. Continue anyway?'); $okay = phutil_console_confirm($issue, true); } else { $phids = $graph->getTopographicallySortedNodes(); @@ -915,17 +964,20 @@ EOTEXT // they don't come with a project id so just do nothing } else if ($bundle_project_id != $working_copy_project_id) { if ($working_copy_project_id) { - $issue = - "This patch is for the '{$bundle_project_id}' project, but the ". - "working copy belongs to the '{$working_copy_project_id}' project."; + $issue = pht( + "This patch is for the '%s' project, but the working copy ". + "belongs to the '%s' project.", + $bundle_project_id, + $working_copy_project_id); } else { - $issue = - "This patch is for the '{$bundle_project_id}' project, but the ". - "working copy does not have an '.arcconfig' file to identify which ". - "project it belongs to."; + $issue = pht( + "This patch is for the '%s' project, but the working copy does ". + "not have an '%s' file to identify which project it belongs to.", + $bundle_project_id, + '.arcconfig'); } $ok = phutil_console_confirm( - "{$issue} Still try to apply the patch?", + pht('%s Still try to apply the patch?', $issue), $default_no = false); if (!$ok) { throw new ArcanistUserAbortException(); @@ -985,9 +1037,12 @@ EOTEXT $source_base_rev); $ok = phutil_console_confirm( - "This diff is against commit {$bundle_base_rev_str}, but the ". - "commit is nowhere in the working copy. Try to apply it against ". - "the current working copy state? ({$source_base_rev_str})", + pht( + 'This diff is against commit %s, but the commit is nowhere '. + 'in the working copy. Try to apply it against the current '. + 'working copy state? (%s)', + $bundle_base_rev_str, + $source_base_rev_str), $default_no = false); if (!$ok) { throw new ArcanistUserAbortException(); diff --git a/src/workflow/ArcanistRevertWorkflow.php b/src/workflow/ArcanistRevertWorkflow.php index 205c91d3..efcc25bc 100644 --- a/src/workflow/ArcanistRevertWorkflow.php +++ b/src/workflow/ArcanistRevertWorkflow.php @@ -34,7 +34,9 @@ EOTEXT } public function run() { - echo pht('Please use `%s` instead.', 'arc backout')."\n"; + echo pht( + 'Please use `%s` instead.', + 'arc backout')."\n"; return 1; } diff --git a/src/workflow/ArcanistSetConfigWorkflow.php b/src/workflow/ArcanistSetConfigWorkflow.php index 3dfb3759..9d9b099d 100644 --- a/src/workflow/ArcanistSetConfigWorkflow.php +++ b/src/workflow/ArcanistSetConfigWorkflow.php @@ -36,7 +36,7 @@ EOTEXT public function getArguments() { return array( 'local' => array( - 'help' => 'Set a local config value instead of a user one', + 'help' => pht('Set a local config value instead of a user one.'), ), '*' => 'argv', ); @@ -85,9 +85,16 @@ EOTEXT $old = $settings->formatConfigValueForDisplay($key, $old); if ($old === null) { - echo "Deleted key '{$key}' from {$which} config.\n"; + echo pht( + "Deleted key '%s' from %s config.\n", + $key, + $which); } else { - echo "Deleted key '{$key}' from {$which} config (was {$old}).\n"; + echo pht( + "Deleted key '%s' from %s config (was %s).\n", + $key, + $which, + $old); } } else { $val = $settings->willWriteValue($key, $val); @@ -103,9 +110,18 @@ EOTEXT $old = $settings->formatConfigValueForDisplay($key, $old); if ($old === null) { - echo "Set key '{$key}' = {$val} in {$which} config.\n"; + echo pht( + "Set key '%s' = %s in %s config.\n", + $key, + $val, + $which); } else { - echo "Set key '{$key}' = {$val} in {$which} config (was {$old}).\n"; + echo pht( + "Set key '%s' = %s in %s config (was %s).\n", + $key, + $val, + $which, + $old); } } diff --git a/src/workflow/ArcanistShellCompleteWorkflow.php b/src/workflow/ArcanistShellCompleteWorkflow.php index ca519903..90551f2a 100644 --- a/src/workflow/ArcanistShellCompleteWorkflow.php +++ b/src/workflow/ArcanistShellCompleteWorkflow.php @@ -50,7 +50,9 @@ EOTEXT if ($pos > $argc) { throw new ArcanistUsageException( - 'Specified position is greater than the number of arguments provided.'); + pht( + 'Specified position is greater than the number of '. + 'arguments provided.')); } // Determine which revision control system the working copy uses, so we diff --git a/src/workflow/ArcanistTasksWorkflow.php b/src/workflow/ArcanistTasksWorkflow.php index 68bc89e7..fe0201d6 100644 --- a/src/workflow/ArcanistTasksWorkflow.php +++ b/src/workflow/ArcanistTasksWorkflow.php @@ -41,31 +41,32 @@ EOTEXT return array( 'status' => array( 'param' => 'task_status', - 'help' => 'Show tasks that or open or closed, default is open.', + 'help' => pht('Show tasks that or open or closed, default is open.'), ), 'owner' => array( 'param' => 'username', 'paramtype' => 'username', - 'help' => + 'help' => pht( 'Only show tasks assigned to the given username, '. - 'also accepts @all to show all, default is you.', + 'also accepts %s to show all, default is you.', + '@all'), 'conflict' => array( - 'unassigned' => '--owner suppresses unassigned', + 'unassigned' => pht('%s suppresses unassigned', '--owner'), ), ), 'order' => array( 'param' => 'task_order', - 'help' => + 'help' => pht( 'Arrange tasks based on priority, created, or modified, '. - 'default is priority.', + 'default is priority.'), ), 'limit' => array( 'param' => 'n', 'paramtype' => 'int', - 'help' => 'Limit the amount of tasks outputted, default is all.', + 'help' => pht('Limit the amount of tasks outputted, default is all.'), ), 'unassigned' => array( - 'help' => 'Only show tasks that are not assigned (upforgrabs).', + 'help' => pht('Only show tasks that are not assigned (upforgrabs).'), ), ); } @@ -94,16 +95,16 @@ EOTEXT $limit); if (!$this->tasks) { - echo "No tasks found.\n"; + echo pht('No tasks found.')."\n"; return 0; } $table = id(new PhutilConsoleTable()) ->setShowHeader(false) - ->addColumn('id', array('title' => 'ID')) - ->addColumn('title', array('title' => 'Title')) - ->addColumn('priority', array('title' => 'Priority')) - ->addColumn('status', array('title' => 'Status')); + ->addColumn('id', array('title' => pht('ID'))) + ->addColumn('title', array('title' => pht('Title'))) + ->addColumn('priority', array('title' => pht('Priority'))) + ->addColumn('status', array('title' => pht('Status'))); foreach ($this->tasks as $task) { $output = array(); diff --git a/src/workflow/ArcanistTodoWorkflow.php b/src/workflow/ArcanistTodoWorkflow.php index 30550e59..6914bbd0 100644 --- a/src/workflow/ArcanistTodoWorkflow.php +++ b/src/workflow/ArcanistTodoWorkflow.php @@ -63,7 +63,7 @@ EOTEXT $conduit = $this->getConduit(); if (trim($summary) == '') { - echo "Please provide a summary.\n"; + echo pht('Please provide a summary.')."\n"; return; } @@ -97,7 +97,7 @@ EOTEXT $project = idx($projects['slugMap'], $slug); if (!$project) { - throw new ArcanistUsageException('No such project: "'.$slug.'"'); + throw new ArcanistUsageException(pht('No such project: "%s"', $slug)); } $phids[] = $project; } @@ -106,11 +106,11 @@ EOTEXT } $result = $conduit->callMethodSynchronous('maniphest.createtask', $args); - echo phutil_console_format( - "Created task T%s: '**%s**' at **%s**\n", - $result['id'], - $result['title'], - $result['uri']); + echo pht( + "Created task %s: '%s' at %s\n", + 'T'.$result['id'], + phutil_console_format('**%s**', $result['title']), + phutil_console_format('**%s**', $result['uri'])); if ($this->getArgument('browse')) { $this->openURIsInBrowser(array($result['uri'])); diff --git a/src/workflow/ArcanistUnitWorkflow.php b/src/workflow/ArcanistUnitWorkflow.php index d2ccdd48..2d3d8a7a 100644 --- a/src/workflow/ArcanistUnitWorkflow.php +++ b/src/workflow/ArcanistUnitWorkflow.php @@ -40,56 +40,61 @@ EOTEXT return array( 'rev' => array( 'param' => 'revision', - 'help' => 'Run unit tests covering changes since a specific revision.', + 'help' => pht( + 'Run unit tests covering changes since a specific revision.'), 'supports' => array( 'git', 'hg', ), 'nosupport' => array( - 'svn' => 'Arc unit does not currently support --rev in SVN.', + 'svn' => pht( + 'Arc unit does not currently support %s in SVN.', + '--rev'), ), ), 'engine' => array( 'param' => 'classname', - 'help' => - 'Override configured unit engine for this project.', + 'help' => pht('Override configured unit engine for this project.'), ), 'coverage' => array( - 'help' => 'Always enable coverage information.', + 'help' => pht('Always enable coverage information.'), 'conflicts' => array( 'no-coverage' => null, ), ), 'no-coverage' => array( - 'help' => 'Always disable coverage information.', + 'help' => pht('Always disable coverage information.'), ), 'detailed-coverage' => array( - 'help' => 'Show a detailed coverage report on the CLI. Implies '. - '--coverage.', + 'help' => pht( + 'Show a detailed coverage report on the CLI. Implies %s.', + '--coverage'), ), 'json' => array( - 'help' => 'Report results in JSON format.', + 'help' => pht('Report results in JSON format.'), ), 'output' => array( 'param' => 'format', - 'help' => + 'help' => pht( "With 'full', show full pretty report (Default). ". "With 'json', report results in JSON format. ". "With 'ugly', use uglier (but more efficient) JSON formatting. ". - "With 'none', don't print results. ", + "With 'none', don't print results."), 'conflicts' => array( - 'json' => 'Only one output format allowed', - 'ugly' => 'Only one output format allowed', + 'json' => pht('Only one output format allowed'), + 'ugly' => pht('Only one output format allowed'), ), ), 'everything' => array( - 'help' => 'Run every test.', + 'help' => pht('Run every test.'), 'conflicts' => array( - 'rev' => '--everything runs all tests.', + 'rev' => pht('%s runs all tests.', '--everything'), ), ), 'ugly' => array( - 'help' => 'With --json, use uglier (but more efficient) formatting.', + 'help' => pht( + 'With %s, use uglier (but more efficient) formatting.', + '--json'), ), '*' => 'paths', ); @@ -117,8 +122,10 @@ EOTEXT if (!$engine_class) { throw new ArcanistNoEngineException( - 'No unit test engine is configured for this project. Edit .arcconfig '. - 'to specify a unit test engine.'); + pht( + 'No unit test engine is configured for this project. Edit %s '. + 'to specify a unit test engine.', + '.arcconfig')); } $paths = $this->getArgument('paths'); @@ -126,8 +133,10 @@ EOTEXT $everything = $this->getArgument('everything'); if ($everything && $paths) { throw new ArcanistUsageException( - 'You can not specify paths with --everything. The --everything '. - 'flag runs every test.'); + pht( + 'You can not specify paths with %s. The %s flag runs every test.', + '--everything', + '--everything')); } if ($everything) { @@ -139,8 +148,10 @@ EOTEXT if (!class_exists($engine_class) || !is_subclass_of($engine_class, 'ArcanistUnitTestEngine')) { throw new ArcanistUsageException( - "Configured unit test engine '{$engine_class}' is not a subclass of ". - "'ArcanistUnitTestEngine'."); + pht( + "Configured unit test engine '%s' is not a subclass of '%s'.", + $engine_class, + 'ArcanistUnitTestEngine')); } $this->engine = newv($engine_class, array()); @@ -228,7 +239,7 @@ EOTEXT $file_coverage[$file] = $coverage; $file_reports[$file] = $report; } - $console->writeOut("\n__COVERAGE REPORT__\n"); + $console->writeOut("\n__%s__\n", pht('COVERAGE REPORT')); asort($file_coverage); foreach ($file_coverage as $file => $coverage) { diff --git a/src/workflow/ArcanistUpgradeWorkflow.php b/src/workflow/ArcanistUpgradeWorkflow.php index 40939f60..ed30593f 100644 --- a/src/workflow/ArcanistUpgradeWorkflow.php +++ b/src/workflow/ArcanistUpgradeWorkflow.php @@ -31,7 +31,9 @@ EOTEXT ); foreach ($roots as $lib => $root) { - echo pht('Upgrading %s...', $lib)."\n"; + echo phutil_console_format( + "%s\n", + pht('Upgrading %s...', $lib)); $working_copy = ArcanistWorkingCopyIdentity::newFromPath($root); $configuration_manager = clone $this->getConfigurationManager(); diff --git a/src/workflow/ArcanistUploadWorkflow.php b/src/workflow/ArcanistUploadWorkflow.php index 7094cdce..b1c711cb 100644 --- a/src/workflow/ArcanistUploadWorkflow.php +++ b/src/workflow/ArcanistUploadWorkflow.php @@ -204,12 +204,18 @@ EOTEXT $ok = fseek($f, $offset); if ($ok !== 0) { - throw new Exception(pht('Failed to fseek()!')); + throw new Exception( + pht( + 'Failed to %s!', + 'fseek()')); } $data = fread($f, $chunk['byteEnd'] - $chunk['byteStart']); if ($data === false) { - throw new Exception(pht('Failed to fread()!')); + throw new Exception( + pht( + 'Failed to %s!', + 'fread()')); } $conduit->callMethodSynchronous( diff --git a/src/workflow/ArcanistVersionWorkflow.php b/src/workflow/ArcanistVersionWorkflow.php index ea27eaff..807c5732 100644 --- a/src/workflow/ArcanistVersionWorkflow.php +++ b/src/workflow/ArcanistVersionWorkflow.php @@ -48,9 +48,7 @@ EOTEXT if (!Filesystem::pathExists($repository->getMetadataPath())) { throw new ArcanistUsageException( - pht( - '%s is not a git working copy.', - $lib)); + pht('%s is not a git working copy.', $lib)); } list($stdout) = $repository->execxLocal('log -1 --format=%s', '%H %ct'); diff --git a/src/workflow/ArcanistWhichWorkflow.php b/src/workflow/ArcanistWhichWorkflow.php index eca4c733..8bc191e9 100644 --- a/src/workflow/ArcanistWhichWorkflow.php +++ b/src/workflow/ArcanistWhichWorkflow.php @@ -42,20 +42,20 @@ EOTEXT public function getArguments() { return array( 'any-status' => array( - 'help' => 'Show committed and abandoned revisions.', + 'help' => pht('Show committed and abandoned revisions.'), ), 'base' => array( 'param' => 'rules', - 'help' => 'Additional rules for determining base revision.', + 'help' => pht('Additional rules for determining base revision.'), 'nosupport' => array( - 'svn' => 'Subversion does not use base commits.', + 'svn' => pht('Subversion does not use base commits.'), ), 'supports' => array('git', 'hg'), ), 'show-base' => array( - 'help' => 'Print base commit only and exit.', + 'help' => pht('Print base commit only and exit.'), 'nosupport' => array( - 'svn' => 'Subversion does not use base commits.', + 'svn' => pht('Subversion does not use base commits.'), ), 'supports' => array('git', 'hg'), ), @@ -64,7 +64,7 @@ EOTEXT 'help' => pht('Specify the end of the commit range to select.'), 'nosupport' => array( 'svn' => pht('Subversion does not support commit ranges.'), - 'hg' => pht('Mercurial does not support --head yet.'), + 'hg' => pht('Mercurial does not support %s yet.', '--head'), ), 'supports' => array('git'), ), @@ -118,7 +118,7 @@ EOTEXT } $commits = implode("\n", $commits); } else { - $commits = ' (No commits.)'; + $commits = ' '.pht('(No commits.)'); } $explanation = $repository_api->getBaseCommitExplanation(); @@ -139,10 +139,13 @@ EOTEXT echo phutil_console_wrap( phutil_console_format( - "**COMMIT RANGE**\n". - "If you run 'arc diff{$arg}', changes between the commit:\n\n")); - - echo " {$relative} {$relative_summary}\n\n"; + "**%s**\n%s\n\n %s %s\n\n", + pht('COMMIT RANGE'), + pht( + "If you run '%s', changes between the commit:", + "arc diff{$arg}"), + $relative, + $relative_summary)); if ($head_commit === null) { $will_be_sent = pht( @@ -157,11 +160,13 @@ EOTEXT } echo phutil_console_wrap( - "{$will_be_sent}\n\n". - "You can see the exact changes that will be sent by running ". - "this command:\n\n". - " $ {$command}\n\n". - "These commits will be included in the diff:\n\n"); + "%s\n\n%s\n\n $ %s\n\n%s\n\n", + $will_be_sent, + pht( + 'You can see the exact changes that will be sent by running '. + 'this command:'), + $command, + pht('These commits will be included in the diff:')); echo $commits."\n\n\n"; } @@ -180,18 +185,22 @@ EOTEXT echo phutil_console_wrap( phutil_console_format( - "**MATCHING REVISIONS**\n". - "These Differential revisions match the changes in this working ". - "copy:\n\n")); + "**%s**\n%s\n\n", + pht('MATCHING REVISIONS'), + pht( + 'These Differential revisions match the changes in this working '. + 'copy:'))); if (empty($revisions)) { echo " (No revisions match.)\n"; echo "\n"; echo phutil_console_wrap( phutil_console_format( - "Since there are no revisions in Differential which match this ". - "working copy, a new revision will be **created** if you run ". - "'arc diff{$arg}'.\n\n")); + pht( + "Since there are no revisions in Differential which match this ". + "working copy, a new revision will be **created** if you run ". + "'%s'.\n\n", + "arc diff{$arg}"))); } else { $other_author_phids = array(); foreach ($revisions as $revision) { @@ -221,19 +230,23 @@ EOTEXT echo pht(" %s %s\n", $monogram, $title); } - echo ' Reason: '.$revision['why']."\n"; + echo ' '.pht('Reason').': '.$revision['why']."\n"; echo "\n"; } if (count($revisions) == 1) { echo phutil_console_wrap( phutil_console_format( - "Since exactly one revision in Differential matches this working ". - "copy, it will be **updated** if you run 'arc diff{$arg}'.")); + pht( + "Since exactly one revision in Differential matches this ". + "working copy, it will be **updated** if you run '%s'.", + "arc diff{$arg}"))); } else { echo phutil_console_wrap( - "Since more than one revision in Differential matches this working ". - "copy, you will be asked which revision you want to update if ". - "you run 'arc diff {$arg}'."); + pht( + "Since more than one revision in Differential matches this ". + "working copy, you will be asked which revision you want to ". + "update if you run '%s'.", + "arc diff {$arg}")); } echo "\n\n"; } diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index d873ae5d..78d5f5be 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -88,7 +88,9 @@ abstract class ArcanistWorkflow extends Phobject { if ($this instanceof ArcanistBaseWorkflow) { phutil_deprecated( 'ArcanistBaseWorkflow', - 'You should extend from `ArcanistWorkflow` instead.'); + pht( + 'You should extend from `%s` instead.', + __CLASS__)); } $this->finalizeWorkingCopy(); @@ -142,7 +144,9 @@ abstract class ArcanistWorkflow extends Phobject { final public function setConduitURI($conduit_uri) { if ($this->conduit) { throw new Exception( - 'You can not change the Conduit URI after a conduit is already open.'); + pht( + 'You can not change the Conduit URI after a '. + 'conduit is already open.')); } $this->conduitURI = $conduit_uri; return $this; @@ -179,8 +183,10 @@ abstract class ArcanistWorkflow extends Phobject { if (!$this->conduitURI) { throw new Exception( - 'You must specify a Conduit URI with setConduitURI() before you can '. - 'establish a conduit.'); + pht( + 'You must specify a Conduit URI with %s before you can '. + 'establish a conduit.', + 'setConduitURI()')); } $this->conduit = new ConduitClient($this->conduitURI); @@ -225,7 +231,7 @@ abstract class ArcanistWorkflow extends Phobject { final public function setConduitCredentials(array $credentials) { if ($this->isConduitAuthenticated()) { throw new Exception( - 'You may not set new credentials after authenticating conduit.'); + pht('You may not set new credentials after authenticating conduit.')); } $this->conduitCredentials = $credentials; @@ -318,8 +324,9 @@ abstract class ArcanistWorkflow extends Phobject { try { if (!$credentials) { throw new Exception( - 'Set conduit credentials with setConduitCredentials() before '. - 'authenticating conduit!'); + pht( + 'Set conduit credentials with %s before authenticating conduit!', + 'setConduitCredentials()')); } // If we have `token`, this server supports the simpler, new-style @@ -351,12 +358,12 @@ abstract class ArcanistWorkflow extends Phobject { if (empty($credentials['user'])) { throw new ConduitClientException( 'ERR-INVALID-USER', - 'Empty user in credentials.'); + pht('Empty user in credentials.')); } if (empty($credentials['certificate'])) { throw new ConduitClientException( 'ERR-NO-CERTIFICATE', - 'Empty certificate in credentials.'); + pht('Empty certificate in credentials.')); } $description = idx($credentials, 'description', ''); @@ -378,29 +385,24 @@ abstract class ArcanistWorkflow extends Phobject { $ex->getErrorCode() == 'ERR-INVALID-USER' || $ex->getErrorCode() == 'ERR-INVALID-AUTH') { $conduit_uri = $this->conduitURI; - $message = - "\n". - phutil_console_format( - 'YOU NEED TO __INSTALL A CERTIFICATE__ TO LOGIN TO PHABRICATOR'). - "\n\n". - phutil_console_format( - ' To do this, run: **arc install-certificate**'). - "\n\n". - "The server '{$conduit_uri}' rejected your request:". - "\n". - $ex->getMessage(); + $message = phutil_console_format( + "\n%s\n\n %s\n\n%s\n%s", + pht('YOU NEED TO __INSTALL A CERTIFICATE__ TO LOGIN TO PHABRICATOR'), + pht('To do this, run: **%s**', 'arc install-certificate'), + pht("The server '%s' rejected your request:", $conduit_uri), + $ex->getMessage()); throw new ArcanistUsageException($message); } else if ($ex->getErrorCode() == 'NEW-ARC-VERSION') { // Cleverly disguise this as being AWESOME!!! - echo phutil_console_format("**New Version Available!**\n\n"); + echo phutil_console_format("**%s**\n\n", pht('New Version Available!')); echo phutil_console_wrap($ex->getMessage()); echo "\n\n"; - echo "In most cases, arc can be upgraded automatically.\n"; + echo pht('In most cases, arc can be upgraded automatically.')."\n"; $ok = phutil_console_confirm( - 'Upgrade arc now?', + pht('Upgrade arc now?'), $default_no = false); if (!$ok) { throw $ex; @@ -411,7 +413,7 @@ abstract class ArcanistWorkflow extends Phobject { chdir($root); $err = phutil_passthru('%s upgrade', $root.'/bin/arc'); if (!$err) { - echo "\nTry running your arc command again.\n"; + echo "\n".pht('Try running your arc command again.')."\n"; } exit(1); } else { @@ -475,8 +477,11 @@ abstract class ArcanistWorkflow extends Phobject { if (!$this->userPHID) { $workflow = get_class($this); throw new Exception( - "This workflow ('{$workflow}') requires authentication, override ". - "requiresAuthentication() to return true."); + pht( + "This workflow ('%s') requires authentication, override ". + "%s to return true.", + $workflow, + 'requiresAuthentication()')); } return $this->userPHID; } @@ -506,8 +511,11 @@ abstract class ArcanistWorkflow extends Phobject { if (!$this->conduit) { $workflow = get_class($this); throw new Exception( - "This workflow ('{$workflow}') requires a Conduit, override ". - "requiresConduit() to return true."); + pht( + "This workflow ('%s') requires a Conduit, override ". + "%s to return true.", + $workflow, + 'requiresConduit()')); } return $this->conduit; } @@ -692,17 +700,21 @@ abstract class ArcanistWorkflow extends Phobject { '--'.head($corrected))."\n"); $arg_key = head($corrected); } else { - throw new ArcanistUsageException(pht( - "Unknown argument '%s'. Try 'arc help'.", - $arg_key)); + throw new ArcanistUsageException( + pht( + "Unknown argument '%s'. Try '%s'.", + $arg_key, + 'arc help')); } } } else if (!strncmp($arg, '-', 1)) { $arg_key = substr($arg, 1); if (empty($short_to_long_map[$arg_key])) { - throw new ArcanistUsageException(pht( - "Unknown argument '%s'. Try 'arc help'.", - $arg_key)); + throw new ArcanistUsageException( + pht( + "Unknown argument '%s'. Try '%s'.", + $arg_key, + 'arc help')); } $arg_key = $short_to_long_map[$arg_key]; } else { @@ -715,9 +727,10 @@ abstract class ArcanistWorkflow extends Phobject { $dict[$arg_key] = true; } else { if ($ii == $size - 1) { - throw new ArcanistUsageException(pht( - "Option '%s' requires a parameter.", - $arg)); + throw new ArcanistUsageException( + pht( + "Option '%s' requires a parameter.", + $arg)); } if (!empty($options['repeat'])) { $dict[$arg_key][] = $args[$ii + 1]; @@ -733,9 +746,11 @@ abstract class ArcanistWorkflow extends Phobject { $dict[$more_key] = $more; } else { $example = reset($more); - throw new ArcanistUsageException(pht( - "Unrecognized argument '%s'. Try 'arc help'.", - $example)); + throw new ArcanistUsageException( + pht( + "Unrecognized argument '%s'. Try '%s'.", + $example, + 'arc help')); } } @@ -753,8 +768,10 @@ abstract class ArcanistWorkflow extends Phobject { // TODO: We'll always display these as long-form, when the user might // have typed them as short form. throw new ArcanistUsageException( - "Arguments '--{$key}' and '--{$conflict}' are mutually exclusive". - $more); + pht( + "Arguments '%s' and '%s' are mutually exclusive", + "--{$key}", + "--{$conflict}").$more); } } } @@ -775,8 +792,11 @@ abstract class ArcanistWorkflow extends Phobject { if (!$working_copy) { $workflow = get_class($this); throw new Exception( - "This workflow ('{$workflow}') requires a working copy, override ". - "requiresWorkingCopy() to return true."); + pht( + "This workflow ('%s') requires a working copy, override ". + "%s to return true.", + $workflow, + 'requiresWorkingCopy()')); } return $working_copy; } @@ -804,8 +824,11 @@ abstract class ArcanistWorkflow extends Phobject { if (!$this->repositoryAPI) { $workflow = get_class($this); throw new Exception( - "This workflow ('{$workflow}') requires a Repository API, override ". - "requiresRepositoryAPI() to return true."); + pht( + "This workflow ('%s') requires a Repository API, override ". + "%s to return true.", + $workflow, + 'requiresRepositoryAPI()')); } return $this->repositoryAPI; } @@ -833,41 +856,52 @@ abstract class ArcanistWorkflow extends Phobject { $must_commit = array(); $working_copy_desc = phutil_console_format( - " Working copy: __%s__\n\n", + " %s: __%s__\n\n", + pht('Working copy'), $api->getPath()); // NOTE: this is a subversion-only concept. $incomplete = $api->getIncompleteChanges(); if ($incomplete) { throw new ArcanistUsageException( - "You have incompletely checked out directories in this working copy. ". - "Fix them before proceeding.\n\n". - $working_copy_desc. - " Incomplete directories in working copy:\n". - " ".implode("\n ", $incomplete)."\n\n". - "You can fix these paths by running 'svn update' on them."); + sprintf( + "%s\n\n%s %s\n %s\n\n%s", + pht( + "You have incompletely checked out directories in this working ". + "copy. Fix them before proceeding.'"), + $working_copy_desc, + pht('Incomplete directories in working copy:'), + implode("\n ", $incomplete), + pht( + "You can fix these paths by running '%s' on them.", + 'svn update'))); } $conflicts = $api->getMergeConflicts(); if ($conflicts) { throw new ArcanistUsageException( - "You have merge conflicts in this working copy. Resolve merge ". - "conflicts before proceeding.\n\n". - $working_copy_desc. - " Conflicts in working copy:\n". - " ".implode("\n ", $conflicts)."\n"); + sprintf( + "%s\n\n%s %s\n %s", + pht( + 'You have merge conflicts in this working copy. Resolve merge '. + 'conflicts before proceeding.'), + $working_copy_desc, + pht('Conflicts in working copy:'), + implode("\n ", $conflicts))); } $missing = $api->getMissingChanges(); if ($missing) { throw new ArcanistUsageException( - pht( - "You have missing files in this working copy. Revert or formally ". - "remove them (with `svn rm`) before proceeding.\n\n". - "%s". - " Missing files in working copy:\n%s\n", + sprintf( + "%s\n\n%s %s\n %s\n", + pht( + 'You have missing files in this working copy. Revert or formally '. + 'remove them (with `%s`) before proceeding.', + 'svn rm'), $working_copy_desc, - " ".implode("\n ", $missing))); + pht('Missing files in working copy:'), + implode("\n ", $missing))); } $uncommitted = $api->getUncommittedChanges(); @@ -882,27 +916,32 @@ abstract class ArcanistWorkflow extends Phobject { } if ($untracked) { - echo pht( - "You have untracked files in this working copy.\n\n%s", + echo sprintf( + "%s\n\n%s", + pht('You have untracked files in this working copy.'), $working_copy_desc); if ($api instanceof ArcanistGitAPI) { $hint = pht( - '(To ignore these %s change(s), add them to ".git/info/exclude".)', - new PhutilNumber(count($untracked))); + '(To ignore these %s change(s), add them to "%s".)', + new PhutilNumber(count($untracked)), + '.git/info/exclude'); } else if ($api instanceof ArcanistSubversionAPI) { $hint = pht( - '(To ignore these %s change(s), add them to "svn:ignore".)', - new PhutilNumber(count($untracked))); + '(To ignore these %s change(s), add them to "%s".)', + new PhutilNumber(count($untracked)), + 'svn:ignore'); } else if ($api instanceof ArcanistMercurialAPI) { $hint = pht( - '(To ignore these %s change(s), add them to ".hgignore".)', - new PhutilNumber(count($untracked))); + '(To ignore these %s change(s), add them to "%s".)', + new PhutilNumber(count($untracked)), + '.hgignore'); } $untracked_list = " ".implode("\n ", $untracked); - echo pht( - " Untracked changes in working copy:\n %s\n%s", + echo sprintf( + " %s\n %s\n%s", + pht('Untracked changes in working copy:'), $hint, $untracked_list); @@ -924,23 +963,26 @@ abstract class ArcanistWorkflow extends Phobject { // to pause in the middle of printing the output below. $this->getShouldAmend(); - echo pht( - "You have uncommitted changes in this working copy.\n\n%s", + echo sprintf( + "%s\n\n%s", + pht('You have uncommitted changes in this working copy.'), $working_copy_desc); $lists = array(); if ($unstaged) { $unstaged_list = " ".implode("\n ", $unstaged); - $lists[] = pht( - " Unstaged changes in working copy:\n%s", + $lists[] = sprintf( + " %s\n%s", + pht('Unstaged changes in working copy:'), $unstaged_list); } if ($uncommitted) { $uncommitted_list = " ".implode("\n ", $uncommitted); - $lists[] = pht( - " Uncommitted changes in working copy:\n%s", + $lists[] = sprintf( + "%s\n%s", + pht('Uncommitted changes in working copy:'), $uncommitted_list); } @@ -957,15 +999,16 @@ abstract class ArcanistWorkflow extends Phobject { 'arc.autostash', false); if ($permit_autostash && $api->canStashChanges()) { - echo "Stashing uncommitted changes. (You can restore them with ". - "`git stash pop`.)\n"; + echo pht( + 'Stashing uncommitted changes. (You can restore them with `%s`).', + 'git stash pop')."\n"; $api->stashChanges(); $this->stashed = true; } else { throw new ArcanistUsageException( pht( - 'You can not continue with uncommitted changes. Commit '. - 'or discard them before proceeding.')); + 'You can not continue with uncommitted changes. '. + 'Commit or discard them before proceeding.')); } } } @@ -975,10 +1018,10 @@ abstract class ArcanistWorkflow extends Phobject { $commit = head($api->getLocalCommitInformation()); $api->amendCommit($commit['message']); } else if ($api->supportsLocalCommits()) { - $template = - "\n\n". - "# ".pht('Enter a commit message.')."\n#\n". - "# ".pht('Changes:')."\n#\n"; + $template = sprintf( + "\n\n# %s\n#\n# %s\n#\n". + pht('Enter a commit message.'), + pht('Changes:')); $paths = array_merge($uncommitted, $unstaged); $paths = array_unique($paths); @@ -1729,13 +1772,14 @@ abstract class ArcanistWorkflow extends Phobject { if (!$results) { $reasons[] = pht( 'No repositories matched the query. Check that your configuration '. - 'is correct, or use "repository.callsign" to select a repository '. - 'explicitly.'); + 'is correct, or use "%s" to select a repository explicitly.', + 'repository.callsign'); } else if (count($results) > 1) { $reasons[] = pht( 'Multiple repostories (%s) matched the query. You can use the '. - '"repository.callsign" configuration to select the one you want.', - implode(', ', ipull($results, 'callsign'))); + '"%s" configuration to select the one you want.', + implode(', ', ipull($results, 'callsign')), + 'repository.callsign'); } else { $result = head($results); $reasons[] = pht('Found a unique matching repository.'); @@ -1757,12 +1801,14 @@ abstract class ArcanistWorkflow extends Phobject { 'callsigns' => array($callsign), ); $reasons[] = pht( - 'Configuration value "repository.callsign" is set to "%s".', + 'Configuration value "%s" is set to "%s".', + 'repository.callsign', $callsign); return array($query, $reasons); } else { $reasons[] = pht( - 'Configuration value "repository.callsign" is empty.'); + 'Configuration value "%s" is empty.', + 'repository.callsign'); } $project_info = $this->getProjectInfo(); @@ -1774,25 +1820,29 @@ abstract class ArcanistWorkflow extends Phobject { 'callsigns' => array($callsign), ); $reasons[] = pht( - 'Configuration value "project.name" is set to "%s"; this project '. + 'Configuration value "%s" is set to "%s"; this project '. 'is associated with the "%s" repository.', + 'project.name', $project_name, $callsign); return array($query, $reasons); } else { $reasons[] = pht( - 'Configuration value "project.name" is set to "%s", but this '. + 'Configuration value "%s" is set to "%s", but this '. 'project is not associated with a repository.', + 'project.name', $project_name); } } else if (strlen($project_name)) { $reasons[] = pht( - 'Configuration value "project.name" is set to "%s", but that '. + 'Configuration value "%s" is set to "%s", but that '. 'project does not exist.', + 'project.name', $project_name); } else { $reasons[] = pht( - 'Configuration value "project.name" is empty.'); + 'Configuration value "%s" is empty.', + 'project.name'); } $uuid = $this->getRepositoryAPI()->getRepositoryUUID(); @@ -1854,9 +1904,11 @@ abstract class ArcanistWorkflow extends Phobject { if (!$engine_class) { throw new ArcanistNoEngineException( pht( - "No lint engine is configured for this project. ". - "Create an '.arclint' file, or configure an advanced engine ". - "with 'lint.engine' in '.arcconfig'.")); + "No lint engine is configured for this project. Create an '%s' ". + "file, or configure an advanced engine with '%s' in '%s'.", + '.arclint', + 'lint.engine', + '.arcconfig')); } $base_class = 'ArcanistLintEngine'; @@ -1864,8 +1916,7 @@ abstract class ArcanistWorkflow extends Phobject { !is_subclass_of($engine_class, $base_class)) { throw new ArcanistUsageException( pht( - 'Configured lint engine "%s" is not a subclass of "%s", but must '. - 'be.', + 'Configured lint engine "%s" is not a subclass of "%s", but must be.', $engine_class, $base_class)); } @@ -1917,8 +1968,9 @@ abstract class ArcanistWorkflow extends Phobject { throw new ArcanistUsageException( pht( - "Unable to find a browser command to run. Set 'browser' in your ". - "Arcanist config to specify a command to use.")); + "Unable to find a browser command to run. Set '%s' in your ". + "Arcanist config to specify a command to use.", + 'browser')); } diff --git a/src/workflow/exception/ArcanistCapabilityNotSupportedException.php b/src/workflow/exception/ArcanistCapabilityNotSupportedException.php index cd4e4be4..6097fa75 100644 --- a/src/workflow/exception/ArcanistCapabilityNotSupportedException.php +++ b/src/workflow/exception/ArcanistCapabilityNotSupportedException.php @@ -5,8 +5,9 @@ final class ArcanistCapabilityNotSupportedException extends Exception { public function __construct(ArcanistRepositoryAPI $api) { $name = $api->getSourceControlSystemName(); parent::__construct( - "This repository API ('{$name}') does not support the requested ". - "capability."); + pht( + "This repository API ('%s') does not support the requested capability.", + $name)); } } diff --git a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php index 7ddd3feb..ba1985df 100644 --- a/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php +++ b/src/workingcopyidentity/ArcanistWorkingCopyIdentity.php @@ -123,7 +123,10 @@ final class ArcanistWorkingCopyIdentity { if ($config === null) { $console->writeLog( "%s\n", - pht('Working Copy: Reading .arcconfig from "%s".', $config_file)); + pht( + 'Working Copy: Reading %s from "%s".', + '.arcconfig', + $config_file)); $config_data = Filesystem::readFile($config_file); $config = self::parseRawConfigFile($config_data, $config_file); } @@ -136,15 +139,16 @@ final class ArcanistWorkingCopyIdentity { $console->writeLog( "%s\n", pht( - 'Working Copy: Unable to find .arcconfig in any of these '. - 'locations: %s.', + 'Working Copy: Unable to find %s in any of these locations: %s.', + '.arcconfig', implode(', ', $looked_in))); } else { $console->writeLog( "%s\n", pht( - 'Working Copy: No candidate locations for .arcconfig from '. - 'this working directory.')); + 'Working Copy: No candidate locations for %s from '. + 'this working directory.', + '.arcconfig')); } $config = array(); } @@ -202,7 +206,7 @@ final class ArcanistWorkingCopyIdentity { return phutil_json_decode($raw_config); } catch (PhutilJSONParserException $ex) { throw new PhutilProxyException( - pht("Unable to parse '.arcconfig' file '%s'.", $from_where), + pht("Unable to parse '%s' file '%s'.", '.arcconfig', $from_where), $ex); } }