diff --git a/src/daemon/PhutilDaemon.php b/src/daemon/PhutilDaemon.php --- a/src/daemon/PhutilDaemon.php +++ b/src/daemon/PhutilDaemon.php @@ -149,9 +149,9 @@ $this->emitOverseerMessage(self::MESSAGETYPE_DOWN, null); $this->log( pht( - 'Daemon was idle for more than %s seconds, scaling pool '. - 'down.', - $scale_down)); + 'Daemon was idle for more than %s second(s)s, '. + 'scaling pool down.', + new PhutilNumber($scale_down))); break; } } diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php --- a/src/filesystem/Filesystem.php +++ b/src/filesystem/Filesystem.php @@ -42,7 +42,7 @@ if ($data === false) { throw new FilesystemException( $path, - pht("Failed to read file `%s'.", $path)); + pht("Failed to read file '%s'.", $path)); } return $data; @@ -91,7 +91,7 @@ if (@file_put_contents($path, $data) === false) { throw new FilesystemException( $path, - pht("Failed to write file `%s'.", $path)); + pht("Failed to write file '%s'.", $path)); } } @@ -234,18 +234,18 @@ if (($fh = fopen($path, 'a')) === false) { throw new FilesystemException( $path, - pht("Failed to open file `%s'.", $path)); + pht("Failed to open file '%s'.", $path)); } $dlen = strlen($data); if (fwrite($fh, $data) !== $dlen) { throw new FilesystemException( $path, - pht("Failed to write %d bytes to `%s'.", $dlen, $path)); + pht("Failed to write %d bytes to '%s'.", $dlen, $path)); } if (!fflush($fh) || !fclose($fh)) { throw new FilesystemException( $path, - pht("Failed closing file `%s' after write.", $path)); + pht("Failed closing file '%s' after write.", $path)); } } @@ -349,7 +349,7 @@ $readable_umask = sprintf('%04o', $umask); throw new FilesystemException( $path, - pht("Failed to chmod `%s' to `%s'.", $path, $readable_umask)); + pht("Failed to chmod '%s' to '%s'.", $path, $readable_umask)); } } @@ -417,10 +417,10 @@ if (strlen($data) != $number_of_bytes) { throw new Exception( pht( - '%s returned an unexpected number of bytes (got %d, expected %d)!', + '%s returned an unexpected number of bytes (got %s, expected %s)!', 'openssl_random_pseudo_bytes()', - strlen($data), - $number_of_bytes)); + new PhutilNumber(strlen($data)), + new PhutilNumber($number_of_bytes))); } return $data; @@ -627,7 +627,7 @@ if (!mkdir($path, $umask)) { throw new FilesystemException( $path, - pht("Failed to create directory `%s'.", $path)); + pht("Failed to create directory '%s'.", $path)); } // Need to change permissions explicitly because mkdir does something @@ -717,7 +717,7 @@ if ($list === false) { throw new FilesystemException( $path, - pht("Unable to list contents of directory `%s'.", $path)); + pht("Unable to list contents of directory '%s'.", $path)); } foreach ($list as $k => $v) { @@ -1012,7 +1012,7 @@ if (!self::pathExists($path)) { throw new FilesystemException( $path, - pht("File system entity `%s' does not exist.", $path)); + pht("File system entity '%s' does not exist.", $path)); } } @@ -1029,7 +1029,7 @@ if (file_exists($path) || is_link($path)) { throw new FilesystemException( $path, - pht("Path `%s' already exists!", $path)); + pht("Path '%s' already exists!", $path)); } } @@ -1046,7 +1046,7 @@ if (!is_file($path)) { throw new FilesystemException( $path, - pht("Requested path `%s' is not a file.", $path)); + pht("Requested path '%s' is not a file.", $path)); } } @@ -1063,7 +1063,7 @@ if (!is_dir($path)) { throw new FilesystemException( $path, - pht("Requested path `%s' is not a directory.", $path)); + pht("Requested path '%s' is not a directory.", $path)); } } @@ -1080,7 +1080,7 @@ if (!is_writable($path)) { throw new FilesystemException( $path, - pht("Requested path `%s' is not writable.", $path)); + pht("Requested path '%s' is not writable.", $path)); } } @@ -1097,7 +1097,7 @@ if (!is_readable($path)) { throw new FilesystemException( $path, - pht("Path `%s' is not readable.", $path)); + pht("Path '%s' is not readable.", $path)); } } diff --git a/src/future/exec/CommandException.php b/src/future/exec/CommandException.php --- a/src/future/exec/CommandException.php +++ b/src/future/exec/CommandException.php @@ -61,7 +61,7 @@ $len = strlen($string); if ($len > $limit) { $cut = $len - $limit; - $suffix = pht('... (%s more bytes) ...', new PhutilNumber($cut)); + $suffix = pht('... (%s more byte(s)) ...', new PhutilNumber($cut)); if ($cut > strlen($suffix)) { $string = substr($string, 0, $limit).$suffix; } diff --git a/src/future/exec/ExecFuture.php b/src/future/exec/ExecFuture.php --- a/src/future/exec/ExecFuture.php +++ b/src/future/exec/ExecFuture.php @@ -737,7 +737,7 @@ if (!is_resource($proc)) { throw new Exception( pht( - 'Failed to %s: %s', + 'Failed to `%s`: %s', 'proc_open()', $err)); } diff --git a/src/future/oauth/PhutilOAuth1Future.php b/src/future/oauth/PhutilOAuth1Future.php --- a/src/future/oauth/PhutilOAuth1Future.php +++ b/src/future/oauth/PhutilOAuth1Future.php @@ -239,7 +239,7 @@ $cert = @openssl_pkey_get_private($this->privateKey->openEnvelope()); if (!$cert) { - throw new Exception(pht('%S failed!', 'openssl_pkey_get_private()')); + throw new Exception(pht('%s failed!', 'openssl_pkey_get_private()')); } $pkey = @openssl_get_privatekey($cert); diff --git a/src/moduleutils/PhutilLibraryMapBuilder.php b/src/moduleutils/PhutilLibraryMapBuilder.php --- a/src/moduleutils/PhutilLibraryMapBuilder.php +++ b/src/moduleutils/PhutilLibraryMapBuilder.php @@ -464,10 +464,12 @@ // Run the analyzer on any files which need analysis. if ($futures) { $limit = $this->subprocessLimit; - $count = number_format(count($futures)); $this->log( - pht('Analyzing %d files with %d subprocesses...', $count, $limit)); + pht( + 'Analyzing %s files with %s subprocess(es)...', + phutil_count($futures), + new PhutilNumber($limit))); $progress = new PhutilConsoleProgressBar(); if ($this->quiet) { diff --git a/src/parser/__tests__/PhutilJSONTestCase.php b/src/parser/__tests__/PhutilJSONTestCase.php --- a/src/parser/__tests__/PhutilJSONTestCase.php +++ b/src/parser/__tests__/PhutilJSONTestCase.php @@ -15,7 +15,7 @@ $this->assertEqual( $expect, $serializer->encodeFormatted(array('x' => array())), - pht('Empty arrays should serialize as %s, not %s.', '[]', '{}')); + pht('Empty arrays should serialize as `%s`, not `%s`.', '[]', '{}')); } } diff --git a/src/parser/xhpast/__tests__/PHPASTParserTestCase.php b/src/parser/xhpast/__tests__/PHPASTParserTestCase.php --- a/src/parser/xhpast/__tests__/PHPASTParserTestCase.php +++ b/src/parser/xhpast/__tests__/PHPASTParserTestCase.php @@ -33,9 +33,10 @@ if (!preg_match('/^#/', $head)) { throw new Exception( pht( - 'Expected first line of parser test file "%s" to begin with "#" '. + 'Expected first line of parser test file "%s" to begin with `%s` '. 'and specify test options.', - $name)); + $name, + '#')); } $head = preg_replace('/^#\s*/', '', $head); 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,8 @@ break; case 'conduit': if (isset($data['size'])) { - $desc = $data['method'].'() '.pht('', $data['size']); + $desc = $data['method'].'() '; + $desc .= pht('', new PhutilNumber($data['size'])); } else { $desc = $data['method'].'()'; } @@ -113,14 +114,15 @@ case 'lint': $desc = $data['linter']; if (isset($data['paths'])) { - $desc .= ' '.pht('', count($data['paths'])); + $desc .= ' '.pht('', phutil_count($data['paths'])); } break; case 'lock': $desc = $data['name']; break; case 'event': - $desc = $data['kind'].' '.pht('', $data['count']); + $desc = $data['kind'].' '; + $desc .= pht('', new PhutilNumber($data['count'])); break; case 'ldap': $call = idx($data, 'call', '?'); diff --git a/src/utils/utils.php b/src/utils/utils.php --- a/src/utils/utils.php +++ b/src/utils/utils.php @@ -742,7 +742,7 @@ if (!is_array($item)) { throw new InvalidArgumentException( pht( - 'Expected all items passed to %s to be arrays, but '. + 'Expected all items passed to `%s` to be arrays, but '. 'argument with key "%s" has type "%s".', __FUNCTION__.'()', $key, @@ -1130,7 +1130,7 @@ if (!phutil_is_utf8($key)) { $full_key = $full_key.phutil_utf8ize($key); return pht( - 'Dictionary key "%s" is not valid UTF8, and can not be JSON encoded.', + 'Dictionary key "%s" is not valid UTF8, and cannot be JSON encoded.', $full_key); } @@ -1152,7 +1152,7 @@ $display); } else { return pht( - 'Dictionary value at key "%s" is not valid UTF8, and can not be '. + 'Dictionary value at key "%s" is not valid UTF8, and cannot be '. 'JSON encoded: %s', $path, $display);