diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php index 8bbdf0fd..377b1b4c 100644 --- a/scripts/__init_script__.php +++ b/scripts/__init_script__.php @@ -46,8 +46,8 @@ if (getenv('ARC_PHUTIL_PATH')) { } if (!@constant('__LIBPHUTIL__')) { echo "ERROR: Unable to load libphutil. Put libphutil/ next to arcanist/, or ". - "update your PHP 'include_path' to include the parent directory of ". - "libphutil/, or symlink libphutil/ into arcanist/externals/includes/.\n"; + "update your PHP 'include_path' to include the parent directory of ". + "libphutil/, or symlink libphutil/ into arcanist/externals/includes/.\n"; exit(1); } diff --git a/src/difference/__tests__/ArcanistDiffUtilsTestCase.php b/src/difference/__tests__/ArcanistDiffUtilsTestCase.php index 81c326d2..26fa9e47 100644 --- a/src/difference/__tests__/ArcanistDiffUtilsTestCase.php +++ b/src/difference/__tests__/ArcanistDiffUtilsTestCase.php @@ -94,7 +94,7 @@ final class ArcanistDiffUtilsTestCase extends PhutilTestCase { ArcanistDiffUtils::generateEditString( str_split($test[0]), str_split($test[1])), - "'{$test[0]}' vs '{$test[1]}'"); + pht("'%s' vs '%s'", $test[0], $test[1])); } $utf8_tests = array( @@ -111,7 +111,7 @@ final class ArcanistDiffUtilsTestCase extends PhutilTestCase { ArcanistDiffUtils::generateEditString( phutil_utf8v_combined($test[0]), phutil_utf8v_combined($test[1])), - "'{$test[0]}' vs '{$test[1]}' (utf8)"); + pht("'%s' vs '%s' (utf8)", $test[0], $test[1])); } } diff --git a/src/internationalization/ArcanistUSEnglishTranslation.php b/src/internationalization/ArcanistUSEnglishTranslation.php index 4356d37c..b468aaaf 100644 --- a/src/internationalization/ArcanistUSEnglishTranslation.php +++ b/src/internationalization/ArcanistUSEnglishTranslation.php @@ -50,20 +50,9 @@ final class ArcanistUSEnglishTranslation extends PhutilTranslation { 'Do you want to create a new commit with these changes?', ), - '(To ignore these %s change(s), add them to ".git/info/exclude".)' => - array( - '(To ignore this change, add it to ".git/info/exclude".)', - '(To ignore these changes, add them to ".git/info/exclude".)', - ), - - '(To ignore these %s change(s), add them to "svn:ignore".)' => array( - '(To ignore this change, add it to "svn:ignore".)', - '(To ignore these changes, add them to "svn:ignore".)', - ), - - '(To ignore these %s change(s), add them to ".hgignore".)' => array( - '(To ignore this change, add it to ".hgignore".)', - '(To ignore these changes, add them to ".hgignore".)', + '(To ignore these %s change(s), add them to "%s".)' => array( + '(To ignore this change, add it to "%s".)', + '(To ignore these changes, add them to "%s".)', ), '%s line(s)' => array('line', 'lines'), diff --git a/src/lint/linter/ArcanistClosureLinter.php b/src/lint/linter/ArcanistClosureLinter.php index 78d4d428..5cdf6259 100644 --- a/src/lint/linter/ArcanistClosureLinter.php +++ b/src/lint/linter/ArcanistClosureLinter.php @@ -6,7 +6,7 @@ final class ArcanistClosureLinter extends ArcanistExternalLinter { public function getInfoName() { - return 'Closure Linter'; + return pht('Closure Linter'); } public function getInfoURI() { diff --git a/src/lint/linter/ArcanistJSONLintLinter.php b/src/lint/linter/ArcanistJSONLintLinter.php index d6b13103..7fd00254 100644 --- a/src/lint/linter/ArcanistJSONLintLinter.php +++ b/src/lint/linter/ArcanistJSONLintLinter.php @@ -6,7 +6,7 @@ final class ArcanistJSONLintLinter extends ArcanistExternalLinter { public function getInfoName() { - return 'JSON Lint'; + return pht('JSON Lint'); } public function getInfoURI() { diff --git a/src/lint/linter/ArcanistJSONLinter.php b/src/lint/linter/ArcanistJSONLinter.php index f6727032..773b21ad 100644 --- a/src/lint/linter/ArcanistJSONLinter.php +++ b/src/lint/linter/ArcanistJSONLinter.php @@ -8,7 +8,7 @@ final class ArcanistJSONLinter extends ArcanistLinter { const LINT_PARSE_ERROR = 1; public function getInfoName() { - return 'JSON Lint'; + return pht('JSON Lint'); } public function getInfoDescription() { diff --git a/src/lint/linter/ArcanistPhutilLibraryLinter.php b/src/lint/linter/ArcanistPhutilLibraryLinter.php index baee3ba3..917c7938 100644 --- a/src/lint/linter/ArcanistPhutilLibraryLinter.php +++ b/src/lint/linter/ArcanistPhutilLibraryLinter.php @@ -15,7 +15,7 @@ final class ArcanistPhutilLibraryLinter extends ArcanistLinter { const LINT_ONE_CLASS_PER_FILE = 3; public function getInfoName() { - return 'Phutil Library Linter'; + return pht('Phutil Library Linter'); } public function getInfoDescription() { diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 29939e9e..4bce3bde 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -81,7 +81,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { private $windowsVersion; public function getInfoName() { - return 'XHPAST Lint'; + return pht('XHPAST Lint'); } public function getInfoDescription() { @@ -1893,9 +1893,10 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { $message = $this->raiseLintAtNode( $var, self::LINT_REUSED_AS_ITERATOR, - 'This iterator variable is a previously declared local '. - 'variable. To avoid overwriting locals, do not reuse them '. - 'as iterator variables.'); + pht( + 'This iterator variable is a previously declared local '. + 'variable. To avoid overwriting locals, do not reuse them '. + 'as iterator variables.')); $message->setOtherLocations(array( $this->getOtherLocation($declarations[$concrete]), $this->getOtherLocation(max($uses[$concrete])), diff --git a/src/lint/linter/__tests__/ArcanistLinterTestCase.php b/src/lint/linter/__tests__/ArcanistLinterTestCase.php index 66c71f16..564f57bc 100644 --- a/src/lint/linter/__tests__/ArcanistLinterTestCase.php +++ b/src/lint/linter/__tests__/ArcanistLinterTestCase.php @@ -107,7 +107,7 @@ abstract class ArcanistLinterTestCase extends PhutilTestCase { $working_copy = ArcanistWorkingCopyIdentity::newFromRootAndConfigFile( $dir, null, - 'Unit Test'); + pht('Unit Test')); $configuration_manager = new ArcanistConfigurationManager(); $configuration_manager->setWorkingCopyIdentity($working_copy); diff --git a/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLintNamingHookTestCase.php b/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLintNamingHookTestCase.php index baec7dbc..16bc8051 100644 --- a/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLintNamingHookTestCase.php +++ b/src/lint/linter/xhpast/__tests__/ArcanistXHPASTLintNamingHookTestCase.php @@ -29,19 +29,19 @@ final class ArcanistXHPASTLintNamingHookTestCase $this->assertEqual( $expect[0], ArcanistXHPASTLintNamingHook::isUpperCamelCase($test), - "UpperCamelCase: '{$test}'"); + pht("UpperCamelCase: '%s'", $test)); $this->assertEqual( $expect[1], ArcanistXHPASTLintNamingHook::isLowerCamelCase($test), - "lowerCamelCase: '{$test}'"); + pht("lowerCamelCase: '%s'", $test)); $this->assertEqual( $expect[2], ArcanistXHPASTLintNamingHook::isUppercaseWithUnderscores($test), - "UPPERCASE_WITH_UNDERSCORES: '{$test}'"); + pht("UPPERCASE_WITH_UNDERSCORES: '%s'", $test)); $this->assertEqual( $expect[3], ArcanistXHPASTLintNamingHook::isLowercaseWithUnderscores($test), - "lowercase_with_underscores: '{$test}'"); + pht("lowercase_with_underscores: '%s'", $test)); } } diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php index 0e9627b7..7966461f 100644 --- a/src/parser/ArcanistDiffParser.php +++ b/src/parser/ArcanistDiffParser.php @@ -1104,7 +1104,7 @@ final class ArcanistDiffParser { protected function getLine() { if ($this->text === null) { - throw new Exception('Not parsing!'); + throw new Exception(pht('Not parsing!')); } if (isset($this->text[$this->line])) { return $this->text[$this->line]; @@ -1205,14 +1205,14 @@ final class ArcanistDiffParser { } $out = array(); - $out[] = "Diff Parse Exception: {$message}"; + $out[] = pht('Diff Parse Exception: %s', $message); if ($this->writeDiffOnFailure) { $temp = new TempFile(); $temp->setPreserveFile(true); Filesystem::writeFile($temp, $this->rawDiff); - $out[] = 'Raw input file was written to: '.(string)$temp; + $out[] = pht('Raw input file was written to: %s', $temp); } $out[] = $context; diff --git a/src/parser/__tests__/ArcanistBaseCommitParserTestCase.php b/src/parser/__tests__/ArcanistBaseCommitParserTestCase.php index 5580676b..5d6b11d2 100644 --- a/src/parser/__tests__/ArcanistBaseCommitParserTestCase.php +++ b/src/parser/__tests__/ArcanistBaseCommitParserTestCase.php @@ -5,7 +5,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { public function testBasics() { // Verify that the very basics of base commit resolution work. $this->assertCommit( - 'Empty Rules', + pht('Empty Rules'), null, array( )); @@ -23,7 +23,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { // test cases intentionally scramble argument order to test that resolution // order is independent of argument order. $this->assertCommit( - 'Order: Args', + pht('Order: Args'), 'y', array( 'local' => 'literal:n', @@ -33,7 +33,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { )); $this->assertCommit( - 'Order: Local', + pht('Order: Local'), 'y', array( 'project' => 'literal:n', @@ -42,7 +42,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { )); $this->assertCommit( - 'Order: Project', + pht('Order: Project'), 'y', array( 'project' => 'literal:y', @@ -50,7 +50,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { )); $this->assertCommit( - 'Order: Global', + pht('Order: Global'), 'y', array( 'user' => 'literal:y', @@ -60,7 +60,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { public function testLegacyRule() { // 'global' should translate to 'user' $this->assertCommit( - '"global" name', + pht('"%s" name', 'global'), 'y', array( 'runtime' => 'arc:global, arc:halt', @@ -71,7 +71,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { // 'args' should translate to 'runtime' $this->assertCommit( - '"args" name', + pht('"%s" name', 'args'), 'y', array( 'runtime' => 'arc:project, literal:y', @@ -84,7 +84,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { public function testHalt() { // 'arc:halt' should halt all processing. $this->assertCommit( - 'Halt', + pht('Halt'), null, array( 'runtime' => 'arc:halt', @@ -95,7 +95,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { public function testYield() { // 'arc:yield' should yield to other rulesets. $this->assertCommit( - 'Yield', + pht('Yield'), 'xyz', array( 'runtime' => 'arc:yield, literal:abc', @@ -104,7 +104,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { // This one should return to 'runtime' after exhausting 'local'. $this->assertCommit( - 'Yield + Return', + pht('Yield + Return'), 'abc', array( 'runtime' => 'arc:yield, literal:abc', @@ -115,7 +115,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { public function testJump() { // This should resolve to 'abc' without hitting any of the halts. $this->assertCommit( - 'Jump', + pht('Jump'), 'abc', array( 'runtime' => 'arc:project, arc:halt', @@ -128,7 +128,7 @@ final class ArcanistBaseCommitParserTestCase extends PhutilTestCase { public function testJumpReturn() { // After jumping to project, we should return to 'runtime'. $this->assertCommit( - 'Jump Return', + pht('Jump Return'), 'xyz', array( 'runtime' => 'arc:project, literal:xyz', diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index 7b0bd64b..b9c6185f 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -314,7 +314,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { // TODO: Remove the history lesson soon. echo phutil_console_format( - "** Select a Default Commit Range **\n\n"); + "** %s **\n\n", + pht('Select a Default Commit Range')); echo phutil_console_wrap( pht( "You're running a command which operates on a range of revisions ". @@ -973,7 +974,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { $branch); if ($err) { - throw new ArcanistUsageException('Merge failed!'); + throw new ArcanistUsageException(pht('Merge failed!')); } } diff --git a/src/unit/engine/PhutilUnitTestEngine.php b/src/unit/engine/PhutilUnitTestEngine.php index 3879396c..1abf1e74 100644 --- a/src/unit/engine/PhutilUnitTestEngine.php +++ b/src/unit/engine/PhutilUnitTestEngine.php @@ -17,7 +17,7 @@ final class PhutilUnitTestEngine extends ArcanistUnitTestEngine { } if (!$run_tests) { - throw new ArcanistNoEffectException('No tests to run.'); + throw new ArcanistNoEffectException(pht('No tests to run.')); } $enable_coverage = $this->getEnableCoverage(); diff --git a/src/unit/parser/ArcanistPhpunitTestResultParser.php b/src/unit/parser/ArcanistPhpunitTestResultParser.php index 314c8265..8eaeb1ab 100644 --- a/src/unit/parser/ArcanistPhpunitTestResultParser.php +++ b/src/unit/parser/ArcanistPhpunitTestResultParser.php @@ -53,17 +53,17 @@ final class ArcanistPhpunitTestResultParser extends ArcanistTestResultParser { $user_data .= idx($event, 'message')."\n"; foreach (idx($event, 'trace') as $trace) { $user_data .= sprintf( - "\n%s:%s", - idx($trace, 'file'), - idx($trace, 'line')); + "\n%s:%s", + idx($trace, 'file'), + idx($trace, 'line')); } } else if ('error' == idx($event, 'status')) { if (strpos(idx($event, 'message'), 'Skipped Test') !== false) { $status = ArcanistUnitTestResult::RESULT_SKIP; $user_data .= idx($event, 'message'); } else if (strpos( - idx($event, 'message'), - 'Incomplete Test') !== false) { + idx($event, 'message'), + 'Incomplete Test') !== false) { $status = ArcanistUnitTestResult::RESULT_SKIP; $user_data .= idx($event, 'message'); } else { @@ -71,9 +71,9 @@ final class ArcanistPhpunitTestResultParser extends ArcanistTestResultParser { $user_data .= idx($event, 'message'); foreach (idx($event, 'trace') as $trace) { $user_data .= sprintf( - "\n%s:%s", - idx($trace, 'file'), - idx($trace, 'line')); + "\n%s:%s", + idx($trace, 'file'), + idx($trace, 'line')); } } } diff --git a/src/unit/renderer/ArcanistUnitConsoleRenderer.php b/src/unit/renderer/ArcanistUnitConsoleRenderer.php index c2e95c01..16441f3c 100644 --- a/src/unit/renderer/ArcanistUnitConsoleRenderer.php +++ b/src/unit/renderer/ArcanistUnitConsoleRenderer.php @@ -92,19 +92,19 @@ final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer { private function formatTime($seconds) { if ($seconds >= 60) { $minutes = floor($seconds / 60); - return sprintf('%dm%02ds', $minutes, round($seconds % 60)); + return pht('%dm%02ds', $minutes, round($seconds % 60)); } if ($seconds >= 1) { - return sprintf('%4.1fs', $seconds); + return pht('%4.1fs', $seconds); } $milliseconds = $seconds * 1000; if ($milliseconds >= 1) { - return sprintf('%3dms', round($milliseconds)); + return pht('%3dms', round($milliseconds)); } - return ' <1ms'; + return pht(' <%dms', 1); } } diff --git a/src/workflow/ArcanistBackoutWorkflow.php b/src/workflow/ArcanistBackoutWorkflow.php index cdd26119..49ff007e 100644 --- a/src/workflow/ArcanistBackoutWorkflow.php +++ b/src/workflow/ArcanistBackoutWorkflow.php @@ -170,7 +170,7 @@ EOTEXT } if (!$repository_api->hasLocalCommit($commit_hash)) { throw new ArcanistUsageException( - 'Invalid commit provided or does not exist in the working copy!'); + pht('Invalid commit provided or does not exist in the working copy!')); } // Run 'backout'. diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php index 72dae0ff..e1c5a917 100644 --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -252,7 +252,7 @@ EOTEXT $prefix = pht( 'Revision includes changes to %s path(s) that do not exist:', new PhutilNumber(count($do_not_exist))); - $prompt = 'Commit this revision anyway?'; + $prompt = pht('Commit this revision anyway?'); $this->promptFileWarning($prefix, $prompt, $do_not_exist); } diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 7f844de1..db1ad23d 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -83,16 +83,17 @@ EOTEXT 'message' => array( 'short' => 'm', 'param' => 'message', - 'help' => + 'help' => pht( 'When updating a revision, use the specified message instead of '. - 'prompting.', + 'prompting.'), ), 'message-file' => array( 'short' => 'F', 'param' => 'file', 'paramtype' => 'file', - 'help' => 'When creating a revision, read revision information '. - 'from this file.', + 'help' => pht( + 'When creating a revision, read revision information '. + 'from this file.'), ), 'use-commit-message' => array( 'supports' => array( @@ -101,7 +102,7 @@ EOTEXT ), 'short' => 'C', 'param' => 'commit', - 'help' => 'Read revision information from a specific commit.', + 'help' => pht('Read revision information from a specific commit.'), 'conflicts' => array( 'only' => null, 'preview' => null, @@ -114,151 +115,169 @@ EOTEXT 'hg', ), 'nosupport' => array( - 'svn' => 'Edit revisions via the web interface when using SVN.', + 'svn' => pht('Edit revisions via the web interface when using SVN.'), ), - 'help' => + 'help' => pht( 'When updating a revision under git, edit revision information '. - 'before updating.', + 'before updating.'), ), 'raw' => array( - 'help' => + 'help' => pht( 'Read diff from stdin, not from the working copy. This disables '. 'many Arcanist/Phabricator features which depend on having access '. - 'to the working copy.', + 'to the working copy.'), 'conflicts' => array( 'less-context' => null, - 'apply-patches' => '--raw disables lint.', - 'never-apply-patches' => '--raw disables lint.', - 'advice' => '--raw disables lint.', - 'lintall' => '--raw disables lint.', + 'apply-patches' => pht('%s disables lint.', '--raw'), + 'never-apply-patches' => pht('%s disables lint.', '--raw'), + 'advice' => pht('%s disables lint.', '--raw'), + 'lintall' => pht('%s disables lint.', '--raw'), - 'create' => '--raw and --create both need stdin. '. - 'Use --raw-command.', - 'edit' => '--raw and --edit both need stdin. '. - 'Use --raw-command.', + 'create' => pht( + '%s and %s both need stdin. Use %s.', + '--raw', + '--create', + '--raw-command'), + 'edit' => pht( + '%s and %s both need stdin. Use %s.', + '--raw', + '--edit', + '--raw-command'), 'raw-command' => null, ), ), 'raw-command' => array( 'param' => 'command', - 'help' => + 'help' => pht( 'Generate diff by executing a specified command, not from the '. 'working copy. This disables many Arcanist/Phabricator features '. - 'which depend on having access to the working copy.', + 'which depend on having access to the working copy.'), 'conflicts' => array( 'less-context' => null, - 'apply-patches' => '--raw-command disables lint.', - 'never-apply-patches' => '--raw-command disables lint.', - 'advice' => '--raw-command disables lint.', - 'lintall' => '--raw-command disables lint.', + 'apply-patches' => pht('%s disables lint.', '--raw-command'), + 'never-apply-patches' => pht('%s disables lint.', '--raw-command'), + 'advice' => pht('%s disables lint.', '--raw-command'), + 'lintall' => pht('%s disables lint.', '--raw-command'), ), ), 'create' => array( - 'help' => 'Always create a new revision.', + 'help' => pht('Always create a new revision.'), 'conflicts' => array( - 'edit' => '--create can not be used with --edit.', - 'only' => '--create can not be used with --only.', - 'preview' => '--create can not be used with --preview.', - 'update' => '--create can not be used with --update.', + 'edit' => pht( + '%s can not be used with %s.', + '--create', + '--edit'), + 'only' => pht( + '%s can not be used with %s.', + '--create', + '--only'), + 'preview' => pht( + '%s can not be used with %s.', + '--create', + '--preview'), + 'update' => pht( + '%s can not be used with %s.', + '--create', + '--update'), ), ), 'update' => array( 'param' => 'revision_id', - 'help' => 'Always update a specific revision.', + 'help' => pht('Always update a specific revision.'), ), 'nounit' => array( - 'help' => - 'Do not run unit tests.', + 'help' => pht('Do not run unit tests.'), ), 'nolint' => array( - 'help' => - 'Do not run lint.', + 'help' => pht('Do not run lint.'), 'conflicts' => array( - 'lintall' => '--nolint suppresses lint.', - 'advice' => '--nolint suppresses lint.', - 'apply-patches' => '--nolint suppresses lint.', - 'never-apply-patches' => '--nolint suppresses lint.', + 'lintall' => pht('%s suppresses lint.', '--nolint'), + 'advice' => pht('%s suppresses lint.', '--nolint'), + 'apply-patches' => pht('%s suppresses lint.', '--nolint'), + 'never-apply-patches' => pht('%s suppresses lint.', '--nolint'), ), ), 'only' => array( - 'help' => + 'help' => pht( 'Only generate a diff, without running lint, unit tests, or other '. - 'auxiliary steps. See also --preview.', + 'auxiliary steps. See also %s.', + '--preview'), 'conflicts' => array( 'preview' => null, - 'message' => '--only does not affect revisions.', - 'edit' => '--only does not affect revisions.', - 'lintall' => '--only suppresses lint.', - 'advice' => '--only suppresses lint.', - 'apply-patches' => '--only suppresses lint.', - 'never-apply-patches' => '--only suppresses lint.', + 'message' => pht('%s does not affect revisions.', '--only'), + 'edit' => pht('%s does not affect revisions.', '--only'), + 'lintall' => pht('%s suppresses lint.', '--only'), + 'advice' => pht('%s suppresses lint.', '--only'), + 'apply-patches' => pht('%s suppresses lint.', '--only'), + 'never-apply-patches' => pht('%s suppresses lint.', '--only'), ), ), 'preview' => array( - 'help' => + 'help' => pht( 'Instead of creating or updating a revision, only create a diff, '. 'which you may later attach to a revision. This still runs lint '. - 'unit tests. See also --only.', + 'unit tests. See also %s.', + '--only'), 'conflicts' => array( 'only' => null, - 'edit' => '--preview does affect revisions.', - 'message' => '--preview does not update any revision.', + 'edit' => pht('%s does affect revisions.', '--preview'), + 'message' => pht('%s does not update any revision.', '--preview'), ), ), 'plan-changes' => array( - 'help' => - 'Create or update a revision without requesting a code review.', + 'help' => pht( + 'Create or update a revision without requesting a code review.'), 'conflicts' => array( - 'only' => '--only does not affect revisions.', - 'preview' => '--preview does not affect revisions.', + 'only' => pht('%s does not affect revisions.', '--only'), + 'preview' => pht('%s does not affect revisions.', '--preview'), ), ), 'encoding' => array( 'param' => 'encoding', - 'help' => - 'Attempt to convert non UTF-8 hunks into specified encoding.', + 'help' => pht( + 'Attempt to convert non UTF-8 hunks into specified encoding.'), ), 'allow-untracked' => array( - 'help' => - 'Skip checks for untracked files in the working copy.', + 'help' => pht('Skip checks for untracked files in the working copy.'), ), 'excuse' => array( 'param' => 'excuse', - 'help' => 'Provide a prepared in advance excuse for any lints/tests'. - ' shall they fail.', + 'help' => pht( + 'Provide a prepared in advance excuse for any lints/tests '. + 'shall they fail.'), ), 'less-context' => array( - 'help' => + 'help' => pht( "Normally, files are diffed with full context: the entire file is ". "sent to Differential so reviewers can 'show more' and see it. If ". "you are making changes to very large files with tens of thousands ". "of lines, this may not work well. With this flag, a diff will ". - "be created that has only a few lines of context.", + "be created that has only a few lines of context."), ), 'lintall' => array( - 'help' => - 'Raise all lint warnings, not just those on lines you changed.', + 'help' => pht( + 'Raise all lint warnings, not just those on lines you changed.'), 'passthru' => array( 'lint' => true, ), ), 'advice' => array( - 'help' => + 'help' => pht( 'Require excuse for lint advice in addition to lint warnings and '. - 'errors.', + 'errors.'), ), 'only-new' => array( 'param' => 'bool', - 'help' => - 'Display only lint messages not present in the original code.', + 'help' => pht( + 'Display only lint messages not present in the original code.'), 'passthru' => array( 'lint' => true, ), ), 'apply-patches' => array( - 'help' => + 'help' => pht( 'Apply patches suggested by lint to the working copy without '. - 'prompting.', + 'prompting.'), 'conflicts' => array( 'never-apply-patches' => true, ), @@ -267,7 +286,7 @@ EOTEXT ), ), 'never-apply-patches' => array( - 'help' => 'Never apply patches suggested by lint.', + 'help' => pht('Never apply patches suggested by lint.'), 'conflicts' => array( 'apply-patches' => true, ), @@ -276,44 +295,46 @@ EOTEXT ), ), 'amend-all' => array( - 'help' => + 'help' => pht( 'When linting git repositories, amend HEAD with all patches '. - 'suggested by lint without prompting.', + 'suggested by lint without prompting.'), 'passthru' => array( 'lint' => true, ), ), '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.'), 'passthru' => array( 'lint' => true, ), ), 'add-all' => array( 'short' => 'a', - 'help' => - 'Automatically add all unstaged and uncommitted files to the commit.', + 'help' => pht( + 'Automatically add all unstaged and uncommitted '. + 'files to the commit.'), ), 'json' => array( - 'help' => - 'Emit machine-readable JSON. EXPERIMENTAL! Probably does not work!', + 'help' => pht( + 'Emit machine-readable JSON. EXPERIMENTAL! Probably does not work!'), ), 'no-amend' => array( - 'help' => 'Never amend commits in the working copy with lint patches.', + 'help' => pht( + 'Never amend commits in the working copy with lint patches.'), ), 'uncommitted' => array( - 'help' => 'Suppress warning about uncommitted changes.', + 'help' => pht('Suppress warning about uncommitted changes.'), 'supports' => array( 'hg', ), ), 'verbatim' => array( - 'help' => 'When creating a revision, try to use the working copy '. - 'commit message verbatim, without prompting to edit it. '. - 'When updating a revision, update some fields from the '. - 'local commit message.', + 'help' => pht( + 'When creating a revision, try to use the working copy commit '. + 'message verbatim, without prompting to edit it. When updating a '. + 'revision, update some fields from the local commit message.'), 'supports' => array( 'hg', 'git', @@ -330,7 +351,7 @@ EOTEXT ), 'reviewers' => array( 'param' => 'usernames', - 'help' => 'When creating a revision, add reviewers.', + 'help' => pht('When creating a revision, add reviewers.'), 'conflicts' => array( 'only' => true, 'preview' => true, @@ -339,7 +360,7 @@ EOTEXT ), 'cc' => array( 'param' => 'usernames', - 'help' => 'When creating a revision, add CCs.', + 'help' => pht('When creating a revision, add CCs.'), 'conflicts' => array( 'only' => true, 'preview' => true, @@ -347,31 +368,35 @@ EOTEXT ), ), 'skip-binaries' => array( - 'help' => 'Do not upload binaries (like images).', + 'help' => pht('Do not upload binaries (like images).'), ), 'ignore-unsound-tests' => array( - 'help' => 'Ignore unsound test failures without prompting.', + 'help' => pht('Ignore unsound test failures without prompting.'), ), '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'), ), 'no-diff' => array( - 'help' => 'Only run lint and unit tests. Intended for internal use.', + 'help' => pht( + 'Only run lint and unit tests. Intended for internal use.'), ), 'cache' => array( 'param' => 'bool', - 'help' => '0 to disable lint cache, 1 to enable (default).', + 'help' => pht( + '%d to disable lint cache, %d to enable (default).', + 0, + 1), 'passthru' => array( 'lint' => true, ), ), 'coverage' => array( - 'help' => 'Always enable coverage information.', + 'help' => pht('Always enable coverage information.'), 'conflicts' => array( 'no-coverage' => null, ), @@ -380,7 +405,7 @@ EOTEXT ), ), 'no-coverage' => array( - 'help' => 'Always disable coverage information.', + 'help' => pht('Always disable coverage information.'), 'passthru' => array( 'unit' => true, ), @@ -399,11 +424,11 @@ EOTEXT 'supports' => array('git'), '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'), ), 'conflicts' => array( - 'lintall' => '--head suppresses lint.', - 'advice' => '--head suppresses lint.', + 'lintall' => pht('%s suppresses lint.', '--head'), + 'advice' => pht('%s suppresses lint.', '--head'), ), ), ); @@ -453,20 +478,22 @@ EOTEXT if ($this->getArgument('nolint')) { $this->excuses['lint'] = $this->getSkipExcuse( - 'Provide explanation for skipping lint or press Enter to abort:', + pht('Provide explanation for skipping lint or press Enter to abort:'), 'lint-excuses'); } if ($this->getArgument('nounit')) { $this->excuses['unit'] = $this->getSkipExcuse( - 'Provide explanation for skipping unit tests or press Enter to abort:', + pht( + 'Provide explanation for skipping unit tests '. + 'or press Enter to abort:'), 'unit-excuses'); } $changes = $this->generateChanges(); if (!$changes) { throw new ArcanistUsageException( - 'There are no changes to generate a diff from!'); + pht('There are no changes to generate a diff from!')); } $diff_spec = array( @@ -500,8 +527,9 @@ EOTEXT if ($this->shouldOnlyCreateDiff()) { if (!$output_json) { echo phutil_console_format( - "Created a new Differential diff:\n". - " **Diff URI:** __%s__\n\n", + "%s\n **%s** __%s__\n\n", + pht('Created a new Differential diff:'), + pht('Diff URI:'), $diff_info['uri']); } else { $human = ob_get_clean(); @@ -530,7 +558,7 @@ EOTEXT $this->writeScratchJSONFile($file, $messages); } - echo "Updated an existing Differential revision:\n"; + echo pht('Updated an existing Differential revision:')."\n"; } else { $revision = $this->dispatchWillCreateRevisionEvent($revision); @@ -547,20 +575,22 @@ EOTEXT if ($this->shouldAmend()) { $repository_api = $this->getRepositoryAPI(); if ($repository_api->supportsAmend()) { - echo "Updating commit message...\n"; + echo pht('Updating commit message...')."\n"; $repository_api->amendCommit($revised_message); } else { - echo 'Commit message was not amended. Amending commit message is '. - 'only supported in git and hg (version 2.2 or newer)'; + echo pht( + 'Commit message was not amended. Amending commit message is '. + 'only supported in git and hg (version 2.2 or newer)'); } } - echo "Created a new Differential revision:\n"; + echo pht('Created a new Differential revision:')."\n"; } $uri = $result['uri']; echo phutil_console_format( - " **Revision URI:** __%s__\n\n", + " **%s** __%s__\n\n", + pht('Revision URI:'), $uri); if ($this->getArgument('plan-changes')) { @@ -570,7 +600,7 @@ EOTEXT 'revision_id' => $result['revisionid'], 'action' => 'rethink', )); - echo "Planned changes to the revision.\n"; + echo pht('Planned changes to the revision.')."\n"; } if ($this->shouldOpenCreatedObjectsInBrowser()) { @@ -578,7 +608,7 @@ EOTEXT } } - echo "Included changes:\n"; + echo pht('Included changes:')."\n"; foreach ($changes as $change) { echo ' '.$change->renderTextSummary()."\n"; } @@ -735,7 +765,6 @@ EOTEXT } protected function shouldOnlyCreateDiff() { - if ($this->getArgument('create')) { return false; } @@ -786,14 +815,17 @@ EOTEXT if ($warn_externals && !$this->hasWarnedExternals) { echo phutil_console_format( - "The working copy includes changes to 'svn:externals' paths. These ". - "changes will not be included in the diff because SVN can not ". - "commit 'svn:externals' changes alongside normal changes.". - "\n\n". - "Modified 'svn:externals' files:". - "\n\n". + "%s\n\n%s\n\n", + pht( + "The working copy includes changes to '%s' paths. These ". + "changes will not be included in the diff because SVN can not ". + "commit 'svn:externals' changes alongside normal changes.", + 'svn:externals'), + pht( + "Modified '%s' files:", + 'svn:externals'), phutil_console_wrap(implode("\n", $warn_externals), 8)); - $prompt = 'Generate a diff (with just local changes) anyway?'; + $prompt = pht('Generate a diff (with just local changes) anyway?'); if (!phutil_console_confirm($prompt)) { throw new ArcanistUserAbortException(); } else { @@ -822,12 +854,12 @@ EOTEXT if ($is_raw) { if ($this->getArgument('raw')) { - fwrite(STDERR, "Reading diff from stdin...\n"); + fwrite(STDERR, pht('Reading diff from stdin...')."\n"); $raw_diff = file_get_contents('php://stdin'); } else if ($this->getArgument('raw-command')) { list($raw_diff) = execx('%C', $this->getArgument('raw-command')); } else { - throw new Exception('Unknown raw diff source.'); + throw new Exception(pht('Unknown raw diff source.')); } $changes = $parser->parseDiff($raw_diff); @@ -864,17 +896,18 @@ EOTEXT $revlist = array(); foreach ($bases as $path => $baserev) { - $revlist[] = " Revision {$baserev}, {$path}"; + $revlist[] = ' '.pht('Revision %s, %s', $baserev, $path); } $revlist = implode("\n", $revlist); foreach ($bases as $path => $baserev) { if ($baserev !== $rev) { throw new ArcanistUsageException( - "Base revisions of changed paths are mismatched. Update all ". - "paths to the same base revision before creating a diff: ". - "\n\n". - $revlist); + pht( + "Base revisions of changed paths are mismatched. Update all ". + "paths to the same base revision before creating a diff: ". + "\n\n%s", + $revlist)); } } @@ -898,18 +931,18 @@ EOTEXT $repository_api->getHeadCommit()); if (!strlen($diff)) { throw new ArcanistUsageException( - 'No changes found. (Did you specify the wrong commit range?)'); + pht('No changes found. (Did you specify the wrong commit range?)')); } $changes = $parser->parseDiff($diff); } else if ($repository_api instanceof ArcanistMercurialAPI) { $diff = $repository_api->getFullMercurialDiff(); if (!strlen($diff)) { throw new ArcanistUsageException( - 'No changes found. (Did you specify the wrong commit range?)'); + pht('No changes found. (Did you specify the wrong commit range?)')); } $changes = $parser->parseDiff($diff); } else { - throw new Exception('Repository API is not supported.'); + throw new Exception(pht('Repository API is not supported.')); } if (count($changes) > 250) { @@ -917,15 +950,16 @@ EOTEXT $link = 'http://www.phabricator.com/docs/phabricator/article/'. 'Differential_User_Guide_Large_Changes.html'; - $message = - "This diff has a very large number of changes ({$count}). ". - "Differential works best for changes which will receive detailed ". - "human review, and not as well for large automated changes or ". - "bulk checkins. See {$link} for information about reviewing big ". - "checkins. Continue anyway?"; + $message = pht( + 'This diff has a very large number of changes (%d). Differential '. + 'works best for changes which will receive detailed human review, '. + 'and not as well for large automated changes or bulk checkins. '. + 'See %s for information about reviewing big checkins. Continue anyway?', + $count, + $link); if (!phutil_console_confirm($message)) { throw new ArcanistUsageException( - 'Aborted generation of gigantic diff.'); + pht('Aborted generation of gigantic diff.')); } } @@ -938,30 +972,32 @@ EOTEXT if ($size > $limit) { $file_name = $change->getCurrentPath(); $change_size = number_format($size); - $byte_warning = - "Diff for '{$file_name}' with context is {$change_size} bytes in ". - "length. Generally, source changes should not be this large."; + $byte_warning = pht( + "Diff for '%s' with context is %d bytes in length. ". + "Generally, source changes should not be this large.", + $file_name, + $change_size); if (!$this->getArgument('less-context')) { - $byte_warning .= - " If this file is a huge text file, try using the ". - "'--less-context' flag."; + $byte_warning .= ' '.pht( + "If this file is a huge text file, try using the '%s' flag.", + '--less-context'); } if ($repository_api instanceof ArcanistSubversionAPI) { throw new ArcanistUsageException( - "{$byte_warning} If the file is not a text file, mark it as ". - "binary with:". - "\n\n". - " $ svn propset svn:mime-type application/octet-stream ". - "\n"); + $byte_warning.' '. + pht( + "If the file is not a text file, mark it as binary with:". + "\n\n $ %s\n", + 'svn propset svn:mime-type application/octet-stream ')); } else { - $confirm = - "{$byte_warning} If the file is not a text file, you can ". - "mark it 'binary'. Mark this file as 'binary' and continue?"; + $confirm = $byte_warning.' '.pht( + "If the file is not a text file, you can mark it 'binary'. ". + "Mark this file as 'binary' and continue?"); if (phutil_console_confirm($confirm)) { $change->convertToBinaryChange($repository_api); } else { throw new ArcanistUsageException( - 'Aborted generation of gigantic diff.'); + pht('Aborted generation of gigantic diff.')); } } } @@ -987,7 +1023,8 @@ EOTEXT } catch (ConduitClientException $e) { if ($e->getErrorCode() == 'ERR-BAD-ARCANIST-PROJECT') { echo phutil_console_wrap( - "Lookup of encoding in arcanist project failed\n". + "%s\n", + pht('Lookup of encoding in arcanist project failed'), $e->getMessage()); } else { throw $e; @@ -1000,8 +1037,10 @@ EOTEXT $name = $change->getCurrentPath(); if (phutil_is_utf8($corpus)) { $this->writeStatusMessage( - "Converted a '{$name}' hunk from '{$try_encoding}' ". - "to UTF-8.\n"); + pht( + "Converted a '%s' hunk from '%s' to UTF-8.\n", + $name, + $try_encoding)); $hunk->setCorpus($corpus); continue; } @@ -1018,23 +1057,29 @@ EOTEXT // has this behavior. if ($utf8_problems) { $utf8_warning = - pht( - 'This diff includes %s file(s) which are not valid UTF-8 (they '. - 'contain invalid byte sequences). You can either stop this workflow '. - 'and fix these files, or continue. If you continue, these files '. - 'will be marked as binary.', - new PhutilNumber(count($utf8_problems))). - "\n\n". - "You can learn more about how Phabricator handles character encodings ". - "(and how to configure encoding settings and detect and correct ". - "encoding problems) by reading 'User Guide: UTF-8 and Character ". - "Encoding' in the Phabricator documentation.\n\n". - " ".pht('%d AFFECTED FILE(S)', count($utf8_problems))."\n"; + sprintf( + "%s\n\n%s\n\n %s\n", + pht( + 'This diff includes %s file(s) which are not valid UTF-8 (they '. + 'contain invalid byte sequences). You can either stop this '. + 'workflow and fix these files, or continue. If you continue, '. + 'these files will be marked as binary.', + new PhutilNumber(count($utf8_problems))), + pht( + "You can learn more about how Phabricator handles character ". + "encodings (and how to configure encoding settings and detect and ". + "correct encoding problems) by reading 'User Guide: UTF-8 and ". + "Character Encoding' in the Phabricator documentation."), + pht( + '%d AFFECTED FILE(S)', + count($utf8_problems))); $confirm = pht( 'Do you want to mark these %s file(s) as binary and continue?', new PhutilNumber(count($utf8_problems))); - echo phutil_console_format("**Invalid Content Encoding (Non-UTF8)**\n"); + echo phutil_console_format( + "**%s**\n", + pht('Invalid Content Encoding (Non-UTF8)')); echo phutil_console_wrap($utf8_warning); $file_list = mpull($utf8_problems, 'getCurrentPath'); @@ -1042,7 +1087,7 @@ EOTEXT echo $file_list; if (!phutil_console_confirm($confirm, $default_no = false)) { - throw new ArcanistUsageException('Aborted workflow to fix UTF-8.'); + throw new ArcanistUsageException(pht('Aborted workflow to fix UTF-8.')); } else { foreach ($utf8_problems as $change) { $change->convertToBinaryChange($repository_api); @@ -1188,7 +1233,7 @@ EOTEXT $repository_api = $this->getRepositoryAPI(); - $this->console->writeOut("Linting...\n"); + $this->console->writeOut("%s\n", pht('Linting...')); try { $argv = $this->getPassthruArgumentsAsArgv('lint'); if ($repository_api->supportsCommitRanges()) { @@ -1211,31 +1256,36 @@ EOTEXT $lint_workflow->getUnresolvedMessages()) { $this->getErrorExcuse( 'lint', - 'Lint issued unresolved advice.', + pht('Lint issued unresolved advice.'), 'lint-excuses'); } else { $this->console->writeOut( - "** LINT OKAY ** No lint problems.\n"); + "** %s ** %s\n", + pht('LINT OKAY'), + pht('No lint problems.')); } break; case ArcanistLintWorkflow::RESULT_WARNINGS: $this->getErrorExcuse( 'lint', - 'Lint issued unresolved warnings.', + pht('Lint issued unresolved warnings.'), 'lint-excuses'); break; case ArcanistLintWorkflow::RESULT_ERRORS: $this->console->writeOut( - "** LINT ERRORS ** Lint raised errors!\n"); + "** %s ** %s\n", + pht('LINT ERRORS'), + pht('Lint raised errors!')); $this->getErrorExcuse( 'lint', - 'Lint issued unresolved errors!', + pht('Lint issued unresolved errors!'), 'lint-excuses'); break; case ArcanistLintWorkflow::RESULT_POSTPONED: $this->console->writeOut( - "** LINT POSTPONED ** ". - "Lint results are postponed.\n"); + "** %s ** %s\n", + pht('LINT POSTPONED'), + pht('Lint results are postponed.')); break; } @@ -1248,9 +1298,11 @@ EOTEXT return $lint_result; } catch (ArcanistNoEngineException $ex) { - $this->console->writeOut("No lint engine configured for this project.\n"); + $this->console->writeOut( + "%s\n", + pht('No lint engine configured for this project.')); } catch (ArcanistNoEffectException $ex) { - $this->console->writeOut($ex->getMessage()."\n"); + $this->console->writeOut("%s\n", $ex->getMessage()); } return null; @@ -1270,7 +1322,7 @@ EOTEXT $repository_api = $this->getRepositoryAPI(); - $this->console->writeOut("Running unit tests...\n"); + $this->console->writeOut("%s\n", pht('Running unit tests...')); try { $argv = $this->getPassthruArgumentsAsArgv('unit'); if ($repository_api->supportsCommitRanges()) { @@ -1283,17 +1335,23 @@ EOTEXT switch ($unit_result) { case ArcanistUnitWorkflow::RESULT_OKAY: $this->console->writeOut( - "** UNIT OKAY ** No unit test failures.\n"); + "** %s ** %s\n", + pht('UNIT OKAY'), + pht('No unit test failures.')); break; case ArcanistUnitWorkflow::RESULT_UNSOUND: if ($this->getArgument('ignore-unsound-tests')) { echo phutil_console_format( - "** UNIT UNSOUND ** Unit testing raised errors, ". - "but all failing tests are unsound.\n"); + "** %s ** %s\n", + pht('UNIT UNSOUND'), + pht( + 'Unit testing raised errors, but all '. + 'failing tests are unsound.')); } else { $continue = $this->console->confirm( - 'Unit test results included failures, but all failing tests '. - 'are known to be unsound. Ignore unsound test failures?'); + pht( + 'Unit test results included failures, but all failing tests '. + 'are known to be unsound. Ignore unsound test failures?')); if (!$continue) { throw new ArcanistUserAbortException(); } @@ -1301,10 +1359,12 @@ EOTEXT break; case ArcanistUnitWorkflow::RESULT_FAIL: $this->console->writeOut( - "** UNIT ERRORS ** Unit testing raised errors!\n"); + "** %s ** %s\n", + pht('UNIT ERRORS'), + pht('Unit testing raised errors!')); $this->getErrorExcuse( 'unit', - 'Unit test results include failures!', + pht('Unit test results include failures!'), 'unit-excuses'); break; } @@ -1317,9 +1377,10 @@ EOTEXT return $unit_result; } catch (ArcanistNoEngineException $ex) { $this->console->writeOut( - "No unit test engine is configured for this project.\n"); + "%s\n", + pht('No unit test engine is configured for this project.')); } catch (ArcanistNoEffectException $ex) { - $this->console->writeOut($ex->getMessage()."\n"); + $this->console->writeOut("%s\n", $ex->getMessage()); } return null; @@ -1347,18 +1408,19 @@ EOTEXT if ($this->getArgument('excuse')) { $this->console->sendMessage(array( 'type' => $type, - 'confirm' => $prompt.' Ignore them?', + 'confirm' => $prompt.' '.pht('Ignore them?'), )); return; } $history = $this->getRepositoryAPI()->getScratchFilePath($history); - $prompt .= ' Provide explanation to continue or press Enter to abort.'; + $prompt .= ' '. + pht('Provide explanation to continue or press Enter to abort.'); $this->console->writeOut("\n\n%s", phutil_console_wrap($prompt)); $this->console->sendMessage(array( 'type' => $type, - 'prompt' => 'Explanation:', + 'prompt' => pht('Explanation:'), 'history' => $history, )); } @@ -1430,10 +1492,12 @@ EOTEXT $is_update = $revision['id']; } else { throw new ArcanistUsageException( - "There are several revisions which match the working copy:\n\n". - $this->renderRevisionList($revisions)."\n". - "Use '--update' to choose one, or '--create' to create a new ". - "revision."); + pht( + "There are several revisions which match the working copy:\n\n%s\n". + "Use '%s' to choose one, or '%s' to create a new revision.", + $this->renderRevisionList($revisions), + '--update', + '--create')); } } @@ -1449,7 +1513,9 @@ EOTEXT $revision_id = $this->normalizeRevisionID($is_update); if (!is_numeric($revision_id)) { throw new ArcanistUsageException( - 'Parameter to --update must be a Differential Revision number'); + pht( + 'Parameter to %s must be a Differential Revision number.', + '--update')); } return $this->getCommitMessageFromRevision($revision_id); } else { @@ -1493,18 +1559,19 @@ EOTEXT ->truncateString($preview); if ($preview) { - $preview = "Message begins:\n\n {$preview}\n\n"; + $preview = pht('Message begins:')."\n\n {$preview}\n\n"; } else { $preview = null; } - echo - "You have a saved revision message in '{$where}'.\n". - "{$preview}". - "You can use this message, or discard it."; + echo pht( + "You have a saved revision message in '%s'.\n%s". + "You can use this message, or discard it.", + $where, + $preview); $use = phutil_console_confirm( - 'Do you want to use this message?', + pht('Do you want to use this message?'), $default_no = false); if ($use) { $template = $saved; @@ -1548,14 +1615,18 @@ EOTEXT foreach ($included_commits as $commit) { $included[] = ' '.$commit; } - $in_branch = ''; + if (!$this->isRawDiffSource()) { - $in_branch = ' in branch '.$this->getRepositoryAPI()->getBranchName(); + $message = pht( + 'Included commits in branch %s:', + $this->getRepositoryAPI()->getBranchName()); + } else { + $message = pht('Included commits:'); } $included = array_merge( array( '', - "Included commits{$in_branch}:", + $message, '', ), $included); @@ -1563,14 +1634,15 @@ EOTEXT $issues = array_merge( array( - 'NEW DIFFERENTIAL REVISION', - 'Describe the changes in this new revision.', + pht('NEW DIFFERENTIAL REVISION'), + pht('Describe the changes in this new revision.'), ), $included, array( '', - 'arc could not identify any existing revision in your working copy.', - 'If you intended to update an existing revision, use:', + pht( + 'arc could not identify any existing revision in your working copy.'), + pht('If you intended to update an existing revision, use:'), '', ' $ arc diff --update ', )); @@ -1597,7 +1669,7 @@ EOTEXT $first = false; if ($template_is_default && ($new_template == $template)) { - throw new ArcanistUsageException('Template not edited.'); + throw new ArcanistUsageException(pht('Template not edited.')); } $template = ArcanistCommentRemover::removeComments($new_template); @@ -1619,7 +1691,7 @@ EOTEXT $wrote = (rtrim($old_message) != rtrim($template)); if ($wrote) { $repository_api->amendCommit($template); - $where = 'commit message'; + $where = pht('commit message'); } } else { $wrote = $this->writeScratchFile('create-message', $template); @@ -1633,30 +1705,34 @@ EOTEXT $this->validateCommitMessage($message); $done = true; } catch (ArcanistDifferentialCommitMessageParserException $ex) { - echo "Commit message has errors:\n\n"; - $issues = array('Resolve these errors:'); + echo pht('Commit message has errors:')."\n\n"; + $issues = array(pht('Resolve these errors:')); foreach ($ex->getParserErrors() as $error) { echo phutil_console_wrap("- ".$error."\n", 6); $issues[] = ' - '.$error; } echo "\n"; - echo 'You must resolve these errors to continue.'; + echo pht('You must resolve these errors to continue.'); $again = phutil_console_confirm( - 'Do you want to edit the message?', + pht('Do you want to edit the message?'), $default_no = false); if ($again) { // Keep going. } else { $saved = null; if ($wrote) { - $saved = "A copy was saved to {$where}."; + $saved = pht('A copy was saved to %s.', $where); } throw new ArcanistUsageException( - "Message has unresolved errrors. {$saved}"); + pht('Message has unresolved errors.')." {$saved}"); } } catch (Exception $ex) { if ($wrote) { - echo phutil_console_wrap("(Message saved to {$where}.)\n"); + echo phutil_console_wrap( + "%s\n", + pht( + '(Message saved to %s.)', + $where)); } throw $ex; } @@ -1697,7 +1773,9 @@ EOTEXT if (!$revision) { throw new ArcanistUsageException( - "Revision '{$revision_id}' does not exist!"); + pht( + "Revision '%s' does not exist!", + $revision_id)); } $this->checkRevisionOwnership($revision); @@ -1735,9 +1813,9 @@ EOTEXT $reviewers = $message->getFieldValue('reviewerPHIDs'); if (!$reviewers) { - $confirm = 'You have not specified any reviewers. Continue anyway?'; + $confirm = pht('You have not specified any reviewers. Continue anyway?'); if (!phutil_console_confirm($confirm)) { - throw new ArcanistUsageException('Specify reviewers and retry.'); + throw new ArcanistUsageException(pht('Specify reviewers and retry.')); } } else { $futures['reviewers'] = $this->getConduit()->callMethod( @@ -1753,7 +1831,9 @@ EOTEXT case 'revision': if (empty($result)) { throw new ArcanistUsageException( - "There is no revision D{$revision_id}."); + pht( + 'There is no revision %s.', + "D{$revision_id}")); } $this->checkRevisionOwnership(head($result)); break; @@ -1766,11 +1846,12 @@ EOTEXT } if (count($untils) == count($reviewers)) { $until = date('l, M j Y', min($untils)); - $confirm = "All reviewers are away until {$until}. ". - "Continue anyway?"; + $confirm = pht( + 'All reviewers are away until %s. Continue anyway?', + $until); if (!phutil_console_confirm($confirm)) { throw new ArcanistUsageException( - 'Specify available reviewers and retry.'); + pht('Specify available reviewers and retry.')); } } break; @@ -1786,9 +1867,12 @@ EOTEXT private function getUpdateMessage(array $fields, $template = '') { if ($this->getArgument('raw')) { throw new ArcanistUsageException( - "When using '--raw' to update a revision, specify an update message ". - "with '--message'. (Normally, we'd launch an editor to ask you for a ". - "message, but can not do that because stdin is the diff source.)"); + pht( + "When using '%s' to update a revision, specify an update message ". + "with '%s'. (Normally, we'd launch an editor to ask you for a ". + "message, but can not do that because stdin is the diff source.)", + '--raw', + '--message')); } // When updating a revision using git without specifying '--message', try @@ -1804,17 +1888,18 @@ EOTEXT if ($template == '') { $comments = $this->getDefaultUpdateMessage(); - $template = - rtrim($comments). - "\n\n". - "# Updating D{$fields['revisionID']}: {$fields['title']}\n". - "#\n". - "# Enter a brief description of the changes included in this update.\n". - "# The first line is used as subject, next lines as comment.\n". - "#\n". - "# If you intended to create a new revision, use:\n". - "# $ arc diff --create\n". - "\n"; + $template = sprintf( + "%s\n\n# %s\n#\n# %s\n# %s\n#\n# %s\n# $ %s\n\n", + rtrim($comments), + pht( + 'Updating %s: %s', + "D{$fields['revisionID']}", + $fields['title']), + pht( + 'Enter a brief description of the changes included in this update.'), + pht('The first line is used as subject, next lines as comment.'), + pht('If you intended to create a new revision, use:'), + 'arc diff --create'); } $comments = $this->newInteractiveEditor($template) @@ -1873,10 +1958,10 @@ EOTEXT $faux_message = array(); if ($this->getArgument('reviewers')) { - $faux_message[] = 'Reviewers: '.$this->getArgument('reviewers'); + $faux_message[] = pht('Reviewers: %s', $this->getArgument('reviewers')); } if ($this->getArgument('cc')) { - $faux_message[] = 'CC: '.$this->getArgument('cc'); + $faux_message[] = pht('CC: %s', $this->getArgument('cc')); } if ($faux_message) { @@ -1884,7 +1969,7 @@ EOTEXT $local = array( '(Flags) ' => array( 'message' => $faux_message, - 'summary' => 'Command-Line Flags', + 'summary' => pht('Command-Line Flags'), ), ) + $local; } @@ -1920,7 +2005,9 @@ EOTEXT $fields[$hash] = $message->getFields(); $frev = substr($hash, 0, 12); - $notes[] = "NOTE: commit {$frev} could not be completely parsed:"; + $notes[] = pht( + 'NOTE: commit %s could not be completely parsed:', + $frev); foreach ($ex->getParserErrors() as $error) { $notes[] = " - {$error}"; } diff --git a/src/workflow/ArcanistDownloadWorkflow.php b/src/workflow/ArcanistDownloadWorkflow.php index 49cb8117..56ea3a22 100644 --- a/src/workflow/ArcanistDownloadWorkflow.php +++ b/src/workflow/ArcanistDownloadWorkflow.php @@ -87,7 +87,7 @@ EOTEXT )); $bytes = number_format($info['byteSize']); - $desc = '('.$bytes.' bytes)'; + $desc = pht('(%d bytes)', $bytes); if ($info['name']) { $desc = "'".$info['name']."' ".$desc; } diff --git a/src/workflow/ArcanistHelpWorkflow.php b/src/workflow/ArcanistHelpWorkflow.php index 2792afde..82233616 100644 --- a/src/workflow/ArcanistHelpWorkflow.php +++ b/src/workflow/ArcanistHelpWorkflow.php @@ -29,7 +29,7 @@ EOTEXT public function getArguments() { return array( 'full' => array( - 'help' => 'Print detailed information about each command.', + 'help' => pht('Print detailed information about each command.'), ), '*' => 'command', ); diff --git a/src/workflow/ArcanistShellCompleteWorkflow.php b/src/workflow/ArcanistShellCompleteWorkflow.php index 90551f2a..0a933506 100644 --- a/src/workflow/ArcanistShellCompleteWorkflow.php +++ b/src/workflow/ArcanistShellCompleteWorkflow.php @@ -30,7 +30,7 @@ EOTEXT 'current' => array( 'param' => 'cursor_position', 'paramtype' => 'int', - 'help' => 'Current term in the argument list being completed.', + 'help' => pht('Current term in the argument list being completed.'), ), '*' => 'argv', ); diff --git a/src/workflow/ArcanistWhichWorkflow.php b/src/workflow/ArcanistWhichWorkflow.php index fdae9c7a..17d43447 100644 --- a/src/workflow/ArcanistWhichWorkflow.php +++ b/src/workflow/ArcanistWhichWorkflow.php @@ -134,7 +134,7 @@ EOTEXT 'hg diff --rev %R', hgsprintf('%s', $relative)); } else { - throw new Exception('Unknown VCS!'); + throw new Exception(pht('Unknown VCS!')); } echo phutil_console_wrap( @@ -193,7 +193,7 @@ EOTEXT 'copy:'))); if (empty($revisions)) { - echo " (No revisions match.)\n"; + echo " ".pht('(No revisions match.)')."\n"; echo "\n"; echo phutil_console_wrap( phutil_console_format( diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index 006d75c1..117bbe94 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -1228,7 +1228,7 @@ abstract class ArcanistWorkflow extends Phobject { $parser = $this->newDiffParser(); $changes = $parser->parseDiff($diff); if (count($changes) != 1) { - throw new Exception('Expected exactly one change.'); + throw new Exception(pht('Expected exactly one change.')); } $this->changeCache[$path] = reset($changes); } @@ -1240,7 +1240,7 @@ abstract class ArcanistWorkflow extends Phobject { } } } else { - throw new Exception('Missing VCS support.'); + throw new Exception(pht('Missing VCS support.')); } if (empty($this->changeCache[$path])) { @@ -1253,7 +1253,9 @@ abstract class ArcanistWorkflow extends Phobject { return $change; } else { throw new Exception( - "Trying to get change for unchanged path '{$path}'!"); + pht( + "Trying to get change for unchanged path '%s'!", + $path)); } } @@ -1275,7 +1277,10 @@ abstract class ArcanistWorkflow extends Phobject { $extended_info = ' '.$options['nosupport'][$system_name]; } throw new ArcanistUsageException( - "Option '--{$arg}' is not supported under {$system_name}.". + pht( + "Option '%s' is not supported under %s.", + "--{$arg}", + $system_name). $extended_info); } } @@ -1375,7 +1380,10 @@ abstract class ArcanistWorkflow extends Phobject { foreach ($paths as $key => $path) { $full_path = Filesystem::resolvePath($path); if (!Filesystem::pathExists($full_path)) { - throw new ArcanistUsageException("Path '{$path}' does not exist!"); + throw new ArcanistUsageException( + pht( + "Path '%s' does not exist!", + $path)); } $relative_path = Filesystem::readablePath( $full_path, @@ -1600,10 +1608,12 @@ abstract class ArcanistWorkflow extends Phobject { } catch (ConduitClientException $ex) { if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { echo phutil_console_wrap( - "This feature requires a newer version of Phabricator. Please ". - "update it using these instructions: ". - "http://www.phabricator.com/docs/phabricator/article/". - "Installation_Guide.html#updating-phabricator\n\n"); + "%s\n\n", + pht( + 'This feature requires a newer version of Phabricator. Please '. + 'update it using these instructions: %s', + 'http://www.phabricator.com/docs/phabricator/article/'. + 'Installation_Guide.html#updating-phabricator')); } throw $ex; } @@ -1628,13 +1638,14 @@ abstract class ArcanistWorkflow extends Phobject { $api = $this->getRepositoryAPI(); if (!$api->supportsCommitRanges()) { throw new ArcanistUsageException( - 'This version control system does not support commit ranges.'); + pht('This version control system does not support commit ranges.')); } if (count($argv) > 1) { throw new ArcanistUsageException( - 'Specify exactly one base commit. The end of the commit range is '. - 'always the working copy state.'); + pht( + 'Specify exactly one base commit. The end of the commit range is '. + 'always the working copy state.')); } $api->setBaseCommit(head($argv));