]> khamidou — GitHub mirrors - arcanist.git/commitdiff
`pht` all the things
authorJoshua Spence <josh@joshuaspence.com>
Wed, 13 May 2015 08:05:15 +0000 (18:05 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Wed, 13 May 2015 11:00:53 +0000 (21:00 +1000)
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

110 files changed:
src/configuration/ArcanistConfiguration.php
src/configuration/ArcanistConfigurationManager.php
src/configuration/ArcanistSettings.php
src/configuration/__tests__/ArcanistBritishTestCase.php
src/difference/ArcanistDiffUtils.php
src/differential/constants/ArcanistDifferentialRevisionStatus.php
src/exception/usage/ArcanistUserAbortException.php
src/hgdaemon/ArcanistHgClientChannel.php
src/hgdaemon/ArcanistHgProxyClient.php
src/hgdaemon/ArcanistHgProxyServer.php
src/hgdaemon/ArcanistHgServerChannel.php
src/lint/ArcanistLintPatcher.php
src/lint/ArcanistLintSeverity.php
src/lint/engine/ArcanistLintEngine.php
src/lint/linter/ArcanistBaseXHPASTLinter.php
src/lint/linter/ArcanistCSharpLinter.php
src/lint/linter/ArcanistCppcheckLinter.php
src/lint/linter/ArcanistCpplintLinter.php
src/lint/linter/ArcanistFlake8Linter.php
src/lint/linter/ArcanistGeneratedLinter.php
src/lint/linter/ArcanistGoLintLinter.php
src/lint/linter/ArcanistHLintLinter.php
src/lint/linter/ArcanistJSHintLinter.php
src/lint/linter/ArcanistJSONLintLinter.php
src/lint/linter/ArcanistJscsLinter.php
src/lint/linter/ArcanistLesscLinter.php
src/lint/linter/ArcanistLinter.php
src/lint/linter/ArcanistPEP8Linter.php
src/lint/linter/ArcanistPhpLinter.php
src/lint/linter/ArcanistPhpcsLinter.php
src/lint/linter/ArcanistPhutilXHPASTLinter.php
src/lint/linter/ArcanistPyFlakesLinter.php
src/lint/linter/ArcanistPyLintLinter.php
src/lint/linter/ArcanistRuboCopLinter.php
src/lint/linter/ArcanistRubyLinter.php
src/lint/linter/ArcanistScriptAndRegexLinter.php
src/lint/linter/ArcanistXMLLinter.php
src/lint/linter/__tests__/ArcanistCppcheckLinterTestCase.php
src/lint/linter/__tests__/ArcanistCpplintLinterTestCase.php
src/lint/linter/__tests__/ArcanistLinterTestCase.php
src/lint/linter/__tests__/ArcanistNoLintLinterTestCase.php
src/lint/linter/__tests__/ArcanistPhutilXHPASTLinterTestCase.php
src/lint/linter/__tests__/ArcanistPyLintLinterTestCase.php
src/lint/renderer/ArcanistConsoleLintRenderer.php
src/lint/renderer/ArcanistSummaryLintRenderer.php
src/parser/ArcanistBaseCommitParser.php
src/parser/ArcanistBundle.php
src/parser/ArcanistDiffParser.php
src/parser/__tests__/ArcanistBundleTestCase.php
src/parser/__tests__/ArcanistDiffParserTestCase.php
src/parser/diff/ArcanistDiffChange.php
src/parser/diff/ArcanistDiffChangeType.php
src/parser/diff/ArcanistDiffHunk.php
src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php
src/repository/api/ArcanistRepositoryAPI.php
src/repository/api/ArcanistSubversionAPI.php
src/repository/api/__tests__/ArcanistRepositoryAPIStateTestCase.php
src/repository/parser/ArcanistMercurialParser.php
src/repository/parser/__tests__/ArcanistMercurialParserTestCase.php
src/unit/engine/ArcanistUnitTestEngine.php
src/unit/engine/CSharpToolsTestEngine.php
src/unit/engine/NoseTestEngine.php
src/unit/engine/PhpunitTestEngine.php
src/unit/engine/PhutilUnitTestEngine.php
src/unit/engine/PytestTestEngine.php
src/unit/engine/XUnitTestEngine.php
src/unit/engine/__tests__/PhutilUnitTestEngineTestCase.php
src/unit/engine/phutil/ArcanistPhutilTestCase.php
src/unit/parser/ArcanistGoTestResultParser.php
src/unit/parser/ArcanistPhpunitTestResultParser.php
src/unit/parser/ArcanistXUnitTestResultParser.php
src/unit/parser/__tests__/XUnitTestResultParserTestCase.php
src/unit/renderer/ArcanistUnitConsoleRenderer.php
src/workflow/ArcanistAliasWorkflow.php
src/workflow/ArcanistAmendWorkflow.php
src/workflow/ArcanistBackoutWorkflow.php
src/workflow/ArcanistBrowseWorkflow.php
src/workflow/ArcanistCloseRevisionWorkflow.php
src/workflow/ArcanistCloseWorkflow.php
src/workflow/ArcanistCommitWorkflow.php
src/workflow/ArcanistCoverWorkflow.php
src/workflow/ArcanistDiffWorkflow.php
src/workflow/ArcanistDownloadWorkflow.php
src/workflow/ArcanistExportWorkflow.php
src/workflow/ArcanistFeatureWorkflow.php
src/workflow/ArcanistFlagWorkflow.php
src/workflow/ArcanistGetConfigWorkflow.php
src/workflow/ArcanistHelpWorkflow.php
src/workflow/ArcanistInstallCertificateWorkflow.php
src/workflow/ArcanistLandWorkflow.php
src/workflow/ArcanistLiberateWorkflow.php
src/workflow/ArcanistLintWorkflow.php
src/workflow/ArcanistLintersWorkflow.php
src/workflow/ArcanistListWorkflow.php
src/workflow/ArcanistPasteWorkflow.php
src/workflow/ArcanistPatchWorkflow.php
src/workflow/ArcanistRevertWorkflow.php
src/workflow/ArcanistSetConfigWorkflow.php
src/workflow/ArcanistShellCompleteWorkflow.php
src/workflow/ArcanistTasksWorkflow.php
src/workflow/ArcanistTodoWorkflow.php
src/workflow/ArcanistUnitWorkflow.php
src/workflow/ArcanistUpgradeWorkflow.php
src/workflow/ArcanistUploadWorkflow.php
src/workflow/ArcanistVersionWorkflow.php
src/workflow/ArcanistWhichWorkflow.php
src/workflow/ArcanistWorkflow.php
src/workflow/exception/ArcanistCapabilityNotSupportedException.php
src/workingcopyidentity/ArcanistWorkingCopyIdentity.php

index d232da3d7b80a145bc0ba8f0c9d4875a631f1321..5755cc5e5a3d5efef665ad9360a7744ae0b1f7c6 100644 (file)
@@ -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);
index ef9b0b4fb64a700e3c800825d9f5aad86e86c733..6195a1ec9ac21e668dc88ccab26e5c52199b4794 100644 (file)
@@ -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;
index ad5f7626a37b03dd3f8b0a712c44f1aa0a532839..b6ede18096146136093e444e941ba7b7c0fd3eed 100644 (file)
@@ -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(
index 8a5dde3965cf39d8fd7f4dfd7eeac3ed85071f6f..53517e46c6fff45221150d0667918df3ebd87c5d 100644 (file)
@@ -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));
   }
 
 }
index c789cddcde1f85df64b9dbad18cc305d8c37ea36..f3486d6f652770ffdba0e755e654bfcea002fac2 100644 (file)
@@ -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();
index 017000e9e9f683c1f82de190be6d8180d3055f9f..62c3eec7b1b733978fe0b1a2c5f97ea5e6dbe008 100644 (file)
@@ -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'));
   }
 
 }
index d1aa1ee1a6e742d82742c8d9dfbbf821472cc19a..f87951f77ec8153ae86ddd7dc6fc6adec90467a0 100644 (file)
@@ -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.'));
   }
 
 }
index a1c803a5993ae6e9b9466df24f6aeb2453c34e60..82ce300290b1fe47a2d0a61217755d6d08cbb709 100644 (file)
@@ -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 <channel, data>.');
+      throw new Exception(pht('Message should be %s.', '<channel, data>'));
     }
 
     $channel = head($argv);
index 62c32b41ca6edd25fd559edaef70947cbf4476d3..86053fc48483b6b4551f0053616587144a838e74 100644 (file)
@@ -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);
index a6e19a251c2b5fa5aadcea28a30671b301701160..9a2e8eb0f8d8bce2763d7b5f71be250397541ad1 100644 (file)
@@ -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
index b16f3bd10c0b7898efd896844078b5b4d8fe694d..1850c9af70ceb306e20d10dc536c7d91fd057df9 100644 (file)
@@ -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);
index 1cea8dc3763ea7473265e1bcc0107f9d6ed9d128..5bbd2503e5dc499471daadaa27206c5c36f878c0 100644 (file)
@@ -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);
index c34756d92cbdac0deeca1f19c65819b1ff650c2f..a8da738ed042d6f31fe2f3363f40c25d9fd329a1 100644 (file)
@@ -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];
index 29cf13d6fcb407a36683745c249e369a0b63ef96..e320fc0c95c8b36094041755b637bea83ecbc084 100644 (file)
@@ -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;
index a62797456eafa48c6f800fd245892979895c6a38..3549a35344666a513638df3b45f99ae3f4eed55f 100644 (file)
@@ -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]--;
index 89c1f632aa44dbf9eb4cc0b0be1d8708d2957aff..6120a07b368296411315d8f9b7478520be7ac608 100644 (file)
@@ -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;
index 830452a59e48ffa6af0d89c6f2cddc427d98b0e4..d5df5acb4422a81aba9cfb4512db82fe2d798f4d 100644 (file)
@@ -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() {
index 7d8b4bbc79ce3b79553838fe0dd4bd5d639296e4..3587131d885d6b96088b83087062c4d8129e4dc9 100644 (file)
@@ -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() {
index 6c1c6d6f0f16c008f6756531513edbc69a9e682e..4cdab66155fdb6432c5fafddfcddefa53c1b01ff 100644 (file)
@@ -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) {
index 29c1e80975f45fa8f2daab11a68786a611487c9b..4d01bca735f023d6b8946680bcfbc52e2cac4950 100644 (file)
@@ -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');
   }
 
index e886e05c37cf8ea2479d243908c4f2f3c9a6fc28..0252d4c9a138e044e42a4e36a98b22995221ddee 100644 (file)
@@ -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() {
index 6274e045714bd75b47d8f451c211cff409471e5f..5a197ce408a744e41f1f3bfdf20fffdcb12f9c43 100644 (file)
@@ -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':
index 76efca9d388d2a05099ff44442ab8dbb6ec4a6dc..f175a144c58bac32eac85406545ccde11375ef15 100644 (file)
@@ -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() {
index b4a65bdfc0876b30b01d1a0743f4796b7da9ea59..2ac0dbbef4f739f16e6291f3a856c31bbd9ab3d4 100644 (file)
@@ -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() {
index cc0372141683416ffe873ae723051ae49fb8c770..6d8f2537799df1052dd842b977c31ad9db7c158a 100644 (file)
@@ -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',
index 5516540baceb25f3a505395d454afde19d89b933..f51660e28a4754bba47e2631b49ad941b06946f9 100644 (file)
@@ -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']);
index 41e27c1c042325fce0d7724789dad06b6c6ade16..aae1fbbd801624b1d3bafb452f56f1d485ec3f64 100644 (file)
@@ -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;
     }
 
index 03811358447c06adb846b6c9867324f868c3d878..984e64bf94e4c09762624d6528a7529cd33d0cee 100644 (file)
@@ -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) {
index bd6b82224901a03cb19a5d308ceaec2b70b95163..c272305e884cfd3433eb899cfa573485dd0f9f99 100644 (file)
@@ -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));
     }
   }
 
index 68d4d7f36bf56bc798deb16f5337ea849446bf12..f05df5c541e16c7c219213734061193e1a93ed04 100644 (file)
@@ -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;
   }
index 50897d53e92b49717d25e97cea2a9368aa55b582..69d1ba86d86611773295812ea28813afc6a3dcbc 100644 (file)
@@ -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'),
     );
   }
 
index 59d919950aba6ee7e9a79b82b427d753330875ea..b88a33222858820cfc7c2ef2500746826375c87f 100644 (file)
@@ -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) {
index 45ebf37fd0f4945ee1877a94fa58d79e08dc74f6..ce1c60de7848040d6fd9e4dc2166eddd423f06ba 100644 (file)
@@ -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'));
       }
     }
 
index 0647a7bc3fc25586f9939c7f3cf082b831d49e1f..c7585ca65282b3d7f80122296b82664d3c371883 100644 (file)
@@ -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) {
index b2d765679131f6cc305b76011a1707ccc9c8c758..fb8ed25e4ebae684a276fc9bfc1d62aba2c506b9 100644 (file)
@@ -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 <http://www.ruby-lang.org/>.');
+    return pht('Install `%s` from <%s>.', 'ruby', 'http://www.ruby-lang.org/');
   }
 
   protected function getMandatoryFlags() {
index c2422f474c9c10da09ad682a86ce6538e49be092..8e8a1f5c5622c923908111af7755270403e3463c 100644 (file)
@@ -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');
index a1274861ee44be6a4b4dfba89cdc4ad879e561e3..b48b19bcc7ebbd1e5c66a0035f2fcab4f711a259 100644 (file)
@@ -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) {
index 75310761ccbe0f0abc0cf60b6771efed2041927e..8bf305b7b3574bdfb1aad2d11417e15b08d94f51 100644 (file)
@@ -4,7 +4,7 @@ final class ArcanistCppcheckLinterTestCase
   extends ArcanistExternalLinterTestCase {
 
   public function testLinter() {
-    return $this->executeTestsInDirectory(dirname(__FILE__).'/cppcheck/');
+    $this->executeTestsInDirectory(dirname(__FILE__).'/cppcheck/');
   }
 
 }
index f178bb9f4f181cdb4ffc05a344166c0f60a075e0..7aef6db15095f16773e53b7c723d1e58a5c01c2b 100644 (file)
@@ -4,7 +4,7 @@ final class ArcanistCpplintLinterTestCase
   extends ArcanistExternalLinterTestCase {
 
   public function testLinter() {
-    return $this->executeTestsInDirectory(dirname(__FILE__).'/cpplint/');
+    $this->executeTestsInDirectory(dirname(__FILE__).'/cpplint/');
   }
 
 }
index 322dca7f8e7e52931a4a1774c23699de39e98cc9..738269aee01c5e4aff8d3d94dfb3dfc289114fdb 100644 (file)
@@ -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) {
index dab24b2da01fd6bb05f1c38837a3574972ea3593..0c4cbd8d69d8859a8e799c1be06fa8fce1512e6e 100644 (file)
@@ -3,7 +3,7 @@
 final class ArcanistNoLintLinterTestCase extends ArcanistLinterTestCase {
 
   public function testLinter() {
-    return $this->executeTestsInDirectory(dirname(__FILE__).'/nolint/');
+    $this->executeTestsInDirectory(dirname(__FILE__).'/nolint/');
   }
 
 }
index 824b1b74fe4df75cce5868af3081cf0dbd4a2372..d773e1f5313acbf9a59b9e550aed5140fb285d23 100644 (file)
@@ -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);
index 4d93f648b5fb5b68e847ffbccdab4146bf92ae36..bbff142b3e7ab309e741131593a942ce2fc1585c 100644 (file)
@@ -4,7 +4,7 @@ final class ArcanistPyLintLinterTestCase
   extends ArcanistExternalLinterTestCase {
 
   public function testLinter() {
-    return $this->executeTestsInDirectory(dirname(__FILE__).'/pylint/');
+    $this->executeTestsInDirectory(dirname(__FILE__).'/pylint/');
   }
 
 }
index b1c32a517dd30c834d6896ba3b7b2655d11ba7e0..6f3476b0dd9f9e7e968a4034dfbb8ff542bc353c 100644 (file)
@@ -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(
-      "<bg:green>** OKAY **</bg> No lint warnings.\n");
+      "<bg:green>** %s **</bg> %s\n",
+      pht('OKAY'),
+      pht('No lint warnings.'));
   }
 
 }
index c78374949786e0f32cdd9b7c20abc3bd35416823..92eed3a4927c15b9a01df677c634c70fbcc8b3f1 100644 (file)
@@ -24,7 +24,9 @@ final class ArcanistSummaryLintRenderer extends ArcanistLintRenderer {
 
   public function renderOkayResult() {
     return phutil_console_format(
-      "<bg:green>** OKAY **</bg> No lint warnings.\n");
+      "<bg:green>** %s **</bg> %s\n",
+      pht('OKAY'),
+      pht('No lint warnings.'));
   }
 
 }
index 7927f6b63809562e1a9ba06affa8682b6b0ca7c1..a546b702c75053dd1003ef20ff9742abc6a18a97 100644 (file)
@@ -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;
index 79bb574c9813ea32968753beee82ad50b11cdfda..7324b8ea8cd3fbdd5328e058a6e9b61a3f4e3045 100644 (file)
@@ -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.
index bbe01d0f289b3fe12e268d9ab9d1b5afeef9a170..0e9627b778b1d8464a8a7b5dd0ed00371cffb19e 100644 (file)
@@ -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'];
index 19f251d9a5252530905c3a97de40a0c491507eb8..cbd6b41e0c100089ae191bd4abe75012c02d0ae9 100644 (file)
@@ -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));
     }
   }
 
index 378013150d5e4a343813823e03b11a35ae98955c..9322063cb9c1cea9ccd3cdfc3454ee711286722b 100644 (file)
@@ -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));
     }
   }
 
index c5e8de7e89f388a4077ad36b6bce94a2a72eff71..06f68b6ccdd115dd916fd62d24a698d8fb6e66c3 100644 (file)
@@ -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]);
   }
index ef84985a64c4e1e76fa64959743d5a0022a33411..36ea5a5c0fb1e5282aacfc6d0d3f53690db445bf 100644 (file)
@@ -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'));
   }
 
 }
index f47dd242fe6bd748dafbe8107e223d0f944071f9..cfd6d998d4a48fb0779ae352c5a16dbe3f78b04a 100644 (file)
@@ -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));
     }
   }
 
index 5377ebafe824bd0508bc84b473140ab68b9ff3f7..7b0bd64b5185620f0509123a1d276673edb399fe 100644 (file)
@@ -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(
         "<bg:green>** Select a Default Commit Range **</bg>\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.)");
-
-      $prompt = 'What default do you want to use? [origin/master]';
+        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 = 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:
index efe51198f4c33bfddc64b1314fecc87ec9a7fe06..4abcea04ddff28dacc9badf5b01df660335f3ab1 100644 (file)
@@ -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;
                 }
               }
index d5a3b540843b0f08ed634ee6d447b1678089b169..56c7a931c063a2025476b3c257f4baa82dae9870 100644 (file)
@@ -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();
index 9b529c084d2abbeb46a1f2e2e7c9afd057e950ef..e953611191457c3ae9c5d7efd49ac3e47e7037a2 100644 (file)
@@ -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;
index ed13af09b998369e873a2afab61cc796e1335246..236f46c704f3e966bdc83650555da799477e4dcb 100644 (file)
@@ -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));
     }
   }
 
index d5d2bf13a3cb18be6dea033fea100ef310c31de0..b9044500fa73f7d4ff023960ab07a179209e8823 100644 (file)
@@ -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],
index 2129448d2e2d02c5e578d5e721a2616d1665674b..6ff5f426fee2627a6e75101b9e953f0bc5a798bf 100644 (file)
@@ -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));
     }
   }
 
index c449ed6f74587f6c8de84661097b78abb74b8047..8dd6e672965ea2133070beb9b151449fad9d0823 100644 (file)
@@ -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;
index 03ad75bbda0116a4ea401c4f69867a5f529344ef..7fd23e0d0daefb7bf6194d729c5bcf6cc2edfa3d 100644 (file)
@@ -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'));
     }
   }
 
index c5c95e3e2002ecfb86826b82e56701d15ead5292..9af83c56af55794db521dc84e0708ce2b7c57496 100644 (file)
@@ -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(
index eb545fb11c92a3b0d64fe693d4bb748bcc63ee5e..8206b787ff1345f4c5531e9c0ced8d6e119223fa 100644 (file)
@@ -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(
index c2a255c3880dd5db9e6b1622e32398e7b0efa6e7..ae7906002609b34cd114777c86d26dd35d24433e 100644 (file)
@@ -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);
index 11315e3f952cc85683fd51da461b25ba62c9aef2..e5fa7370d502c824ecc4e6945c0cd93f1b224b69 100644 (file)
@@ -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,
index 1824b5b804160c7a8329653c6bbb9738a080a01d..cec076c5a11dadb47230f4b77eae6cf414daffbf 100644 (file)
@@ -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();
index aa055910ac590a528f3580f9c53041cf9a0fd004..561e108b16681eeca5eef1e6fc0aeca089608934 100644 (file)
@@ -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!'));
     }
   }
 
index 96b9fdeb331d0a91179ac3a4b936b2a9b087b656..3e10052b1a0564d2bbfa18a27efa3a3c162ed133 100644 (file)
@@ -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."));
     }
   }
 
index 41463f108dcb3b4f55503509917a90be9fced69a..fa0a2672dbac65f1879369268a8c69a502a4364a 100644 (file)
@@ -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);
index 1710f71aef91b1f988f2e27fd71049914cc020d7..314c82656f100dea65316d9504fdb6b205443589 100644 (file)
@@ -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);
index fead0ab070913724202386b51e3595f0382a5daf..3f1f447d4c7fe6b1e22294c4053e25a83cddfc00 100644 (file)
@@ -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();
index 2157a80bcaf65fc2dbaaeb03f237e462f1cff224..84c93dca1435e826475972501bd02732bf7f870f 100644 (file)
@@ -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
     }
index 0f93aad0aa298e5c1a4aa5ebe69920bf4b2ccec6..c2e95c0104a2ca40bd7c84caea1ce7793b349094 100644 (file)
@@ -36,16 +36,32 @@ final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer {
   }
 
   private function getFormattedResult($result) {
-    static $status_codes = array(
-      ArcanistUnitTestResult::RESULT_PASS => '<bg:green>** PASS **</bg>',
-      ArcanistUnitTestResult::RESULT_FAIL => '<bg:red>** FAIL **</bg>',
-      ArcanistUnitTestResult::RESULT_SKIP => '<bg:yellow>** SKIP **</bg>',
-      ArcanistUnitTestResult::RESULT_BROKEN => '<bg:red>** BROKEN **</bg>',
-      ArcanistUnitTestResult::RESULT_UNSOUND => '<bg:yellow>** UNSOUND **</bg>',
-      ArcanistUnitTestResult::RESULT_POSTPONED =>
-        '<bg:yellow>** POSTPONED **</bg>',
-    );
-    return phutil_console_format($status_codes[$result]);
+    switch ($result) {
+      case ArcanistUnitTestResult::RESULT_PASS:
+        return phutil_console_format('<bg:green>** %s **</bg>', pht('PASS'));
+
+      case ArcanistUnitTestResult::RESULT_FAIL:
+        return phutil_console_format('<bg:red>** %s **</bg>', pht('FAIL'));
+
+      case ArcanistUnitTestResult::RESULT_SKIP:
+        return phutil_console_format('<bg:yellow>** %s **</bg>', pht('SKIP'));
+
+      case ArcanistUnitTestResult::RESULT_BROKEN:
+        return phutil_console_format('<bg:red>** %s **</bg>', pht('BROKEN'));
+
+      case ArcanistUnitTestResult::RESULT_UNSOUND:
+        return phutil_console_format(
+          '<bg:yellow>** %s **</bg>',
+          pht('UNSOUND'));
+
+      case ArcanistUnitTestResult::RESULT_POSTPONED:
+        return phutil_console_format(
+          '<bg:yellow>** %s **</bg>',
+          pht('POSTPONED'));
+
+      default:
+        return null;
+    }
   }
 
   private function formatTestDuration($seconds) {
index 40cf9a949d94cad19ba83cfc8f1b351602502a1b..9762821d8ba39e1bdba9f3518f85e0b16c9dd1a3 100644 (file)
@@ -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);
     }
index 334ff9d266a065d27928398257ccbfaae6cff9f3..e660d8909f37bc3134f2bfe452fbb0924c21a026 100644 (file)
@@ -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 <id>' 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 <id>'));
       } 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 <id>' 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 <id>');
         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);
     }
index f4667a352ce853eb52febb3c6edbb0e06a733924..bd554e1871279f31ddfa3e9724b0aa4e1c63a342 100644 (file)
@@ -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");
   }
 
 }
index 9653affe1e4fc51ff3cca3b1bd45c40a2a499b3d..76aa66dd6867d14213624d566f0278e7a9edf689 100644 (file)
@@ -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');
index 5e234284da4dcdefc1fee0356fb90451dfd8a20b..af1e3031f9d36d3089f62a2b65a5a3dd1079c6f1 100644 (file)
@@ -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";
       }
     }
 
index 083ec355c01f0ad757c83a534fbb937f9a6715ef..b32b9caa88bea2d6b95b47c30b634e83af7e9ef7 100644 (file)
@@ -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;
index 6c727b5ab8bc6c6c9e9d854c14d328c9983c47ff..72dae0ffb04fdf95b42c360551d1cbeb99b47bf6 100644 (file)
@@ -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 <revision_id>' to select a revision.");
+          pht(
+            "Unable to identify the revision in the working copy. Use ".
+            "'%s' to select a revision.",
+            '--revision <revision_id>'));
       } 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 <revision_id>' 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 <revision_id>'));
       }
 
     } 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) {
index 5e984cf9074c9160bed793328dc15c02b5d0db10..35c3c891936561a87dc3bc3b68bb923f205b6c71 100644 (file)
@@ -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;
index 78621a739d01bb96a8f11b171eaadde441d5aa3e..347549663f99c4b4717da392d658d477711bacf4 100644 (file)
@@ -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'));
         }
       }
     }
index bb320af3c1199e10fa568acc3f349e5c8a75bbcf..49cb81178f9e9a35ed20237c36b1d2d58c214fae 100644 (file)
@@ -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;
index 01abb79f21bfa3b89d41a33556665d6f195edf41..d3e3b3962345d5714bbe7eca8ece89d6ddb76dce 100644 (file)
@@ -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 <path>' to ".
-        "choose an export format.");
+        pht(
+          "Specify one of '%s', '%s' or '%s' to choose an export format.",
+          '--git',
+          '--unified',
+          '--arcbundle <path>'));
     } 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;
     }
 
index b69074a0796c6e59297b8b51f601da5217c234fe..2fc70aadaedf64c6b9de653275e8c138d995c15d 100644 (file)
@@ -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']) {
index 2a7e06c26bffcc97df456d952eda28db5c0d0612..d842072862496ffc0fe205dd195a8d7c06adff2c 100644 (file)
@@ -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
index be5af0033e872202719ed18a3594fabcc523ef52..565856bdca0c7d7adc45064191eb7f24d448d9b3 100644 (file)
@@ -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;
index 0a4af1660d51e11fc26936e46b21021d820ef682..2792afde8694edab7c023400925b645392ff5eb5 100644 (file)
@@ -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;
     }
 
index ae68f4f24aa0b4d66ef23c8384ec858733f61a8a..41f0726ec6a9cc7f59820db8382779d2ca2fc4eb 100644 (file)
@@ -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(
-        "<bg:green>** SUCCESS! **</bg> API Token installed.\n");
+        "<bg:green>** %s **</bg> %s\n",
+        pht('SUCCESS!'),
+        pht('API Token installed.'));
     } else {
       echo phutil_console_format(
-        "<bg:green>** SUCCESS! **</bg> Certificate installed.\n");
+        "<bg:green>** %s **</bg> %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;
     }
index 69c498ec6f13dac85d28a8f37f6f82bce33a0bce..8f72f439144610efef15fea0a6f6372963eaeb6f 100644 (file)
@@ -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 <id>' 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 <id>'));
     } 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("<bg:red>**   %s   **</bg>\n", $failed_str);
+        echo phutil_console_format(
+          "<bg:red>**   %s   **</bg>\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(
         "**<bg:green> %s </bg>** %s\n",
         pht('BUILDS PASSED'),
-        pht(
-          'Harbormaster builds for the active diff completed successfully.'));
+        pht('Harbormaster builds for the active diff completed successfully.'));
       return;
     }
 
index 176bc8bcf6533c5339fd409754577bd662e022d9..c7fe1bd9af6537cd959b89962a1c7043d2dab21b 100644 (file)
@@ -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
       "<?php\n\n".
       "phutil_register_library('{$name}', __FILE__);\n";
 
-    echo "Writing '__phutil_library_init__.php' to '{$path}'...\n";
+    echo pht(
+      "Writing '%s' to '%s'...\n",
+      '__phutil_library_init__.php',
+      $path);
     Filesystem::writeFile($init_path, $template);
     $this->liberateVersion2($path);
   }
index 187a0facdb9663faea3a90ff7c871124b1528ba2..a824a080830bf86eeb36b32e030a6984945b4d64 100644 (file)
@@ -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(
-          "<bg:yellow>** LINT NOTICE **</bg> Automatically amending HEAD ".
-          "with lint patches.\n");
+          "<bg:yellow>** %s **</bg> %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.'));
       }
     }
 
index c2d8cef7839278737b530a3299245b795cf88116..b872e300c0784f00ba7741ba7c0b9485c4de2a4b 100644 (file)
@@ -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();
index 5ed6fb222a60a5432e530b1e311189707a2092ea..ff6f0c6e753818b7418140d06328dd176db32c7d 100644 (file)
@@ -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(
-          "<fg:{$spec['color']}>%s</fg>", $spec['statusName']),
+          "<fg:{$spec['color']}>%s</fg>",
+          $spec['statusName']),
         'title'  => phutil_console_format(
-          '**D%d:** %s', $revision['id'], $revision['title']),
+          '**D%d:** %s',
+          $revision['id'],
+          $revision['title']),
       ));
     }
 
index 27981b6285f826fc6bbf83bea701ba6fba2197e9..f7f1bbffd9d5d01e61f091703dff58a5fb2c97a1 100644 (file)
@@ -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(
index fb3d0e0643443d542a07f801bf447ec93083c709..4fbc9cf09dc20facee2abf2553eec77daf19fcbb 100644 (file)
@@ -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 <revision_id>' (to select the ".
-        "current changes attached to a Differential revision), ".
-        "'--diff <diff_id>' (to select a specific, out-of-date diff or a ".
-        "diff which is not attached to a revision), '--arcbundle <file>' ".
-        "or '--patch <file>' 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 <revision_id>',
+          '--diff <diff_id>',
+          '--arcbundle <file>',
+          '--patch <file>'));
     } 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(
-          "<bg:green>** OKAY **</bg> Successfully applied patch ".
-          "to the working copy.\n");
+          "<bg:green>** %s **</bg> %s\n",
+          pht('OKAY'),
+          pht('Successfully applied patch to the working copy.'));
       } else {
         echo phutil_console_format(
-          "\n\n<bg:yellow>** WARNING **</bg> 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<bg:yellow>** %s **</bg> %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<bg:red>** Patch Failed! **</bg>\n");
+          "\n<bg:red>** %s **</bg>\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<bg:red>** Cherry Pick Failed!**</bg>\n");
+            "\n<bg:red>** %s**</bg>\n",
+            pht('Cherry Pick Failed!'));
           throw $ex;
         }
       }
 
       echo phutil_console_format(
-        "<bg:green>** OKAY **</bg> Successfully {$verb} patch.\n");
+        "<bg:green>** %s **</bg> %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<bg:red>** Patch Failed! **</bg>\n");
+          "\n<bg:red>** %s **</bg>\n",
+          pht('Patch Failed!'));
         $stderr = $ex->getStdErr();
         if (preg_match('/case-folding collision/', $stderr)) {
           echo phutil_console_wrap(
             phutil_console_format(
-              "\n<bg:yellow>** WARNING **</bg> 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<bg:yellow>** %s **</bg> %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<bg:red>** Rebase onto $original_branch failed!**</bg>\n"));
+            throw new ArcanistUsageException(
+              phutil_console_format(
+                "\n<bg:red>** %s**</bg>\n",
+                pht('Rebase onto %s failed!', $original_branch)));
           }
         }
 
-        $verb = 'committed';
+        $verb = pht('committed');
       } else {
-        $verb = 'applied';
+        $verb = pht('applied');
       }
 
       echo phutil_console_format(
-        "<bg:green>** OKAY **</bg> Successfully {$verb} patch.\n");
-
+        "<bg:green>** %s **</bg> %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();
index 205c91d3ee10b3ae324f308e0982b5d7f2df8169..efcc25bcddbaf43813227d3b1255e5548f0ae5ef 100644 (file)
@@ -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;
   }
 
index 3dfb3759eb6452679cf1bd32370f904aad0149ae..9d9b099d2d102d4f6bc64980a37c40f00250438d 100644 (file)
@@ -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);
       }
     }
 
index ca519903556ec98fe4b24db348a228b235b964c1..90551f2ae4883508fc0ed18e05bb4d050b03b344 100644 (file)
@@ -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
index 68bc89e75f3c88068fcbd2d1ddf2cea889c2a4b4..fe0201d6319369b0c75437d3cc7ff577985eae6b 100644 (file)
@@ -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();
index 30550e5918a7ea50090630df0f560933eac82c55..6914bbd076930332950f33f596162bc60b8e19d8 100644 (file)
@@ -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: '<fg:green>**%s**</fg>' at <fg:blue>**%s**</fg>\n",
-      $result['id'],
-      $result['title'],
-      $result['uri']);
+    echo pht(
+      "Created task %s: '%s' at %s\n",
+      'T'.$result['id'],
+      phutil_console_format('<fg:green>**%s**</fg>', $result['title']),
+      phutil_console_format('<fg:blue>**%s**</fg>', $result['uri']));
 
     if ($this->getArgument('browse')) {
       $this->openURIsInBrowser(array($result['uri']));
index d2ccdd483a3f7dd33bfc5c2f2b5d148474971405..2d3d8a7abfad482dfecc968560d9b70e09bb8e18 100644 (file)
@@ -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) {
index 40939f603e67b8b2152122e786e3b7f0ce67d82d..ed30593f0937be0b661387cebd750860b93a2e98 100644 (file)
@@ -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();
index 7094cdce69297c8374f734ea308303a1065fbd4c..b1c711cb7458a68008e229ddd6c74e6f348edc94 100644 (file)
@@ -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(
index ea27eaff3c11aca5911d4ffb0a92c807abc972b0..807c573275bf175792cc33da56ee6009fd1a7a3f 100644 (file)
@@ -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');
index eca4c7339f275eb417ad57153e7b929196797fcd..8bc191e98fc5eac1d43e565404740c25e90a15f9 100644 (file)
@@ -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";
     }
index d873ae5d0edfe845f61484866e629cb1f3451ba0..78d5f5bee280d0a85568e3400df52518e1d51fe5 100644 (file)
@@ -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'));
   }
 
 
index cd4e4be48c413e0243bb5aba43bdb8eacd6f4a8a..6097fa7572cce1cded038678e5675e8011c63b13 100644 (file)
@@ -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));
   }
 
 }
index 7ddd3feb1b9b27f62d79b2a2547fbe72dcd49276..ba1985df6b523725a3442e71cf450e5ce6ba61d4 100644 (file)
@@ -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);
     }
   }