Skip to content

Commit

Permalink
pht all the things
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joshuaspence committed May 13, 2015
1 parent 9090efc commit d2b38cd
Show file tree
Hide file tree
Showing 110 changed files with 1,784 additions and 1,151 deletions.
15 changes: 10 additions & 5 deletions src/configuration/ArcanistConfiguration.php
Expand Up @@ -46,8 +46,11 @@ public function buildAllWorkflows() {
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;
Expand Down Expand Up @@ -109,7 +112,8 @@ final public function selectWorkflow(
$shell_cmd = substr($full_alias, 1);

$console->writeLog(
"[alias: 'arc %s' -> $ %s]",
"[%s: 'arc %s' -> $ %s]",
pht('alias'),
$command,
$shell_cmd);

Expand All @@ -127,7 +131,8 @@ final public function selectWorkflow(
$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;
Expand Down Expand Up @@ -168,7 +173,7 @@ final public function selectWorkflow(
}

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);
Expand Down
20 changes: 13 additions & 7 deletions src/configuration/ArcanistConfigurationManager.php
Expand Up @@ -180,11 +180,13 @@ public function readUserConfigurationFile() {
}
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);

Expand All @@ -200,7 +202,7 @@ public function readUserConfigurationFile() {
$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 {
Expand Down Expand Up @@ -236,7 +238,7 @@ public function writeUserConfigurationFile($config) {
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;
Expand Down Expand Up @@ -318,8 +320,12 @@ public function applyRuntimeArcConfig($args) {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/ArcanistSettings.php
Expand Up @@ -86,7 +86,7 @@ private function getOptions() {
'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(
Expand Down
4 changes: 2 additions & 2 deletions src/configuration/__tests__/ArcanistBritishTestCase.php
Expand Up @@ -53,7 +53,7 @@ private function assertCommandCompletion($expect, $input, $commands) {
$this->assertEqual(
$expect,
$result,
"Correction of {$input} against: {$commands}");
pht('Correction of %s against: %s', $input, $commands));
}

public function testArgumentCompletion() {
Expand Down Expand Up @@ -91,7 +91,7 @@ private function assertArgumentCompletion($expect, $input, $arguments) {
$this->assertEqual(
$expect,
$result,
"Correction of {$input} against: {$arguments}");
pht('Correction of %s against: %s', $input, $arguments));
}

}
2 changes: 1 addition & 1 deletion src/difference/ArcanistDiffUtils.php
Expand Up @@ -26,7 +26,7 @@ public static function renderDifferences(
$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();
Expand Down
Expand Up @@ -21,7 +21,7 @@ public static function getNameForRevisionStatus($status) {
self::IN_PREPARATION => pht('In Preparation'),
);

return idx($map, coalesce($status, '?'), 'Unknown');
return idx($map, coalesce($status, '?'), pht('Unknown'));
}

}
2 changes: 1 addition & 1 deletion src/exception/usage/ArcanistUserAbortException.php
Expand Up @@ -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.'));
}

}
2 changes: 1 addition & 1 deletion src/hgdaemon/ArcanistHgClientChannel.php
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/hgdaemon/ArcanistHgProxyClient.php
Expand Up @@ -163,7 +163,10 @@ private function connectToDaemon() {

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);
Expand Down
35 changes: 22 additions & 13 deletions src/hgdaemon/ArcanistHgProxyServer.php
Expand Up @@ -168,7 +168,7 @@ public function start() {
$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
Expand All @@ -181,7 +181,7 @@ public function start() {
));

if (!$hg->update()) {
throw new Exception('Server exited unexpectedly!');
throw new Exception(pht('Server exited unexpectedly!'));
}

// Accept any new clients.
Expand All @@ -190,7 +190,7 @@ public function start() {
$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
Expand All @@ -216,15 +216,15 @@ public function start() {
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.

if ($this->clientLimit) {
if ($this->lifetimeClientCount >= $this->clientLimit) {
if (!$clients) {
$this->log(null, 'Exiting (Client Limit)');
$this->log(null, pht('Exiting (Client Limit)'));
return;
}
}
Expand All @@ -236,11 +236,11 @@ public function start() {
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));
}
}
}
Expand Down Expand Up @@ -312,7 +312,7 @@ private function updateClient(
// 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();

Expand Down Expand Up @@ -349,12 +349,15 @@ private function startWorkingCopySocket() {

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;
Expand Down Expand Up @@ -438,9 +441,15 @@ private function log($client, $message) {
}

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";
Expand All @@ -461,7 +470,7 @@ private function daemonize() {

$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
Expand Down
3 changes: 2 additions & 1 deletion src/hgdaemon/ArcanistHgServerChannel.php
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/lint/ArcanistLintPatcher.php
Expand Up @@ -49,8 +49,10 @@ public function writePatchToDisk() {
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) {
Expand Down Expand Up @@ -114,7 +116,7 @@ private function getCharacterOffset($line_num) {
}

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);
Expand Down
12 changes: 6 additions & 6 deletions src/lint/ArcanistLintSeverity.php
Expand Up @@ -13,19 +13,19 @@ 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'),
);
}

public static function getStringForSeverity($severity_code) {
$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];
Expand Down
8 changes: 5 additions & 3 deletions src/lint/engine/ArcanistLintEngine.php
Expand Up @@ -168,7 +168,7 @@ final public function setMinimumSeverity($severity) {
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) {
Expand All @@ -189,7 +189,7 @@ final public function run() {
}

if (!$have_paths) {
throw new ArcanistNoEffectException('No paths are lintable.');
throw new ArcanistNoEffectException(pht('No paths are lintable.'));
}

$versions = array($this->getCacheVersion());
Expand Down Expand Up @@ -272,7 +272,9 @@ final public function run() {
}

if ($exceptions) {
throw new PhutilAggregateException('Some linters failed:', $exceptions);
throw new PhutilAggregateException(
pht('Some linters failed:'),
$exceptions);
}

return $this->results;
Expand Down
5 changes: 3 additions & 2 deletions src/lint/linter/ArcanistBaseXHPASTLinter.php
Expand Up @@ -132,8 +132,9 @@ final protected function releaseSharedFutures(array $paths) {
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]--;
Expand Down

0 comments on commit d2b38cd

Please sign in to comment.