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

View file

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