Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14776999
D12876.id31012.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
33 KB
Referenced Files
None
Subscribers
None
D12876.id31012.diff
View Options
diff --git a/scripts/build_xhpast.sh b/scripts/build_xhpast.sh
--- a/scripts/build_xhpast.sh
+++ b/scripts/build_xhpast.sh
@@ -4,4 +4,4 @@
require_once dirname(__FILE__).'/__init_script__.php';
PhutilXHPASTBinary::build();
-echo "Build successful!\n";
+echo pht('Build successful!')."\n";
diff --git a/scripts/daemon/exec/exec_daemon.php b/scripts/daemon/exec/exec_daemon.php
--- a/scripts/daemon/exec/exec_daemon.php
+++ b/scripts/daemon/exec/exec_daemon.php
@@ -6,12 +6,12 @@
if (!posix_isatty(STDOUT)) {
$sid = posix_setsid();
if ($sid <= 0) {
- throw new Exception('Failed to create new process session!');
+ throw new Exception(pht('Failed to create new process session!'));
}
}
$args = new PhutilArgumentParser($argv);
-$args->setTagline('daemon executor');
+$args->setTagline(pht('daemon executor'));
$args->setSynopsis(<<<EOHELP
**exec_daemon.php** [__options__] __daemon__ ...
Run an instance of __daemon__.
@@ -21,22 +21,23 @@
array(
array(
'name' => 'trace',
- 'help' => 'Enable debug tracing.',
+ 'help' => pht('Enable debug tracing.'),
),
array(
'name' => 'trace-memory',
- 'help' => 'Enable debug memory tracing.',
+ 'help' => pht('Enable debug memory tracing.'),
),
array(
'name' => 'verbose',
- 'help' => 'Enable verbose activity logging.',
+ 'help' => pht('Enable verbose activity logging.'),
),
array(
'name' => 'label',
'short' => 'l',
'param' => 'label',
'help' => pht(
- 'Optional process label. Makes "ps" nicer, no behavioral effects.'),
+ 'Optional process label. Makes "%s" nicer, no behavioral effects.',
+ 'ps'),
),
array(
'name' => 'daemon',
@@ -89,10 +90,15 @@
$daemon = head($daemon);
if (!class_exists($daemon)) {
throw new PhutilArgumentUsageException(
- pht('No class "%s" exists in any known library.', $daemon));
+ pht(
+ 'No class "%s" exists in any known library.',
+ $daemon));
} else if (!is_subclass_of($daemon, 'PhutilDaemon')) {
throw new PhutilArgumentUsageException(
- pht('Class "%s" is not a subclass of "%s".', $daemon, 'PhutilDaemon'));
+ pht(
+ 'Class "%s" is not a subclass of "%s".',
+ $daemon,
+ 'PhutilDaemon'));
}
}
diff --git a/scripts/daemon/torture/resist-death.php b/scripts/daemon/torture/resist-death.php
--- a/scripts/daemon/torture/resist-death.php
+++ b/scripts/daemon/torture/resist-death.php
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
+require_once dirname(__FILE__).'/../../__init_script__.php';
+
// This script just creates a process which is difficult to terminate. It is
// used for daemon resilience tests.
@@ -12,7 +14,7 @@
return;
}
-echo "Resisting death; sleeping forever...\n";
+echo pht('Resisting death; sleeping forever...')."\n";
while (true) {
sleep(60);
diff --git a/scripts/example/calculator.php b/scripts/example/calculator.php
--- a/scripts/example/calculator.php
+++ b/scripts/example/calculator.php
@@ -4,7 +4,7 @@
require_once dirname(dirname(__FILE__)).'/__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('simple calculator example');
+$args->setTagline(pht('simple calculator example'));
$args->setSynopsis(<<<EOHELP
**calculator.php** __op__ __n__ ...
Perform a calculation.
@@ -14,7 +14,7 @@
$add_workflow = id(new PhutilArgumentWorkflow())
->setName('add')
->setExamples('**add** __n__ ...')
- ->setSynopsis('Compute the sum of a list of numbers.')
+ ->setSynopsis(pht('Compute the sum of a list of numbers.'))
->setArguments(
array(
array(
@@ -26,7 +26,7 @@
$mul_workflow = id(new PhutilArgumentWorkflow())
->setName('mul')
->setExamples('**mul** __n__ ...')
- ->setSynopsis('Compute the product of a list of numbers.')
+ ->setSynopsis(pht('Compute the product of a list of numbers.'))
->setArguments(
array(
array(
@@ -44,13 +44,13 @@
$nums = $args->getArg('numbers');
if (empty($nums)) {
- echo "You must provide one or more numbers!\n";
+ echo pht('You must provide one or more numbers!')."\n";
exit(1);
}
foreach ($nums as $num) {
if (!is_numeric($num)) {
- echo "Number '{$num}' is not numeric!\n";
+ echo pht("Number '%s' is not numeric!", $num)."\n";
exit(1);
}
}
diff --git a/scripts/example/subworkflow.php b/scripts/example/subworkflow.php
--- a/scripts/example/subworkflow.php
+++ b/scripts/example/subworkflow.php
@@ -4,7 +4,7 @@
require_once dirname(dirname(__FILE__)).'/__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('crazy workflow delgation');
+$args->setTagline(pht('crazy workflow delegation'));
$args->setSynopsis(<<<EOHELP
**subworkflow.php** do echo __args__ ...
Echo some stuff using a convoluted series of delegate workflows.
@@ -47,7 +47,7 @@
$echo_workflow = id(new PhutilEchoExampleArgumentWorkflow())
->setName('echo')
->setExamples('**echo** __string__ ...')
- ->setSynopsis('Echo __string__.');
+ ->setSynopsis(pht('Echo __string__.'));
$args->parseWorkflows(
array(
@@ -62,7 +62,7 @@
$do_workflow = id(new PhutilDoExampleArgumentWorkflow())
->setName('do')
->setExamples('**do** __thing__ ...')
- ->setSynopsis('Do __thing__.');
+ ->setSynopsis(pht('Do __thing__.'));
$args->parseWorkflows(
array(
diff --git a/scripts/format_log.php b/scripts/format_log.php
--- a/scripts/format_log.php
+++ b/scripts/format_log.php
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
-// Simple script to format stacktraces in apache logs, etc., so they are more
+// Simple script to format stack traces in apache logs, etc., so they are more
// readable.
$f = fopen('php://stdin', 'r');
diff --git a/scripts/phutil_rebuild_map.php b/scripts/phutil_rebuild_map.php
--- a/scripts/phutil_rebuild_map.php
+++ b/scripts/phutil_rebuild_map.php
@@ -4,7 +4,7 @@
require_once dirname(__FILE__).'/__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('rebuild the library map file');
+$args->setTagline(pht('rebuild the library map file'));
$args->setSynopsis(<<<EOHELP
**phutil_rebuild_map.php** [__options__] __root__
Rebuild the library map file for a libphutil library.
@@ -17,28 +17,31 @@
array(
array(
'name' => 'quiet',
- 'help' => 'Do not write status messages to stderr.',
+ 'help' => pht('Do not write status messages to stderr.'),
),
array(
'name' => 'drop-cache',
- 'help' => 'Drop the symbol cache and rebuild the entire map from '.
- 'scratch.',
+ 'help' => pht(
+ 'Drop the symbol cache and rebuild the entire map from scratch.'),
),
array(
'name' => 'limit',
'param' => 'N',
'default' => 8,
- 'help' => 'Controls the number of symbol mapper subprocesses run '.
- 'at once. Defaults to 8.',
+ 'help' => pht(
+ 'Controls the number of symbol mapper subprocesses run at once. '.
+ 'Defaults to 8.'),
),
array(
'name' => 'show',
- 'help' => 'Print symbol map to stdout instead of writing it to the '.
- 'map file.',
+ 'help' => pht(
+ 'Print symbol map to stdout instead of writing it to the map file.'),
),
array(
'name' => 'ugly',
- 'help' => 'Use faster but less readable serialization for --show.',
+ 'help' => pht(
+ 'Use faster but less readable serialization for %s.',
+ '--show'),
),
array(
'name' => 'root',
@@ -48,7 +51,7 @@
$root = $args->getArg('root');
if (count($root) !== 1) {
- throw new Exception('Provide exactly one library root!');
+ throw new Exception(pht('Provide exactly one library root!'));
}
$root = Filesystem::resolvePath(head($root));
diff --git a/scripts/phutil_symbols.php b/scripts/phutil_symbols.php
--- a/scripts/phutil_symbols.php
+++ b/scripts/phutil_symbols.php
@@ -2,13 +2,13 @@
<?php
// We have to do this first before we load any symbols, because we define the
-// builtin symbol list through introspection.
+// built-in symbol list through introspection.
$builtins = phutil_symbols_get_builtins();
require_once dirname(__FILE__).'/__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('identify symbols in a PHP source file');
+$args->setTagline(pht('identify symbols in a PHP source file'));
$args->setSynopsis(<<<EOHELP
**phutil_symbols.php** [__options__] __path.php__
Identify the symbols (clases, functions and interfaces) in a PHP
@@ -36,23 +36,23 @@
array(
array(
'name' => 'all',
- 'help' => 'Report all symbols, including builtins and declared '.
- 'externals.',
+ 'help' => pht(
+ 'Report all symbols, including built-ins and declared externals.'),
),
array(
'name' => 'ugly',
- 'help' => 'Do not prettify JSON output.',
+ 'help' => pht('Do not prettify JSON output.'),
),
array(
'name' => 'path',
'wildcard' => true,
- 'help' => 'PHP Source file to analyze.',
+ 'help' => pht('PHP Source file to analyze.'),
),
));
$paths = $args->getArg('path');
if (count($paths) !== 1) {
- throw new Exception('Specify exactly one path!');
+ throw new Exception(pht('Specify exactly one path!'));
}
$path = Filesystem::resolvePath(head($paths));
@@ -86,7 +86,7 @@
$uses = $root->selectDescendantsOfType('n_USE');
foreach ($namespaces as $namespace) {
phutil_fail_on_unsupported_feature(
- $namespace, $path, pht('namespace `use` statements'));
+ $namespace, $path, pht('namespace `%s` statements', 'use'));
}
$possible_traits = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
@@ -483,12 +483,14 @@
function phutil_fail_on_unsupported_feature(XHPASTNode $node, $file, $what) {
$line = $node->getLineNumber();
- $message = phutil_console_wrap(pht(
- '`arc liberate` has limited support for features introduced after PHP '.
- '5.2.3. This library uses an unsupported feature (%s) on line %d of %s',
- $what,
- $line,
- Filesystem::readablePath($file)));
+ $message = phutil_console_wrap(
+ pht(
+ '`%s` has limited support for features introduced after PHP 5.2.3. '.
+ 'This library uses an unsupported feature (%s) on line %d of %s.',
+ 'arc liberate',
+ $what,
+ $line,
+ Filesystem::readablePath($file)));
$result = array(
'error' => $message,
diff --git a/scripts/sandpit/harden_directory.php b/scripts/sandpit/harden_directory.php
--- a/scripts/sandpit/harden_directory.php
+++ b/scripts/sandpit/harden_directory.php
@@ -47,7 +47,7 @@
if (!is_dir($dir)) {
$ok = mkdir($dir, 0777, $recursive = true);
if (!$ok) {
- throw new Exception("Failed to make directory for '{$link}'!");
+ throw new Exception(pht("Failed to make directory for '%s'!", $link));
}
}
@@ -55,14 +55,14 @@
if ($type == 'link') {
$ok = symlink(readlink($soft.'/'.$path), $link);
if (!$ok) {
- throw new Exception("Failed to create symlink '{$link}'!");
+ throw new Exception(pht("Failed to create symlink '%s'!", $link));
}
continue;
}
if ($type === 'exec') {
// Multiple hardlinks share a single executable bit, so we need to keep
- // executable versions separate from nonexecutable versions.
+ // executable versions separate from non-executable versions.
$obj .= '.x';
}
@@ -89,23 +89,23 @@
if ($stat === false) {
$ok = mkdir(dirname($obj), 0777, $recursive = true);
if (!$ok) {
- throw new Exception("Failed to make directory for '{$obj}'.");
+ throw new Exception(pht("Failed to make directory for '%s'.", $obj));
}
$ok = copy($soft.'/'.$path, $obj);
if (!$ok) {
- throw new Exception("Failed to copy file '{$soft}/{$path}'!");
+ throw new Exception(pht("Failed to copy file '%s/%s'!", $soft, $path));
}
if ($type === 'exec') {
$ok = chmod($obj, 0755);
if (!$ok) {
- throw new Exception("Failed to chmod file '{$obj}'!");
+ throw new Exception(pht("Failed to chmod file '%s'!", $obj));
}
}
}
$ok = link($obj, $link);
if (!$ok) {
- throw new Exception("Failed to hardlink '{$obj}' to '{$link}'!");
+ throw new Exception(pht("Failed to hardlink '%s' to '%s'!", $obj, $link));
}
}
@@ -133,7 +133,7 @@
$matches = null;
$regexp = '/^(\d{6}) (\w+) ([a-z0-9]{40})\t(.*)$/';
if (!preg_match($regexp, $line, $matches)) {
- throw new Exception("Unable to parse line '{$line}'!");
+ throw new Exception(pht("Unable to parse line '%s'!", $line));
}
$flag = $matches[1];
$type = $matches[2];
@@ -149,7 +149,7 @@
$mask = (int)base_convert($flag, 8, 10);
$type = 'file';
if ($mask & 0111) {
- echo "EXEC: {$file}\n";
+ echo pht('EXEC: %s', $file)."\n";
$type = 'exec';
} else if (($mask & 0120000) === 0120000) {
$type = 'link';
diff --git a/scripts/test/http.php b/scripts/test/http.php
--- a/scripts/test/http.php
+++ b/scripts/test/http.php
@@ -21,7 +21,7 @@
$uri = $args->getArg('url');
if (count($uri) !== 1) {
throw new PhutilArgumentUsageException(
- 'Specify exactly one URL to retrieve.');
+ pht('Specify exactly one URL to retrieve.'));
}
$uri = head($uri);
diff --git a/scripts/test/interactive_editor.php b/scripts/test/interactive_editor.php
--- a/scripts/test/interactive_editor.php
+++ b/scripts/test/interactive_editor.php
@@ -4,7 +4,7 @@
require_once dirname(__FILE__).'/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('test InteractiveEditor class');
+$args->setTagline(pht('test %s class', 'InteractiveEditor'));
$args->setSynopsis(<<<EOHELP
**interactive_editor.php** [__options__]
Edit some content via the InteractiveEditor class. This script
@@ -18,18 +18,18 @@
array(
'name' => 'fallback',
'param' => 'editor',
- 'help' => 'Set the fallback editor.',
+ 'help' => pht('Set the fallback editor.'),
),
array(
'name' => 'line',
'short' => 'l',
'param' => 'number',
- 'help' => 'Open at line number __number__.',
+ 'help' => pht('Open at line number __number__.'),
),
array(
'name' => 'name',
'param' => 'filename',
- 'help' => 'Set edited file name.',
+ 'help' => pht('Set edited file name.'),
),
));
@@ -38,9 +38,7 @@
}
$editor = new PhutilInteractiveEditor(
- "The wizard quickly\n".
- "jinxed the gnomes\n".
- "before they vaporized.");
+ pht("The wizard quickly\njinxed the gnomes\nbefore they vaporized."));
$name = $args->getArg('name');
if ($name) {
@@ -58,4 +56,4 @@
}
$result = $editor->editInteractively();
-echo "Edited Text:\n{$result}\n";
+echo pht('Edited Text:')."\n{$result}\n";
diff --git a/scripts/test/lipsum.php b/scripts/test/lipsum.php
--- a/scripts/test/lipsum.php
+++ b/scripts/test/lipsum.php
@@ -4,7 +4,7 @@
require_once dirname(__FILE__).'/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('test context-free grammars');
+$args->setTagline(pht('test context-free grammars'));
$args->setSynopsis(<<<EOHELP
**lipsum.php** __class__
Generate output from a named context-free grammar.
@@ -34,8 +34,12 @@
if (empty($symbols[$class])) {
$available = implode(', ', array_keys($symbols));
throw new PhutilArgumentUsageException(
- "Class '{$class}' is not a defined, concrete subclass of ".
- "PhutilContextFreeGrammar. Available classes are: {$available}");
+ pht(
+ "Class '%s' is not a defined, concrete subclass of %s. ".
+ "Available classes are: %s",
+ $class,
+ 'PhutilContextFreeGrammar',
+ $available));
}
$object = newv($class, array());
diff --git a/scripts/test/mime.php b/scripts/test/mime.php
--- a/scripts/test/mime.php
+++ b/scripts/test/mime.php
@@ -4,7 +4,7 @@
require_once dirname(__FILE__).'/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('test Filesystem::getMimeType()');
+$args->setTagline(pht('test %s', 'Filesystem::getMimeType()'));
$args->setSynopsis(<<<EOHELP
**mime.php** [__options__] __file__
Determine the mime type of a file.
@@ -16,7 +16,8 @@
array(
'name' => 'default',
'param' => 'mimetype',
- 'help' => 'Use __mimetype__ as default instead of builtin default.',
+ 'help' => pht(
+ 'Use __mimetype__ as default instead of built-in default.'),
),
array(
'name' => 'file',
diff --git a/scripts/test/progress_bar.php b/scripts/test/progress_bar.php
--- a/scripts/test/progress_bar.php
+++ b/scripts/test/progress_bar.php
@@ -6,20 +6,24 @@
$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();
-echo "PROGRESS BAR TEST SCRIPT\n\n";
-echo "This script is a test script for `PhutilConsoleProgressBar`. It will ".
- "draw some progress bars, and generally allow you to test bar behaviors ".
- "and changes.\n\n";
-
-echo "GENERAL NOTES\n\n";
-echo " - When run as `php -f progress_bar.php 2>&1 | more`, no progress bars ".
- "should be shown (stderr is not a tty).\n";
-echo " - When run in a narrow terminal, the bar should resize automatically ".
- "to fit the terminal.\n";
-echo " - When run with `--trace`, the bar should not be drawn.\n";
+echo pht(
+ "PROGRESS BAR TEST SCRIPT\n\n".
+ "This script is a test script for `%s`. It will draw some progress bars, ".
+ "and generally allow you to test bar behaviors and changes.",
+ 'PhutilConsoleProgressBar');
+echo "\n\n";
+echo pht(
+ "GENERAL NOTES\n\n".
+ " - When run as `%s`, no progress bars should be shown ".
+ "(stderr is not a tty).\n".
+ " - When run in a narrow terminal, the bar should resize automatically ".
+ "to fit the terminal.\n".
+ " - When run with `%s`, the bar should not be drawn.\n",
+ 'php -f progress_bar.php 2>&1 | more',
+ '--trace');
echo "\n\n";
-echo "STANDARD PROGRESS BAR\n";
+echo pht('STANDARD PROGRESS BAR')."\n";
$n = 80;
$bar = id(new PhutilConsoleProgressBar())
->setTotal($n);
@@ -29,14 +33,14 @@
}
$bar->done();
-echo "\n";
-echo "INTERRUPTED PROGRESS BAR\n";
-echo "This bar will be interrupted by an exception.\n";
-echo "It should clean itself up.\n";
+echo "\n".pht(
+ "INTERRUPTED PROGRESS BAR\n".
+ "This bar will be interrupted by an exception.\n".
+ "It should clean itself up.")."\n";
try {
run_interrupt_bar();
} catch (Exception $ex) {
- echo "Caught exception!\n";
+ echo pht('Caught exception!')."\n";
}
@@ -46,7 +50,7 @@
for ($ii = 0; $ii < 100; $ii++) {
if ($ii === 20) {
- throw new Exception('Boo!');
+ throw new Exception(pht('Boo!'));
}
$bar->update(1);
usleep(10000);
diff --git a/scripts/test/prompt.php b/scripts/test/prompt.php
--- a/scripts/test/prompt.php
+++ b/scripts/test/prompt.php
@@ -4,7 +4,7 @@
require_once dirname(__FILE__).'/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('test console prompting');
+$args->setTagline(pht('test console prompting'));
$args->setSynopsis(<<<EOHELP
**prompt.php** __options__
Test console prompting.
@@ -17,13 +17,13 @@
'name' => 'history',
'param' => 'file',
'default' => '',
- 'help' => 'Use specified history __file__.',
+ 'help' => pht('Use specified history __file__.'),
),
array(
'name' => 'prompt',
'param' => 'text',
'default' => 'Enter some text:',
- 'help' => 'Change the prompt text to __text__.',
+ 'help' => pht('Change the prompt text to __text__.'),
),
));
@@ -32,4 +32,4 @@
$args->getArg('history'));
$console = PhutilConsole::getConsole();
-$console->writeOut("Input is: %s\n", $result);
+$console->writeOut("%s\n", pht('Input is: %s', $result));
diff --git a/scripts/test/service_profiler.php b/scripts/test/service_profiler.php
--- a/scripts/test/service_profiler.php
+++ b/scripts/test/service_profiler.php
@@ -11,5 +11,5 @@
exec_manual('sleep %d', 1);
phutil_passthru('cat');
-echo "\n\nSERVICE CALL LOG\n";
+echo "\n\n".pht('SERVICE CALL LOG')."\n";
var_dump(PhutilServiceProfiler::getInstance()->getServiceCallLog());
diff --git a/scripts/utils/directory_fixture.php b/scripts/utils/directory_fixture.php
--- a/scripts/utils/directory_fixture.php
+++ b/scripts/utils/directory_fixture.php
@@ -4,7 +4,7 @@
require_once dirname(__FILE__).'/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('edit directory fixtures');
+$args->setTagline(pht('edit directory fixtures'));
$args->setSynopsis(<<<EOHELP
**directory_fixture.php** __file__ --create
Create a new directory fixture.
@@ -44,15 +44,19 @@
if ($is_create) {
if (Filesystem::pathExists($file)) {
throw new PhutilArgumentUsageException(
- pht('File "%s" already exists, so you can not --create it.', $file));
+ pht(
+ 'File "%s" already exists, so you can not %s it.',
+ $file,
+ '--create'));
}
$fixture = PhutilDirectoryFixture::newEmptyFixture();
} else {
if (!Filesystem::pathExists($file)) {
throw new PhutilArgumentUsageException(
pht(
- 'File "%s" does not exist! Use --create to create a new fixture.',
- $file));
+ 'File "%s" does not exist! Use %s to create a new fixture.',
+ $file,
+ '--create'));
}
$fixture = PhutilDirectoryFixture::newFromArchive($file);
}
diff --git a/scripts/utils/lock.php b/scripts/utils/lock.php
--- a/scripts/utils/lock.php
+++ b/scripts/utils/lock.php
@@ -4,7 +4,7 @@
require_once dirname(__FILE__).'/../__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('acquire and hold a lockfile');
+$args->setTagline(pht('acquire and hold a lockfile'));
$args->setSynopsis(<<<EOHELP
**lock.php** __file__ [__options__]
Acquire a lockfile and hold it until told to unlock it.
@@ -16,16 +16,16 @@
$args->parse(array(
array(
'name' => 'test',
- 'help' => 'Instead of holding the lock, release it and exit.',
+ 'help' => pht('Instead of holding the lock, release it and exit.'),
),
array(
'name' => 'hold',
- 'help' => 'Hold indefinitely without prompting.',
+ 'help' => pht('Hold indefinitely without prompting.'),
),
array(
'name' => 'wait',
'param' => 'n',
- 'help' => 'Block for up to __n__ seconds waiting for the lock.',
+ 'help' => pht('Block for up to __n__ seconds waiting for the lock.'),
'default' => 0,
),
array(
@@ -42,19 +42,24 @@
$file = head($file);
$console = PhutilConsole::getConsole();
-$console->writeOut("This process has PID %d. Acquiring lock...\n", getmypid());
+$console->writeOut(
+ "%s\n",
+ pht('This process has PID %d. Acquiring lock...', getmypid()));
$lock = PhutilFileLock::newForPath($file);
try {
$lock->lock($args->getArg('wait'));
} catch (PhutilFileLockException $ex) {
- $console->writeOut("**UNABLE TO ACQUIRE LOCK:** Lock is already held.\n");
+ $console->writeOut(
+ "**%s** %s\n",
+ pht('UNABLE TO ACQUIRE LOCK:'),
+ pht('Lock is already held.'));
exit(1);
}
// NOTE: This string is magic, the unit tests look for it.
-$console->writeOut("LOCK ACQUIRED\n");
+$console->writeOut("%s\n", pht('LOCK ACQUIRED'));
if ($args->getArg('test')) {
$lock->unlock();
exit(0);
@@ -66,12 +71,12 @@
}
}
-while (!$console->confirm('Release lock?')) {
+while (!$console->confirm(pht('Release lock?'))) {
// Keep asking until they say yes.
}
-$console->writeOut("Unlocking...\n");
+$console->writeOut("%s\n", pht('Unlocking...'));
$lock->unlock();
-$console->writeOut("Done.\n");
+$console->writeOut("%s\n", pht('Done.'));
exit(0);
diff --git a/scripts/utils/utf8.php b/scripts/utils/utf8.php
--- a/scripts/utils/utf8.php
+++ b/scripts/utils/utf8.php
@@ -4,7 +4,7 @@
require_once dirname(dirname(__FILE__)).'/__init_script__.php';
$args = new PhutilArgumentParser($argv);
-$args->setTagline('utf8 charset test script');
+$args->setTagline(pht('utf8 charset test script'));
$args->setSynopsis(<<<EOHELP
**utf8.php** [-C n] __file__ ...
Show regions in files which are not valid UTF-8. With "-C n",
@@ -30,15 +30,16 @@
'short' => 'C',
'param' => 'lines',
'default' => 3,
- 'help' => 'Show __lines__ lines of context instead of the default 3.',
+ 'help' => pht(
+ 'Show __lines__ lines of context instead of the default 3.'),
'conflicts' => array(
- 'test' => 'with --test, context is not shown.',
+ 'test' => pht('with %s, context is not shown.', '--test'),
),
),
array(
'name' => 'test',
'short' => 't',
- 'help' => 'Print file names containing invalid UTF-8 to stdout.',
+ 'help' => pht('Print file names containing invalid UTF-8 to stdout.'),
),
array(
'name' => 'files',
@@ -95,11 +96,11 @@
$data = read($file);
$ok = phutil_is_utf8($data);
if ($ok) {
- echo 'OKAY';
+ echo pht('OKAY');
} else {
- echo 'FAIL';
+ echo pht('FAIL');
}
- echo " ".name($file)."\n";
+ echo ' '.name($file)."\n";
if (!$ok) {
$lines = explode("\n", $data);
diff --git a/src/auth/PhutilOAuth1AuthAdapter.php b/src/auth/PhutilOAuth1AuthAdapter.php
--- a/src/auth/PhutilOAuth1AuthAdapter.php
+++ b/src/auth/PhutilOAuth1AuthAdapter.php
@@ -101,7 +101,10 @@
if (strlen($consumer_key)) {
$future->setConsumerKey($consumer_key);
} else {
- throw new Exception('setConsumerKey() is required!');
+ throw new Exception(
+ pht(
+ '%s is required!',
+ 'setConsumerKey()'));
}
$consumer_secret = $this->getConsumerSecret();
diff --git a/src/console/PhutilConsoleServer.php b/src/console/PhutilConsoleServer.php
--- a/src/console/PhutilConsoleServer.php
+++ b/src/console/PhutilConsoleServer.php
@@ -88,7 +88,9 @@
return call_user_func($this->handler, $message);
} else {
throw new Exception(
- "Received unknown console message of type '{$type}'.");
+ pht(
+ "Received unknown console message of type '%s'.",
+ $type));
}
}
diff --git a/src/daemon/PhutilDaemonOverseer.php b/src/daemon/PhutilDaemonOverseer.php
--- a/src/daemon/PhutilDaemonOverseer.php
+++ b/src/daemon/PhutilDaemonOverseer.php
@@ -29,7 +29,7 @@
PhutilServiceProfiler::getInstance()->enableDiscardMode();
$args = new PhutilArgumentParser($argv);
- $args->setTagline('daemon overseer');
+ $args->setTagline(pht('daemon overseer'));
$args->setSynopsis(<<<EOHELP
**launch_daemon.php** [__options__] __daemon__
Launch and oversee an instance of __daemon__.
diff --git a/src/future/aws/PhutilAWSException.php b/src/future/aws/PhutilAWSException.php
--- a/src/future/aws/PhutilAWSException.php
+++ b/src/future/aws/PhutilAWSException.php
@@ -16,10 +16,10 @@
$desc[] = pht('HTTP Status Code: %d', $http_status);
if ($this->requestID) {
- $desc[] = 'AWS Request ID: '.$this->requestID;
+ $desc[] = pht('AWS Request ID: %s', $this->requestID);
$errors = idx($params, 'Errors');
if ($errors) {
- $desc[] = 'AWS Errors:';
+ $desc[] = pht('AWS Errors:');
foreach ($errors as $error) {
list($code, $message) = $error;
$desc[] = " - {$code}: {$message}\n";
diff --git a/src/markup/__tests__/PhutilMarkupTestCase.php b/src/markup/__tests__/PhutilMarkupTestCase.php
--- a/src/markup/__tests__/PhutilMarkupTestCase.php
+++ b/src/markup/__tests__/PhutilMarkupTestCase.php
@@ -176,7 +176,7 @@
$this->assertEqual(
$expect,
$caught instanceof Exception,
- "Rejected href: {$href}");
+ pht('Rejected href: %s', $href));
}
}
}
diff --git a/src/parser/__tests__/PhutilJSONParserTestCase.php b/src/parser/__tests__/PhutilJSONParserTestCase.php
--- a/src/parser/__tests__/PhutilJSONParserTestCase.php
+++ b/src/parser/__tests__/PhutilJSONParserTestCase.php
@@ -37,7 +37,7 @@
$this->assertEqual(
$expect,
$parser->parse($input),
- 'Parsing JSON: '.$input);
+ pht('Parsing JSON: %s', $input));
}
}
@@ -123,7 +123,7 @@
$this->assertEqual(
$expect,
$parser->parse($input),
- 'Parsing JSON: '.$input);
+ pht('Parsing JSON: %s', $input));
$parser->setAllowDuplicateKeys(false);
$caught = null;
diff --git a/src/phage/__tests__/PhageAgentTestCase.php b/src/phage/__tests__/PhageAgentTestCase.php
--- a/src/phage/__tests__/PhageAgentTestCase.php
+++ b/src/phage/__tests__/PhageAgentTestCase.php
@@ -31,7 +31,7 @@
'stdout' => "phage\n",
'stderr' => '',
),
- "'echo phage' for {$name}");
+ pht("'%s' for %s", 'echo phage', $name));
$agent->write(
array(
diff --git a/src/serviceprofiler/PhutilServiceProfiler.php b/src/serviceprofiler/PhutilServiceProfiler.php
--- a/src/serviceprofiler/PhutilServiceProfiler.php
+++ b/src/serviceprofiler/PhutilServiceProfiler.php
@@ -102,7 +102,7 @@
break;
case 'conduit':
if (isset($data['size'])) {
- $desc = $data['method'].'() <bytes = '.$data['size'].'>';
+ $desc = $data['method'].'() '.pht('<bytes = %d>', $data['size']);
} else {
$desc = $data['method'].'()';
}
@@ -113,14 +113,14 @@
case 'lint':
$desc = $data['linter'];
if (isset($data['paths'])) {
- $desc .= ' <paths = '.count($data['paths']).'>';
+ $desc .= ' '.pht('<paths = %d>', count($data['paths']));
}
break;
case 'lock':
$desc = $data['name'];
break;
case 'event':
- $desc = $data['kind'].' <listeners = '.$data['count'].'>';
+ $desc = $data['kind'].' '.pht('<listeners = %d>', $data['count']);
break;
case 'ldap':
$call = idx($data, 'call', '?');
@@ -146,7 +146,9 @@
break;
}
} else if ($is_end) {
- $desc = number_format((int)(1000000 * $data['duration'])).' us';
+ $desc = pht(
+ '%d us',
+ number_format((int)(1000000 * $data['duration'])));
}
$console = PhutilConsole::getConsole();
diff --git a/src/utils/__tests__/PhutilUTF8TestCase.php b/src/utils/__tests__/PhutilUTF8TestCase.php
--- a/src/utils/__tests__/PhutilUTF8TestCase.php
+++ b/src/utils/__tests__/PhutilUTF8TestCase.php
@@ -344,7 +344,7 @@
$this->assertEqual(
$expect,
phutil_utf8_hard_wrap($string, $width),
- "Wrapping of '".$string."'");
+ pht("Wrapping of '%s'", $string));
}
}
@@ -516,33 +516,93 @@
public function testUTF8BMP() {
$tests = array(
- '' => array(true, true, 'empty string'),
- 'a' => array(true, true, 'a'),
- "a\xCD\xA0\xCD\xA0" => array(true, true, 'a with combining'),
- "\xE2\x98\x83" => array(true, true, 'snowman'),
+ '' => array(
+ true,
+ true,
+ pht('empty string'),
+ ),
+ 'a' => array(
+ true,
+ true,
+ 'a',
+ ),
+ "a\xCD\xA0\xCD\xA0" => array(
+ true,
+ true,
+ pht('%s with combining', 'a'),
+ ),
+ "\xE2\x98\x83" => array(
+ true,
+ true,
+ pht('snowman'),
+ ),
// This is the last character in BMP, U+FFFF.
- "\xEF\xBF\xBF" => array(true, true, 'U+FFFF'),
+ "\xEF\xBF\xBF" => array(
+ true,
+ true,
+ 'U+FFFF',
+ ),
// This isn't valid.
- "\xEF\xBF\xC0" => array(false, false, 'Invalid, byte range.'),
+ "\xEF\xBF\xC0" => array(
+ false,
+ false,
+ pht('Invalid, byte range.'),
+ ),
// This is an invalid nonminimal representation.
- "\xF0\x81\x80\x80" => array(false, false, 'Nonminimal 4-byte characer.'),
+ "\xF0\x81\x80\x80" => array(
+ false,
+ false,
+ pht('Nonminimal 4-byte character.'),
+ ),
// This is the first character above BMP, U+10000.
- "\xF0\x90\x80\x80" => array(true, false, 'U+10000'),
- "\xF0\x9D\x84\x9E" => array(true, false, 'gclef'),
+ "\xF0\x90\x80\x80" => array(
+ true,
+ false,
+ 'U+10000',
+ ),
+ "\xF0\x9D\x84\x9E" => array(
+ true,
+ false,
+ 'gclef',
+ ),
- "musical \xF0\x9D\x84\x9E g-clef" => array(true, false, 'gclef text'),
- "\xF0\x9D\x84" => array(false, false, 'Invalid, truncated.'),
+ "musical \xF0\x9D\x84\x9E g-clef" => array(
+ true,
+ false,
+ pht('gclef text'),
+ ),
+ "\xF0\x9D\x84" => array(
+ false,
+ false,
+ pht('Invalid, truncated.'),
+ ),
- "\xE0\x80\x80" => array(false, false, 'Nonminimal 3-byte character.'),
+ "\xE0\x80\x80" => array(
+ false,
+ false,
+ pht('Nonminimal 3-byte character.'),
+ ),
// Partial BMP characters.
- "\xCD" => array(false, false, 'Partial 2-byte character.'),
- "\xE0\xA0" => array(false, false, 'Partial BMP 0xE0 character.'),
- "\xE2\x98" => array(false, false, 'Partial BMP cahracter.'),
+ "\xCD" => array(
+ false,
+ false,
+ pht('Partial 2-byte character.'),
+ ),
+ "\xE0\xA0" => array(
+ false,
+ false,
+ pht('Partial BMP 0xE0 character.'),
+ ),
+ "\xE2\x98" => array(
+ false,
+ false,
+ pht('Partial BMP cahracter.'),
+ ),
);
foreach ($tests as $input => $test) {
diff --git a/support/xhpast/generate_nodes.php b/support/xhpast/generate_nodes.php
--- a/support/xhpast/generate_nodes.php
+++ b/support/xhpast/generate_nodes.php
@@ -129,7 +129,7 @@
$hpp .= "#define {$node} {$value}\n";
}
file_put_contents('node_names.hpp', $hpp);
-echo "Wrote C++ definition.\n";
+echo pht('Wrote C++ definition.')."\n";
$at = '@';
$php =
@@ -143,4 +143,4 @@
$php .= " );\n";
$php .= "}\n";
file_put_contents('parser_nodes.php', $php);
-echo "Wrote PHP definition.\n";
+echo pht('Wrote PHP definition.')."\n";
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 25, 4:34 AM (19 h, 50 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7046788
Default Alt Text
D12876.id31012.diff (33 KB)
Attached To
Mode
D12876: Add some more translation strings
Attached
Detach File
Event Timeline
Log In to Comment