phtize all the things

Summary: `pht`ize a whole bunch of strings in rP.

Test Plan: Intense eyeballing.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: hach-que, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12797
This commit is contained in:
Joshua Spence
2015-05-22 17:27:56 +10:00
parent d3268aecc2
commit 36e2d02d6e
928 changed files with 5267 additions and 4239 deletions

View File

@@ -36,7 +36,7 @@ final class PhabricatorOAuthServer {
private function getUser() {
if (!$this->user) {
throw new Exception('You must setUser before you can getUser!');
throw new PhutilInvalidStateException('setUser');
}
return $this->user;
}
@@ -48,7 +48,7 @@ final class PhabricatorOAuthServer {
private function getClient() {
if (!$this->client) {
throw new Exception('You must setClient before you can getClient!');
throw new PhutilInvalidStateException('setClient');
}
return $this->client;
}
@@ -65,16 +65,16 @@ final class PhabricatorOAuthServer {
public function userHasAuthorizedClient(array $scope) {
$authorization = id(new PhabricatorOAuthClientAuthorization())->
loadOneWhere('userPHID = %s AND clientPHID = %s',
$this->getUser()->getPHID(),
$this->getClient()->getPHID());
loadOneWhere(
'userPHID = %s AND clientPHID = %s',
$this->getUser()->getPHID(),
$this->getClient()->getPHID());
if (empty($authorization)) {
return array(false, null);
}
if ($scope) {
$missing_scope = array_diff_key($scope,
$authorization->getScope());
$missing_scope = array_diff_key($scope, $authorization->getScope());
} else {
$missing_scope = false;
}
@@ -166,10 +166,10 @@ final class PhabricatorOAuthServer {
$must_be_used_by = $created_time + self::ACCESS_TOKEN_TIMEOUT;
$expired = time() > $must_be_used_by;
$authorization = id(new PhabricatorOAuthClientAuthorization())
->loadOneWhere(
'userPHID = %s AND clientPHID = %s',
$token->getUserPHID(),
$token->getClientPHID());
->loadOneWhere(
'userPHID = %s AND clientPHID = %s',
$token->getUserPHID(),
$token->getClientPHID());
if (!$authorization) {
return false;

View File

@@ -60,10 +60,10 @@ final class PhabricatorOAuthServerScope {
$label = null;
switch ($scope) {
case self::SCOPE_OFFLINE_ACCESS:
$label = 'Make access tokens granted to this client never expire.';
$label = pht('Make access tokens granted to this client never expire.');
break;
case self::SCOPE_WHOAMI:
$label = 'Read access to Conduit method user.whoami.';
$label = pht('Read access to Conduit method %s.', 'user.whoami');
break;
}

View File

@@ -18,7 +18,7 @@ final class PhabricatorOAuthServerTestCase
$this->assertEqual(
$expected,
$result,
"Validation of redirect URI '{$input}'");
pht("Validation of redirect URI '%s'", $input));
}
}
@@ -39,8 +39,10 @@ final class PhabricatorOAuthServerTestCase
$this->assertEqual(
$expected,
$server->validateSecondaryRedirectURI($uri, $primary_uri),
"Validation of redirect URI '{$input}' ".
"relative to '{$primary_uri}'");
pht(
"Validation of redirect URI '%s' relative to '%s'",
$input,
$primary_uri));
}
$primary_uri = new PhutilURI('http://www.google.com/?auth');
@@ -57,8 +59,10 @@ final class PhabricatorOAuthServerTestCase
$this->assertEqual(
$expected,
$server->validateSecondaryRedirectURI($uri, $primary_uri),
"Validation of secondary redirect URI '{$input}' ".
"relative to '{$primary_uri}'");
pht(
"Validation of secondary redirect URI '%s' relative to '%s'",
$input,
$primary_uri));
}
$primary_uri = new PhutilURI('https://secure.example.com/');
@@ -71,7 +75,7 @@ final class PhabricatorOAuthServerTestCase
$this->assertEqual(
$expected,
$server->validateSecondaryRedirectURI($uri, $primary_uri),
"Validation (https): {$input}");
pht('Validation (https): %s', $input));
}
$primary_uri = new PhutilURI('http://example.com/?z=2&y=3');
@@ -88,7 +92,7 @@ final class PhabricatorOAuthServerTestCase
$this->assertEqual(
$expected,
$server->validateSecondaryRedirectURI($uri, $primary_uri),
"Validation (params): {$input}");
pht('Validation (params): %s', $input));
}
}

View File

@@ -6,23 +6,19 @@ abstract class PhabricatorOAuthServerController
public function buildStandardPageResponse($view, array $data) {
$user = $this->getRequest()->getUser();
$page = $this->buildStandardPageView();
$page->setApplicationName('OAuth Server');
$page->setApplicationName(pht('OAuth Server'));
$page->setBaseURI('/oauthserver/');
$page->setTitle(idx($data, 'title'));
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/oauthserver/'));
$nav->addLabel('Clients');
$nav->addFilter('client/create',
'Create Client');
$nav->addLabel(pht('Clients'));
$nav->addFilter('client/create', pht('Create Client'));
foreach ($this->getExtraClientFilters() as $filter) {
$nav->addFilter($filter['url'],
$filter['label']);
$nav->addFilter($filter['url'], $filter['label']);
}
$nav->addFilter('client',
'My Clients');
$nav->selectFilter($this->getFilter(),
'clientauthorization');
$nav->addFilter('client', pht('My Clients'));
$nav->selectFilter($this->getFilter(), 'clientauthorization');
$nav->appendChild($view);

View File

@@ -26,25 +26,31 @@ final class PhabricatorOAuthServerTokenController
if ($grant_type != 'authorization_code') {
$response->setError('unsupported_grant_type');
$response->setErrorDescription(
'Only grant_type authorization_code is supported.');
pht(
'Only %s %s is supported.',
'grant_type',
'authorization_code'));
return $response;
}
if (!$code) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter code missing.');
$response->setErrorDescription(pht('Required parameter code missing.'));
return $response;
}
if (!$client_phid) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter client_id missing.');
pht(
'Required parameter %s missing.',
'client_id'));
return $response;
}
if (!$client_secret) {
$response->setError('invalid_request');
$response->setErrorDescription(
'Required parameter client_secret missing.');
pht(
'Required parameter %s missing.',
'client_secret'));
return $response;
}
// one giant try / catch around all the exciting database stuff so we
@@ -56,7 +62,9 @@ final class PhabricatorOAuthServerTokenController
if (!$auth_code) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Authorization code '.$code.' not found.');
pht(
'Authorization code %d not found.',
$code));
return $response;
}
@@ -70,25 +78,29 @@ final class PhabricatorOAuthServerTokenController
$redirect_uri != $auth_code_redirect_uri) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Redirect uri in request must exactly match redirect uri '.
'from authorization code.');
pht(
'Redirect URI in request must exactly match redirect URI '.
'from authorization code.'));
return $response;
}
} else if ($redirect_uri) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Redirect uri in request and no redirect uri in authorization '.
'code. The two must exactly match.');
pht(
'Redirect URI in request and no redirect URI in authorization '.
'code. The two must exactly match.'));
return $response;
}
$client = id(new PhabricatorOAuthServerClient())
->loadOneWhere('phid = %s',
$client_phid);
->loadOneWhere('phid = %s', $client_phid);
if (!$client) {
$response->setError('invalid_client');
$response->setErrorDescription(
'Client with client_id '.$client_phid.' not found.');
pht(
'Client with %s %d not found.',
'client_id',
$client_phid));
return $response;
}
$server->setClient($client);
@@ -99,7 +111,9 @@ final class PhabricatorOAuthServerTokenController
if (!$user) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'User with phid '.$user_phid.' not found.');
pht(
'User with PHID %d not found.',
$user_phid));
return $response;
}
$server->setUser($user);
@@ -107,12 +121,15 @@ final class PhabricatorOAuthServerTokenController
$test_code = new PhabricatorOAuthServerAuthorizationCode();
$test_code->setClientSecret($client_secret);
$test_code->setClientPHID($client_phid);
$is_good_code = $server->validateAuthorizationCode($auth_code,
$test_code);
$is_good_code = $server->validateAuthorizationCode(
$auth_code,
$test_code);
if (!$is_good_code) {
$response->setError('invalid_grant');
$response->setErrorDescription(
'Invalid authorization code '.$code.'.');
pht(
'Invalid authorization code %d.',
$code));
return $response;
}
@@ -129,8 +146,9 @@ final class PhabricatorOAuthServerTokenController
} catch (Exception $e) {
$response->setError('server_error');
$response->setErrorDescription(
'The authorization server encountered an unexpected condition '.
'which prevented it from fulfilling the request.');
pht(
'The authorization server encountered an unexpected condition '.
'which prevented it from fulfilling the request.'));
return $response;
}
}

View File

@@ -82,13 +82,13 @@ final class PhabricatorOAuthClientEditController
->setUser($viewer)
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Name')
->setLabel(pht('Name'))
->setName('name')
->setValue($client->getName())
->setError($e_name))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Redirect URI')
->setLabel(pht('Redirect URI'))
->setName('redirect_uri')
->setValue($client->getRedirectURI())
->setError($e_redirect))

View File

@@ -50,11 +50,11 @@ final class PhabricatorOAuthClientSecretController
if ($is_serious) {
$body = pht(
'The secret associated with this oauth application will be shown in '.
'The secret associated with this OAuth application will be shown in '.
'plain text on your screen.');
} else {
$body = pht(
'The secret associated with this oauth application will be shown in '.
'The secret associated with this OAuth application will be shown in '.
'plain text on your screen. Before continuing, wrap your arms around '.
'your monitor to create a human shield, keeping it safe from prying '.
'eyes. Protect company secrets!');

View File

@@ -16,8 +16,8 @@ final class PhabricatorOAuthServerAuthorizationsSettingsPanel
}
public function isEnabled() {
$app_name = 'PhabricatorOAuthServerApplication';
return PhabricatorApplication::isClassInstalled($app_name);
return PhabricatorApplication::isClassInstalled(
'PhabricatorOAuthServerApplication');
}
public function processRequest(AphrontRequest $request) {
@@ -108,8 +108,7 @@ final class PhabricatorOAuthServerAuthorizationsSettingsPanel
$table = new AphrontTableView($rows);
$table->setNoDataString(
pht(
"You haven't authorized any OAuth applications."));
pht("You haven't authorized any OAuth applications."));
$table->setRowClasses($rowc);
$table->setHeaders(