From c450fa6c069e3f15204b3011775e4be66ddc6ff0 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 27 Jan 2015 06:58:18 +1100 Subject: [PATCH] `pht`ize a bunch of strings Summary: Self-explanatory. Test Plan: Eyeball it. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11501 --- .../ArcanistConfigurationDrivenLintEngine.php | 123 +++++++++++------- 1 file changed, 74 insertions(+), 49 deletions(-) diff --git a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php index 88eeb9d8..dbd60638 100644 --- a/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php +++ b/src/lint/engine/ArcanistConfigurationDrivenLintEngine.php @@ -7,9 +7,12 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { $config_path = $working_copy->getProjectPath('.arclint'); if (!Filesystem::pathExists($config_path)) { - throw new Exception( - "Unable to find '.arclint' file to configure linters. Create a ". - "'.arclint' file in the root directory of the working copy."); + throw new ArcanistUsageException( + pht( + "Unable to find '%s' file to configure linters. Create an ". + "'%s' file in the root directory of the working copy.", + '.arclint', + '.arclint')); } $data = Filesystem::readFile($config_path); @@ -19,8 +22,9 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { } catch (PhutilJSONParserException $ex) { throw new PhutilProxyException( pht( - "Expected '.arclint' file to be a valid JSON file, but failed to ". - "decode %s", + "Expected '%s' file to be a valid JSON file, but ". + "failed to decode '%s'.", + '.arclint', $config_path), $ex); } @@ -35,10 +39,9 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { 'linters' => 'map>', )); } catch (PhutilTypeCheckException $ex) { - $message = pht( - 'Error in parsing ".arclint" file: %s', - $ex->getMessage()); - throw new PhutilProxyException($message, $ex); + throw new PhutilProxyException( + pht("Error in parsing '%s' file."), + $ex); } $global_exclude = (array)idx($config, 'exclude', array()); @@ -49,10 +52,13 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { $type = idx($spec, 'type'); if ($type !== null) { if (empty($linters[$type])) { - $list = implode(', ', array_keys($linters)); - throw new Exception( - "Linter '{$name}' specifies invalid type '{$type}'. Available ". - "linters are: {$list}."); + throw new ArcanistUsageException( + pht( + "Linter '%s' specifies invalid type '%s'. ". + "Available linters are: %s.", + $name, + $type, + implode(', ', array_keys($linters)))); } $linter = clone $linters[$type]; @@ -83,11 +89,12 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { 'exclude' => 'optional regex | list', ) + $more); } catch (PhutilTypeCheckException $ex) { - $message = pht( - 'Error in parsing ".arclint" file, for linter "%s": %s', - $name, - $ex->getMessage()); - throw new PhutilProxyException($message, $ex); + throw new PhutilProxyException( + pht( + "Error in parsing '%s' file, for linter '%s'.", + '.arclint', + $name), + $ex); } foreach ($more as $key => $value) { @@ -95,13 +102,13 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { try { $linter->setLinterConfigurationValue($key, $spec[$key]); } catch (Exception $ex) { - $message = pht( - 'Error in parsing ".arclint" file, in key "%s" for '. - 'linter "%s": %s', - $key, - $name, - $ex->getMessage()); - throw new PhutilProxyException($message, $ex); + throw new PhutilProxyException( + pht( + "Error in parsing '%s' file, in key '%s' for linter '%s'.", + '.arclint', + $key, + $name), + $ex); } } } @@ -110,16 +117,17 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { $exclude = (array)idx($spec, 'exclude', array()); $console = PhutilConsole::getConsole(); - $console->writeLog("Examining paths for linter \"%s\".\n", $name); + $console->writeLog( + "%s\n", + pht("Examining paths for linter '%s'.", $name)); $paths = $this->matchPaths( $all_paths, $include, $exclude, $global_exclude); $console->writeLog( - "Found %d matching paths for linter \"%s\".\n", - count($paths), - $name); + "%s\n", + pht("Found %d matching paths for linter '%s'.", count($paths), $name)); if ($paths) { $linter->setPaths($paths); @@ -152,9 +160,12 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { $orig_class = get_class($map[$name]); $this_class = get_class($linter); throw new Exception( - "Two linters ({$orig_class}, {$this_class}) both have the same ". - "configuration name ({$name}). Linters must have unique configuration ". - "names."); + pht( + "Two linters (`%s`, `%s`) both have the same configuration ". + "name ('%s'). Linters must have unique configuration names.", + $orig_class, + $this_class, + $name)); } return $map; @@ -170,65 +181,79 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine { $match = array(); foreach ($paths as $path) { - $console->writeLog("Examining path '%s'...\n", $path); + $console->writeLog("%s\n", pht("Examining path '%s'...", $path)); $keep = false; if (!$include) { $keep = true; $console->writeLog( - " Including path by default because there is no 'include' rule.\n"); + " %s\n", + pht('Including path by default because there is no "include" rule.')); } else { - $console->writeLog(" Testing \"include\" rules.\n"); + $console->writeLog( + " %s\n", + pht('Testing "include" rules.')); foreach ($include as $rule) { if (preg_match($rule, $path)) { $keep = true; - $console->writeLog(" Path matches include rule: %s\n", $rule); + $console->writeLog( + " %s\n", + pht('Path matches include rule: %s.', $rule)); break; } else { $console->writeLog( - " Path does not match include rule: %s\n", - $rule); + " %s\n", + pht('Path does not match include rule: %s', $rule)); } } } if (!$keep) { $console->writeLog( - " Path does not match any include rules, discarding.\n"); + " %s\n", + pht('Path does not match any include rules, discarding.')); continue; } if ($exclude) { - $console->writeLog(" Testing \"exclude\" rules.\n"); + $console->writeLog( + " %s\n", + pht('Testing "exclude" rules.')); foreach ($exclude as $rule) { if (preg_match($rule, $path)) { - $console->writeLog(" Path matches \"exclude\" rule: %s\n", $rule); + $console->writeLog( + " %s\n", + pht('Path matches "exclude" rule: %s.', $rule)); continue 2; } else { $console->writeLog( - " Path does not match \"exclude\" rule: %s\n", - $rule); + " %s\n", + pht('Path does not match "exclude" rule: %s.', $rule)); } } } if ($global_exclude) { - $console->writeLog(" Testing global \"exclude\" rules.\n"); + $console->writeLog( + " %s\n", + pht('Testing global "exclude" rules.')); foreach ($global_exclude as $rule) { if (preg_match($rule, $path)) { $console->writeLog( - " Path matches global \"exclude\" rule: %s\n", - $rule); + " %s\n", + pht('Path matches global "exclude" rule: %s.', $rule)); continue 2; } else { $console->writeLog( - " Path does not match global \"exclude\" rule: %s\n", - $rule); + " %s\n", + pht('Path does not match global "exclude" rule: %s.', $rule)); } } } - $console->writeLog(" Path matches.\n"); + $console->writeLog( + " %s\n", + pht('Path matches.')); $match[] = $path; }