1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-30 18:52:41 +01:00

phtize some strings

Summary: Self-explanatory.

Test Plan: Eye-balled it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10596
This commit is contained in:
Joshua Spence 2015-01-06 23:14:04 +11:00
parent 6eed5c2514
commit 7e2df9a5bf
3 changed files with 119 additions and 79 deletions

View file

@ -15,7 +15,7 @@ $base_args->parsePartial(
array( array(
'name' => 'load-phutil-library', 'name' => 'load-phutil-library',
'param' => 'path', 'param' => 'path',
'help' => 'Load a libphutil library.', 'help' => pht('Load a libphutil library.'),
'repeat' => true, 'repeat' => true,
), ),
array( array(
@ -28,25 +28,26 @@ $base_args->parsePartial(
array( array(
'name' => 'conduit-uri', 'name' => 'conduit-uri',
'param' => 'uri', 'param' => 'uri',
'help' => 'Connect to Phabricator install specified by __uri__.', 'help' => pht('Connect to Phabricator install specified by __uri__.'),
), ),
array( array(
'name' => 'conduit-version', 'name' => 'conduit-version',
'param' => 'version', 'param' => 'version',
'help' => '(Developers) Mock client version in protocol handshake.', 'help' => pht(
'(Developers) Mock client version in protocol handshake.'),
), ),
array( array(
'name' => 'conduit-timeout', 'name' => 'conduit-timeout',
'param' => 'timeout', 'param' => 'timeout',
'help' => 'Set Conduit timeout (in seconds).', 'help' => pht('Set Conduit timeout (in seconds).'),
), ),
array( array(
'name' => 'config', 'name' => 'config',
'param' => 'key=value', 'param' => 'key=value',
'repeat' => true, 'repeat' => true,
'help' => 'help' => pht(
'Specify a runtime configuration value. This will take precedence '. 'Specify a runtime configuration value. This will take precedence '.
'over static values, and only affect the current arcanist invocation.', 'over static values, and only affect the current arcanist invocation.'),
), ),
)); ));
@ -69,17 +70,22 @@ $workflow = null;
try { try {
$console->writeLog( $console->writeLog(
"libphutil loaded from '%s'.\n", "%s\n",
phutil_get_library_root('phutil')); pht(
"libphutil loaded from '%s'.",
phutil_get_library_root('phutil')));
$console->writeLog( $console->writeLog(
"arcanist loaded from '%s'.\n", "%s\n",
phutil_get_library_root('arcanist')); pht(
"arcanist loaded from '%s'.",
phutil_get_library_root('arcanist')));
if (!$args) { if (!$args) {
if ($help) { if ($help) {
$args = array('help'); $args = array('help');
} else { } else {
throw new ArcanistUsageException("No command provided. Try 'arc help'."); throw new ArcanistUsageException(
pht('No command provided. Try `%s`.', 'arc help'));
} }
} else if ($help) { } else if ($help) {
array_unshift($args, 'help'); array_unshift($args, 'help');
@ -116,14 +122,17 @@ try {
// specific libraries to load regardless of the state of the world. // specific libraries to load regardless of the state of the world.
if ($load) { if ($load) {
$console->writeLog( $console->writeLog(
"Using '--load-phutil-library' flag, configuration will be ignored ". "%s\n",
"and configured libraries will not be loaded."."\n"); pht(
'Using `%s` flag, configuration will be ignored and configured '.
'libraries will not be loaded.',
'--load-phutil-library'));
// Load the flag libraries. These must load, since the user specified them // Load the flag libraries. These must load, since the user specified them
// explicitly. // explicitly.
arcanist_load_libraries( arcanist_load_libraries(
$load, $load,
$must_load = true, $must_load = true,
$lib_source = 'a "--load-phutil-library" flag', $lib_source = pht('a "%s" flag', '--load-phutil-library'),
$working_copy); $working_copy);
} else { } else {
// Load libraries in system 'load' config. In contrast to global config, we // Load libraries in system 'load' config. In contrast to global config, we
@ -132,7 +141,7 @@ try {
arcanist_load_libraries( arcanist_load_libraries(
idx($system_config, 'load', array()), idx($system_config, 'load', array()),
$must_load = true, $must_load = true,
$lib_source = 'the "load" setting in system config', $lib_source = pht('the "%s" setting in system config', 'load'),
$working_copy); $working_copy);
// Load libraries in global 'load' config, as per "arc set-config load". We // Load libraries in global 'load' config, as per "arc set-config load". We
@ -141,23 +150,22 @@ try {
arcanist_load_libraries( arcanist_load_libraries(
idx($global_config, 'load', array()), idx($global_config, 'load', array()),
$must_load = false, $must_load = false,
$lib_source = 'the "load" setting in global config', $lib_source = pht('the "%s" setting in global config', 'load'),
$working_copy); $working_copy);
// Load libraries in ".arcconfig". Libraries here must load. // Load libraries in ".arcconfig". Libraries here must load.
arcanist_load_libraries( arcanist_load_libraries(
$working_copy->getProjectConfig('load'), $working_copy->getProjectConfig('load'),
$must_load = true, $must_load = true,
$lib_source = 'the "load" setting in ".arcconfig"', $lib_source = pht('the "%s" setting in "%s"', 'load', '.arcconfig'),
$working_copy); $working_copy);
// Load libraries in ".arcconfig". Libraries here must load. // Load libraries in ".arcconfig". Libraries here must load.
arcanist_load_libraries( arcanist_load_libraries(
idx($runtime_config, 'load', array()), idx($runtime_config, 'load', array()),
$must_load = true, $must_load = true,
$lib_source = 'the --config "load=[...]" argument', $lib_source = pht('the %s argument', '--config "load=[...]"'),
$working_copy); $working_copy);
} }
$user_config = $configuration_manager->readUserConfigurationFile(); $user_config = $configuration_manager->readUserConfigurationFile();
@ -211,8 +219,9 @@ try {
if ($need_working_copy || $want_working_copy) { if ($need_working_copy || $want_working_copy) {
if ($need_working_copy && !$working_copy->getVCSType()) { if ($need_working_copy && !$working_copy->getVCSType()) {
throw new ArcanistUsageException( throw new ArcanistUsageException(
'This command must be run in a Git, Mercurial or Subversion working '. pht(
'copy.'); 'This command must be run in a Git, Mercurial or Subversion '.
'working copy.'));
} }
$configuration_manager->setWorkingCopyIdentity($working_copy); $configuration_manager->setWorkingCopyIdentity($working_copy);
} }
@ -223,8 +232,7 @@ try {
$conduit_uri = $configuration_manager->getConfigFromAnySource( $conduit_uri = $configuration_manager->getConfigFromAnySource(
'phabricator.uri'); 'phabricator.uri');
if ($conduit_uri === null) { if ($conduit_uri === null) {
$conduit_uri = $configuration_manager->getConfigFromAnySource( $conduit_uri = $configuration_manager->getConfigFromAnySource('default');
'default');
} }
} }
@ -258,12 +266,21 @@ try {
if (!$conduit_uri) { if (!$conduit_uri) {
$message = phutil_console_format( $message = phutil_console_format(
"This command requires arc to connect to a Phabricator install, but ". "%s\n\n - %s\n - %s\n - %s\n",
"no Phabricator installation is configured. To configure a ". pht(
"Phabricator URI:\n\n". 'This command requires arc to connect to a Phabricator install, '.
" - set a default location with `arc set-config default <uri>`; or\n". 'but no Phabricator installation is configured. To configure a '.
" - specify '--conduit-uri=uri' explicitly; or\n". 'Phabricator URI:'),
" - run 'arc' in a working copy with an '.arcconfig'.\n"); pht(
'set a default location with `%s`; or',
'arc set-config default <uri>'),
pht(
'specify `%s` explicitly; or',
'--conduit-uri=uri'),
pht(
"run `%s` in a working copy with an '%s'.",
'arc',
'.arcconfig'));
$message = phutil_console_wrap($message); $message = phutil_console_wrap($message);
throw new ArcanistUsageException($message); throw new ArcanistUsageException($message);
@ -297,12 +314,14 @@ try {
throw new ArcanistUsageException( throw new ArcanistUsageException(
phutil_console_format( phutil_console_format(
"YOU NEED TO AUTHENTICATE TO CONTINUE\n\n". "%s\n\n%s\n\n%s **%s:**\n\n $ **{$arc} install-certificate**\n",
"You are trying to connect to a server ({$conduit_domain}) that you ". pht('YOU NEED TO AUTHENTICATE TO CONTINUE'),
"do not have any credentials stored for.\n\n". pht(
"To retrieve and store credentials for this server, ". 'You are trying to connect to a server (%s) that you '.
"**run this command:**\n\n". 'do not have any credentials stored for.',
" $ **{$arc} install-certificate**\n")); $conduit_domain),
pht('To retrieve and store credentials for this server,'),
pht('run this command')));
} }
$workflow->authenticateConduit(); $workflow->authenticateConduit();
} }
@ -319,8 +338,8 @@ try {
if ($listeners) { if ($listeners) {
foreach ($listeners as $listener) { foreach ($listeners as $listener) {
$console->writeLog( $console->writeLog(
"Registering event listener '%s'.\n", "%s\n",
$listener); pht("Registering event listener '%s'.", $listener));
try { try {
id(new $listener())->register(); id(new $listener())->register();
} catch (PhutilMissingSymbolException $ex) { } catch (PhutilMissingSymbolException $ex) {
@ -330,9 +349,11 @@ try {
// it might not have been triggered by the listener itself (for example, // it might not have been triggered by the listener itself (for example,
// the listener might use a bad class in its register() method). // the listener might use a bad class in its register() method).
$console->writeErr( $console->writeErr(
"ERROR: Failed to load event listener '%s': %s\n", "%s\n",
pht(
"ERROR: Failed to load event listener '%s': %s",
$listener, $listener,
$ex->getMessage()); $ex->getMessage()));
} }
} }
} }
@ -356,7 +377,8 @@ try {
$is_usage = ($ex instanceof ArcanistUsageException); $is_usage = ($ex instanceof ArcanistUsageException);
if ($is_usage) { if ($is_usage) {
echo phutil_console_format( echo phutil_console_format(
"**Usage Exception:** %s\n", "**%s** %s\n",
pht('Usage Exception:'),
$ex->getMessage()); $ex->getMessage());
} }
@ -370,7 +392,7 @@ try {
} }
if (!$is_usage) { if (!$is_usage) {
echo phutil_console_format("**Exception**\n"); echo phutil_console_format("**%s**\n", pht('Exception'));
while ($ex) { while ($ex) {
echo $ex->getMessage()."\n"; echo $ex->getMessage()."\n";
@ -382,7 +404,9 @@ try {
} }
} }
echo "(Run with --trace for a full exception trace.)\n"; echo phutil_console_format(
"(%s)\n",
pht('Run with `%s` for a full exception trace.', '--trace'));
} }
exit(1); exit(1);
@ -486,13 +510,13 @@ function sanity_check_environment() {
} }
function die_with_bad_php($message) { function die_with_bad_php($message) {
echo "\nPHP CONFIGURATION ERRORS\n\n"; echo phutil_console_format(
echo $message; "\n%s\n\n%s\n\n",
echo "\n\n"; pht('PHP CONFIGURATION ERRORS'),
$message);
exit(1); exit(1);
} }
function arcanist_load_libraries( function arcanist_load_libraries(
$load, $load,
$must_load, $must_load,
@ -504,10 +528,12 @@ function arcanist_load_libraries(
} }
if (!is_array($load)) { if (!is_array($load)) {
$error = "Libraries specified by {$lib_source} are invalid; expected ". $error = pht(
"a list. Check your configuration."; 'Libraries specified by %s are invalid; expected a list. '.
'Check your configuration.',
$lib_source);
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();
$console->writeErr("WARNING: %s\n", $error); $console->writeErr("%s: %s\n", pht('WARNING'), $error);
return; return;
} }
@ -554,33 +580,40 @@ function arcanist_load_libraries(
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();
$console->writeLog( $console->writeLog(
"Loading phutil library from '%s'...\n", "%s\n",
$location); pht("Loading phutil library from '%s'...", $location));
$error = null; $error = null;
try { try {
phutil_load_library($location); phutil_load_library($location);
} catch (PhutilBootloaderException $ex) { } catch (PhutilBootloaderException $ex) {
$error = "Failed to load phutil library at location '{$location}'. ". $error = pht(
"This library is specified by {$lib_source}. Check that the ". "Failed to load phutil library at location '%s'. This library ".
"setting is correct and the library is located in the right ". "is specified by %s. Check that the setting is correct and the ".
"place."; "library is located in the right place.",
$location,
$lib_source);
if ($must_load) { if ($must_load) {
throw new ArcanistUsageException($error); throw new ArcanistUsageException($error);
} else { } else {
fwrite(STDERR, phutil_console_wrap('WARNING: '.$error."\n\n")); fwrite(STDERR, phutil_console_wrap(
"%s: %s\n\n",
pht('WARNING'),
$error));
} }
} catch (PhutilLibraryConflictException $ex) { } catch (PhutilLibraryConflictException $ex) {
if ($ex->getLibrary() != 'arcanist') { if ($ex->getLibrary() != 'arcanist') {
throw $ex; throw $ex;
} }
$arc_dir = dirname(dirname(__FILE__)); $arc_dir = dirname(dirname(__FILE__));
$error = $error = pht(
"You are trying to run one copy of Arcanist on another copy of ". "You are trying to run one copy of Arcanist on another copy of ".
"Arcanist. This operation is not supported. To execute Arcanist ". "Arcanist. This operation is not supported. To execute Arcanist ".
"operations against this working copy, run './bin/arc' (from the ". "operations against this working copy, run `%s` (from the current ".
"current working copy) not some other copy of 'arc' (you ran one ". "working copy) not some other copy of '%s' (you ran one from '%s').",
"from '{$arc_dir}')."; './bin/arc',
'arc',
$arc_dir);
throw new ArcanistUsageException($error); throw new ArcanistUsageException($error);
} }
} }
@ -631,12 +664,14 @@ function reenter_if_this_is_arcanist_or_libphutil(
if ($project_id == 'libphutil') { if ($project_id == 'libphutil') {
$console->writeLog( $console->writeLog(
"This is libphutil! Forcing this copy to load...\n"); "%s\n",
pht('This is libphutil! Forcing this copy to load...'));
$original_argv[0] = dirname(phutil_get_library_root('arcanist')).'/bin/arc'; $original_argv[0] = dirname(phutil_get_library_root('arcanist')).'/bin/arc';
$libphutil_path = $project_root; $libphutil_path = $project_root;
} else { } else {
$console->writeLog( $console->writeLog(
"This is arcanist! Forcing this copy to run...\n"); "%s\n",
pht('This is arcanist! Forcing this copy to run...'));
$original_argv[0] = $project_root.'/bin/arc'; $original_argv[0] = $project_root.'/bin/arc';
$libphutil_path = dirname(phutil_get_library_root('phutil')); $libphutil_path = dirname(phutil_get_library_root('phutil'));
} }

View file

@ -9,10 +9,10 @@ $args->parse(
array( array(
array( array(
'name' => 'skip-hello', 'name' => 'skip-hello',
'help' => 'Do not expect "capability" message when connecting. '. 'help' => pht(
'The server must be configured not to send the message. '. 'Do not expect "capability" message when connecting. The server '.
'This deviates from the Mercurial protocol, but slightly '. 'must be configured not to send the message. This deviates from '.
'improves performance.', 'the Mercurial protocol, but slightly improves performance.'),
), ),
array( array(
'name' => 'repository', 'name' => 'repository',
@ -22,7 +22,7 @@ $args->parse(
$repo = $args->getArg('repository'); $repo = $args->getArg('repository');
if (count($repo) !== 1) { if (count($repo) !== 1) {
throw new Exception('Specify exactly one working copy!'); throw new Exception(pht('Specify exactly one working copy!'));
} }
$repo = head($repo); $repo = head($repo);
@ -37,4 +37,9 @@ $result = $client->executeCommand(
$t_end = microtime(true); $t_end = microtime(true);
var_dump($result); var_dump($result);
echo "\nExecuted in ".((int)(1000000 * ($t_end - $t_start)))."us.\n"; $console = PhutilConsole::getConsole();
$console->writeOut(
"\n%s\n",
pht(
'Executed in %d us.',
((int)(1000000 * ($t_end - $t_start)))));

View file

@ -9,28 +9,28 @@ $args->parse(
array( array(
array( array(
'name' => 'quiet', 'name' => 'quiet',
'help' => 'Do not print status messages to stdout.', 'help' => pht('Do not print status messages to stdout.'),
), ),
array( array(
'name' => 'skip-hello', 'name' => 'skip-hello',
'help' => 'Do not send "capability" message when clients connect. '. 'help' => pht(
'Clients must be configured not to expect the message. '. 'Do not send "capability" message when clients connect. Clients '.
'This deviates from the Mercurial protocol, but slightly '. 'must be configured not to expect the message. This deviates '.
'improves performance.', 'from the Mercurial protocol, but slightly improves performance.'),
), ),
array( array(
'name' => 'do-not-daemonize', 'name' => 'do-not-daemonize',
'help' => 'Remain in the foreground instead of daemonizing.', 'help' => pht('Remain in the foreground instead of daemonizing.'),
), ),
array( array(
'name' => 'client-limit', 'name' => 'client-limit',
'param' => 'limit', 'param' => 'limit',
'help' => 'Exit after serving __limit__ clients.', 'help' => pht('Exit after serving __limit__ clients.'),
), ),
array( array(
'name' => 'idle-limit', 'name' => 'idle-limit',
'param' => 'seconds', 'param' => 'seconds',
'help' => 'Exit after __seconds__ spent idle.', 'help' => pht('Exit after __seconds__ spent idle.'),
), ),
array( array(
'name' => 'repository', 'name' => 'repository',
@ -40,7 +40,7 @@ $args->parse(
$repo = $args->getArg('repository'); $repo = $args->getArg('repository');
if (count($repo) !== 1) { if (count($repo) !== 1) {
throw new Exception('Specify exactly one working copy!'); throw new Exception(pht('Specify exactly one working copy!'));
} }
$repo = head($repo); $repo = head($repo);