From 251a7b06022444f662725833a3ac632de6eae16f Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sat, 26 Jan 2013 16:17:44 -0800 Subject: [PATCH] Reasonable pht pass at auth. Summary: Spent some time going through auth stuff for pht's. Test Plan: Tested logging in, logging out, reseting password, using Github, creating a new account. I couldn't quite test everything so will double read the diff when I submit it. Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4671 --- .../controller/PhabricatorAuthController.php | 2 +- .../PhabricatorDisabledUserController.php | 7 +- .../PhabricatorEmailLoginController.php | 40 ++++++----- .../PhabricatorEmailTokenController.php | 12 ++-- .../PhabricatorLDAPLoginController.php | 29 ++++---- .../PhabricatorLDAPRegistrationController.php | 40 +++++------ .../PhabricatorLDAPUnlinkController.php | 8 +-- .../controller/PhabricatorLoginController.php | 71 ++++++++++--------- .../PhabricatorLoginValidateController.php | 10 +-- .../PhabricatorLogoutController.php | 6 +- .../PhabricatorMustVerifyEmailController.php | 29 ++++---- .../PhabricatorOAuthLoginController.php | 63 ++++++++-------- .../PhabricatorOAuthUnlinkController.php | 10 +-- ...atorOAuthDefaultRegistrationController.php | 42 +++++------ .../auth/view/PhabricatorOAuthFailureView.php | 4 +- 15 files changed, 199 insertions(+), 174 deletions(-) diff --git a/src/applications/auth/controller/PhabricatorAuthController.php b/src/applications/auth/controller/PhabricatorAuthController.php index 60dc5bcbc9..19094da148 100644 --- a/src/applications/auth/controller/PhabricatorAuthController.php +++ b/src/applications/auth/controller/PhabricatorAuthController.php @@ -5,7 +5,7 @@ abstract class PhabricatorAuthController extends PhabricatorController { public function buildStandardPageResponse($view, array $data) { $page = $this->buildStandardPageView(); - $page->setApplicationName('Login'); + $page->setApplicationName(pht('Login')); $page->setBaseURI('/login/'); $page->setTitle(idx($data, 'title')); $page->appendChild($view); diff --git a/src/applications/auth/controller/PhabricatorDisabledUserController.php b/src/applications/auth/controller/PhabricatorDisabledUserController.php index 08647187b5..dcd1e36abc 100644 --- a/src/applications/auth/controller/PhabricatorDisabledUserController.php +++ b/src/applications/auth/controller/PhabricatorDisabledUserController.php @@ -15,13 +15,14 @@ final class PhabricatorDisabledUserController } $failure_view = new AphrontRequestFailureView(); - $failure_view->setHeader('Account Disabled'); - $failure_view->appendChild('

Your account has been disabled.

'); + $failure_view->setHeader(pht('Account Disabled')); + $failure_view->appendChild( + '

'.pht('Your account has been disabled.').'

'); return $this->buildStandardPageResponse( $failure_view, array( - 'title' => 'Account Disabled', + 'title' => pht('Account Disabled'), )); } diff --git a/src/applications/auth/controller/PhabricatorEmailLoginController.php b/src/applications/auth/controller/PhabricatorEmailLoginController.php index bf142ea23e..e6cc6372df 100644 --- a/src/applications/auth/controller/PhabricatorEmailLoginController.php +++ b/src/applications/auth/controller/PhabricatorEmailLoginController.php @@ -22,18 +22,18 @@ final class PhabricatorEmailLoginController if ($request->isFormPost()) { $e_email = null; - $e_captcha = 'Again'; + $e_captcha = pht('Again'); $captcha_ok = AphrontFormRecaptchaControl::processCaptcha($request); if (!$captcha_ok) { - $errors[] = "Captcha response is incorrect, try again."; - $e_captcha = 'Invalid'; + $errors[] = pht("Captcha response is incorrect, try again."); + $e_captcha = pht('Invalid'); } $email = $request->getStr('email'); if (!strlen($email)) { - $errors[] = "You must provide an email address."; - $e_email = 'Required'; + $errors[] = pht("You must provide an email address."); + $e_email = pht('Required'); } if (!$errors) { @@ -53,8 +53,9 @@ final class PhabricatorEmailLoginController } if (!$target_user) { - $errors[] = "There is no account associated with that email address."; - $e_email = "Invalid"; + $errors[] = + pht("There is no account associated with that email address."); + $e_email = pht("Invalid"); } if (!$errors) { @@ -96,13 +97,15 @@ EOBODY; $mail->saveAndSend(); $view = new AphrontRequestFailureView(); - $view->setHeader('Check Your Email'); + $view->setHeader(pht('Check Your Email')); $view->appendChild( - '

An email has been sent with a link you can use to login.

'); + '

'.pht( + 'An email has been sent with a link you can use to login.' + ).'

'); return $this->buildStandardPageResponse( $view, array( - 'title' => 'Email Sent', + 'title' => pht('Email Sent'), )); } } @@ -115,38 +118,41 @@ EOBODY; ->setUser($request->getUser()) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Email') + ->setLabel(pht('Email')) ->setName('email') ->setValue($request->getStr('email')) ->setError($e_email)) ->appendChild( id(new AphrontFormRecaptchaControl()) - ->setLabel('Captcha') + ->setLabel(pht('Captcha')) ->setError($e_captcha)) ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Send Email')); + ->setValue(pht('Send Email'))); $error_view = null; if ($errors) { $error_view = new AphrontErrorView(); - $error_view->setTitle('Login Error'); + $error_view->setTitle(pht('Login Error')); $error_view->setErrors($errors); } $panel = new AphrontPanelView(); $panel->setWidth(AphrontPanelView::WIDTH_FORM); - $panel->appendChild('

Forgot Password / Email Login

'); + $panel->appendChild(' +

'.pht('Forgot Password / Email Login').'

'); $panel->appendChild($email_auth); + $panel->setNoBackground(); - return $this->buildStandardPageResponse( + return $this->buildApplicationPage( array( $error_view, $panel, ), array( - 'title' => 'Create New Account', + 'title' => pht('Forgot Password'), + 'device' => true, )); } diff --git a/src/applications/auth/controller/PhabricatorEmailTokenController.php b/src/applications/auth/controller/PhabricatorEmailTokenController.php index 0f2187ee31..855caa37af 100644 --- a/src/applications/auth/controller/PhabricatorEmailTokenController.php +++ b/src/applications/auth/controller/PhabricatorEmailTokenController.php @@ -49,21 +49,23 @@ final class PhabricatorEmailTokenController !$target_user->validateEmailToken($target_email, $token)) { $view = new AphrontRequestFailureView(); - $view->setHeader('Unable to Login'); + $view->setHeader(pht('Unable to Login')); $view->appendChild( - '

The authentication information in the link you clicked is '. + '

'.pht('The authentication information in the link you clicked is '. 'invalid or out of date. Make sure you are copy-and-pasting the '. 'entire link into your browser. You can try again, or request '. - 'a new email.

'); + 'a new email.').'

'); $view->appendChild( '
'. - 'Send Another Email'. + ''. + pht('Send Another Email'). + ''. '
'); return $this->buildStandardPageResponse( $view, array( - 'title' => 'Login Failure', + 'title' => pht('Login Failure'), )); } diff --git a/src/applications/auth/controller/PhabricatorLDAPLoginController.php b/src/applications/auth/controller/PhabricatorLDAPLoginController.php index 60595be4eb..4dafe831f7 100644 --- a/src/applications/auth/controller/PhabricatorLDAPLoginController.php +++ b/src/applications/auth/controller/PhabricatorLDAPLoginController.php @@ -42,11 +42,12 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController { $existing_ldap) { $dialog = new AphrontDialogView(); $dialog->setUser($current_user); - $dialog->setTitle('Already Linked to Another Account'); + $dialog->setTitle(pht('Already Linked to Another Account')); $dialog->appendChild( - '

The LDAP account you just authorized is already linked to '. - 'another Phabricator account. Before you can link it to a '. - 'different LDAP account, you must unlink the old account.

' + '

'.pht('The LDAP account you just authorized is already '. + 'linked toanother Phabricator account. Before you can link it '. + 'to a different LDAP account, you must unlink the old '. + 'account.').'

' ); $dialog->addCancelButton('/settings/panel/ldap/'); @@ -60,12 +61,14 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController { if (!$request->isDialogFormPost()) { $dialog = new AphrontDialogView(); $dialog->setUser($current_user); - $dialog->setTitle('Link LDAP Account'); + $dialog->setTitle(pht('Link LDAP Account')); $dialog->appendChild( - '

Link your LDAP account to your Phabricator account?

'); + '

'. + pht('Link your LDAP account to your Phabricator account?'). + '

'); $dialog->addHiddenInput('username', $request->getStr('username')); $dialog->addHiddenInput('password', $request->getStr('password')); - $dialog->addSubmitButton('Link Accounts'); + $dialog->addSubmitButton(pht('Link Accounts')); $dialog->addCancelButton('/settings/panel/ldap/'); return id(new AphrontDialogResponse())->setDialog($dialog); @@ -116,27 +119,27 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController { ->setAction('/ldap/login/') ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('LDAP username') + ->setLabel(pht('LDAP username')) ->setName('username') ->setValue($ldap_username)) ->appendChild( id(new AphrontFormPasswordControl()) - ->setLabel('Password') + ->setLabel(pht('Password')) ->setName('password')); $ldap_form ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Login')); + ->setValue(pht('Login'))); $panel = new AphrontPanelView(); $panel->setWidth(AphrontPanelView::WIDTH_FORM); - $panel->appendChild('

LDAP login

'); + $panel->appendChild('

'.pht('LDAP login').'

'); $panel->appendChild($ldap_form); if (isset($errors) && count($errors) > 0) { $error_view = new AphrontErrorView(); - $error_view->setTitle('Login Failed'); + $error_view->setTitle(pht('Login Failed')); $error_view->setErrors($errors); } @@ -146,7 +149,7 @@ final class PhabricatorLDAPLoginController extends PhabricatorAuthController { $panel, ), array( - 'title' => 'Login', + 'title' => pht('Login'), )); } diff --git a/src/applications/auth/controller/PhabricatorLDAPRegistrationController.php b/src/applications/auth/controller/PhabricatorLDAPRegistrationController.php index 1fde2ef450..e52eea2134 100644 --- a/src/applications/auth/controller/PhabricatorLDAPRegistrationController.php +++ b/src/applications/auth/controller/PhabricatorLDAPRegistrationController.php @@ -63,10 +63,10 @@ extends PhabricatorAuthController { $user->setUsername($request->getStr('username')); $username = $user->getUsername(); if (!strlen($user->getUsername())) { - $e_username = 'Required'; - $errors[] = 'Username is required.'; + $e_username = pht('Required'); + $errors[] = pht('Username is required.'); } else if (!PhabricatorUser::validateUsername($username)) { - $e_username = 'Invalid'; + $e_username = pht('Invalid'); $errors[] = PhabricatorUser::describeValidUsername(); } else { $e_username = null; @@ -75,8 +75,8 @@ extends PhabricatorAuthController { if (!$new_email) { $new_email = trim($request->getStr('email')); if (!$new_email) { - $e_email = 'Required'; - $errors[] = 'Email is required.'; + $e_email = pht('Required'); + $errors[] = pht('Email is required.'); } else { $e_email = null; } @@ -84,7 +84,7 @@ extends PhabricatorAuthController { if ($new_email) { if (!PhabricatorUserEmail::isAllowedAddress($new_email)) { - $e_email = 'Invalid'; + $e_email = pht('Invalid'); $errors[] = PhabricatorUserEmail::describeAllowedAddresses(); } } @@ -92,8 +92,8 @@ extends PhabricatorAuthController { if (!strlen($user->getRealName())) { $user->setRealName($request->getStr('realname')); if (!strlen($user->getRealName())) { - $e_realname = 'Required'; - $errors[] = 'Real name is required.'; + $e_realname = pht('Required'); + $errors[] = pht('Real name is required.'); } else { $e_realname = null; } @@ -137,11 +137,11 @@ extends PhabricatorAuthController { $new_email); if ($same_username) { - $e_username = 'Duplicate'; - $errors[] = 'That username or email is not unique.'; + $e_username = pht('Duplicate'); + $errors[] = pht('That username or email is not unique.'); } else if ($same_email) { - $e_email = 'Duplicate'; - $errors[] = 'That email is not unique.'; + $e_email = pht('Duplicate'); + $errors[] = pht('That email is not unique.'); } else { throw $exception; } @@ -153,7 +153,7 @@ extends PhabricatorAuthController { $error_view = null; if ($errors) { $error_view = new AphrontErrorView(); - $error_view->setTitle('Registration Failed'); + $error_view->setTitle(pht('Registration Failed')); $error_view->setErrors($errors); } @@ -169,20 +169,20 @@ extends PhabricatorAuthController { ->setAction($action_path) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Username') + ->setLabel(pht('Username')) ->setName('username') ->setValue($user->getUsername()) ->setError($e_username)); $form->appendChild( id(new AphrontFormPasswordControl()) - ->setLabel('Password') + ->setLabel(pht('Password')) ->setName('password')); if ($show_email_input) { $form->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Email') + ->setLabel(pht('Email')) ->setName('email') ->setValue($request->getStr('email')) ->setError($e_email)); @@ -191,7 +191,7 @@ extends PhabricatorAuthController { if ($provider->retrieveUserRealName() === null) { $form->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Real Name') + ->setLabel(pht('Real Name')) ->setName('realname') ->setValue($request->getStr('realname')) ->setError($e_realname)); @@ -200,10 +200,10 @@ extends PhabricatorAuthController { $form ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Create Account')); + ->setValue(pht('Create Account'))); $panel = new AphrontPanelView(); - $panel->setHeader('Create New Account'); + $panel->setHeader(pht('Create New Account')); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->appendChild($form); @@ -213,7 +213,7 @@ extends PhabricatorAuthController { $panel, ), array( - 'title' => 'Create New Account', + 'title' => pht('Create New Account'), )); } diff --git a/src/applications/auth/controller/PhabricatorLDAPUnlinkController.php b/src/applications/auth/controller/PhabricatorLDAPUnlinkController.php index 180c20ce73..44cad5a398 100644 --- a/src/applications/auth/controller/PhabricatorLDAPUnlinkController.php +++ b/src/applications/auth/controller/PhabricatorLDAPUnlinkController.php @@ -17,11 +17,11 @@ final class PhabricatorLDAPUnlinkController extends PhabricatorAuthController { if (!$request->isDialogFormPost()) { $dialog = new AphrontDialogView(); $dialog->setUser($user); - $dialog->setTitle('Really unlink account?'); + $dialog->setTitle(pht('Really unlink account?')); $dialog->appendChild( - '

You will not be able to login using this account '. - 'once you unlink it. Continue?

'); - $dialog->addSubmitButton('Unlink Account'); + '

'.pht('You will not be able to login using this account '. + 'once you unlink it. Continue?').'

'); + $dialog->addSubmitButton(pht('Unlink Account')); $dialog->addCancelButton('/settings/panel/ldap/'); return id(new AphrontDialogResponse())->setDialog($dialog); diff --git a/src/applications/auth/controller/PhabricatorLoginController.php b/src/applications/auth/controller/PhabricatorLoginController.php index 6bc87c5aab..c4bda38a77 100644 --- a/src/applications/auth/controller/PhabricatorLoginController.php +++ b/src/applications/auth/controller/PhabricatorLoginController.php @@ -28,10 +28,10 @@ final class PhabricatorLoginController $dialog = new AphrontDialogView(); $dialog->setUser($user); - $dialog->setTitle('Login Required'); - $dialog->appendChild('

You must login to continue.

'); - $dialog->addSubmitButton('Login'); - $dialog->addCancelButton('/', 'Cancel'); + $dialog->setTitle(pht('Login Required')); + $dialog->appendChild('

'.pht('You must login to continue.').'

'); + $dialog->addSubmitButton(pht('Login')); + $dialog->addCancelButton('/', pht('Cancel')); return id(new AphrontDialogResponse())->setDialog($dialog); } @@ -62,10 +62,10 @@ final class PhabricatorLoginController $request->clearCookie('phsid'); $error_view = new AphrontErrorView(); - $error_view->setTitle('Invalid Session'); + $error_view->setTitle(pht('Invalid Session')); $error_view->setErrors(array( - "Your login session is invalid. Try logging in again. If that ". - "doesn't work, clear your browser cookies." + pht("Your login session is invalid. Try logging in again. If that ". + "doesn't work, clear your browser cookies.") )); } @@ -100,12 +100,12 @@ final class PhabricatorLoginController $require_captcha = true; if (!AphrontFormRecaptchaControl::processCaptcha($request)) { if (AphrontFormRecaptchaControl::hasCaptchaResponse($request)) { - $e_captcha = 'Invalid'; - $errors[] = 'CAPTCHA was not entered correctly.'; + $e_captcha = pht('Invalid'); + $errors[] = pht('CAPTCHA was not entered correctly.'); } else { - $e_captcha = 'Required'; - $errors[] = 'Too many login failures recently. You must '. - 'submit a CAPTCHA with your login request.'; + $e_captcha = pht('Required'); + $errors[] = pht('Too many login failures recently. You must '. + 'submit a CAPTCHA with your login request.'); } } } @@ -128,7 +128,7 @@ final class PhabricatorLoginController $envelope = new PhutilOpaqueEnvelope($request->getStr('password')); if (!$user || !$user->comparePassword($envelope)) { - $errors[] = 'Bad username/password.'; + $errors[] = pht('Bad username/password.'); } } @@ -160,7 +160,7 @@ final class PhabricatorLoginController if ($errors) { $error_view = new AphrontErrorView(); - $error_view->setTitle('Login Failed'); + $error_view->setTitle(pht('Login Failed')); $error_view->setErrors($errors); } @@ -170,16 +170,16 @@ final class PhabricatorLoginController ->setAction('/login/') ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Username/Email') + ->setLabel(pht('Username/Email')) ->setName('username_or_email') ->setValue($username_or_email)) ->appendChild( id(new AphrontFormPasswordControl()) - ->setLabel('Password') + ->setLabel(pht('Password')) ->setName('password') ->setCaption( ''. - 'Forgot your password? / Email Login')); + pht('Forgot your password? / Email Login').'')); if ($require_captcha) { $form->appendChild( @@ -190,7 +190,7 @@ final class PhabricatorLoginController $form ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Login')); + ->setValue(pht('Login'))); // $panel->setCreateButton('Register New Account', '/login/register/'); @@ -206,18 +206,18 @@ final class PhabricatorLoginController ->setAction('/ldap/login/') ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('LDAP username') + ->setLabel(pht('LDAP username')) ->setName('username') ->setValue($username_or_email)) ->appendChild( id(new AphrontFormPasswordControl()) - ->setLabel('Password') + ->setLabel(pht('Password')) ->setName('password')); $ldap_form ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Login')); + ->setValue(pht('Login'))); $forms['LDAP Login'] = $ldap_form; } @@ -243,18 +243,23 @@ final class PhabricatorLoginController // CSRF for logged-out users is vaugely tricky. if ($provider->isProviderRegistrationEnabled()) { - $title = "Login or Register with {$provider_name}"; - $body = 'Login or register for Phabricator using your '. - phutil_escape_html($provider_name).' account.'; - $button = "Login or Register with {$provider_name}"; + $title = pht("Login or Register with %s", + phutil_escape_html($provider_name)); + $body = pht('Login or register for Phabricator using your %s account.', + phutil_escape_html($provider_name)); + $button = pht("Login or Register with %s", + phutil_escape_html($provider_name)); } else { - $title = "Login with {$provider_name}"; - $body = 'Login to your existing Phabricator account using your '. - phutil_escape_html($provider_name).' account.

'. - 'You can not use '. - phutil_escape_html($provider_name).' to register a new '. - 'account.'; - $button = "Login with {$provider_name}"; + $title = pht("Login with %s", + phutil_escape_html($provider_name)); + $body = pht('Login to your existing Phabricator account using your '. + '%s account.', phutil_escape_html($provider_name)). + '

'. + ''. + pht('You can not use %s to register a new account.', + phutil_escape_html($provider_name)). + ''; + $button = pht("Log in with %s", phutil_escape_html($provider_name)); } $auth_form = new AphrontFormView(); @@ -298,7 +303,7 @@ final class PhabricatorLoginController $panel, ), array( - 'title' => 'Login', + 'title' => pht('Login'), 'device' => true )); } diff --git a/src/applications/auth/controller/PhabricatorLoginValidateController.php b/src/applications/auth/controller/PhabricatorLoginValidateController.php index 7ddc737011..9423199711 100644 --- a/src/applications/auth/controller/PhabricatorLoginValidateController.php +++ b/src/applications/auth/controller/PhabricatorLoginValidateController.php @@ -48,19 +48,19 @@ final class PhabricatorLoginValidateController $list = ''; $view = new AphrontRequestFailureView(); - $view->setHeader('Login Failed'); + $view->setHeader(pht('Login Failed')); $view->appendChild( - '

Login failed:

'. + '

'.pht('Login failed:').'

'. $list. - '

Clear your cookies and try again.

'); + '

'.pht('Clear your cookies and try again.').'

'); $view->appendChild( '
'. - 'Try Again'. + ''.pht('Try Again').''. '
'); return $this->buildStandardPageResponse( $view, array( - 'title' => 'Login Failed', + 'title' => pht('Login Failed'), )); } diff --git a/src/applications/auth/controller/PhabricatorLogoutController.php b/src/applications/auth/controller/PhabricatorLogoutController.php index fc3e9c8dc5..e2cc5410fa 100644 --- a/src/applications/auth/controller/PhabricatorLogoutController.php +++ b/src/applications/auth/controller/PhabricatorLogoutController.php @@ -45,9 +45,9 @@ final class PhabricatorLogoutController if ($user->getPHID()) { $dialog = id(new AphrontDialogView()) ->setUser($user) - ->setTitle('Log out of Phabricator?') - ->appendChild('

Are you sure you want to log out?

') - ->addSubmitButton('Log Out') + ->setTitle(pht('Log out of Phabricator?')) + ->appendChild('

'.pht('Are you sure you want to log out?').'

') + ->addSubmitButton(pht('Logout')) ->addCancelButton('/'); return id(new AphrontDialogResponse())->setDialog($dialog); diff --git a/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php b/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php index 319163112d..999dec88ee 100644 --- a/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php +++ b/src/applications/auth/controller/PhabricatorMustVerifyEmailController.php @@ -30,21 +30,25 @@ final class PhabricatorMustVerifyEmailController $email->sendVerificationEmail($user); $sent = new AphrontErrorView(); $sent->setSeverity(AphrontErrorView::SEVERITY_NOTICE); - $sent->setTitle('Email Sent'); - $sent->appendChild( - '

Another verification email was sent to '. - phutil_escape_html($email_address).'.

'); + $sent->setTitle(pht('Email Sent')); + $sent->appendChild('

'. + pht('Another verification email was sent to %s.', + phutil_escape_html($email_address)).'

'); } $error_view = new AphrontRequestFailureView(); - $error_view->setHeader('Check Your Email'); + $error_view->setHeader(pht('Check Your Email')); $error_view->appendChild( - '

You must verify your email address to login. You should have a new '. + '

'. + pht('You must verify your email address to login. You should have a new '. 'email message from Phabricator with verification instructions in your '. - 'inbox ('.phutil_escape_html($email_address).').

'); + 'inbox (%s).', phutil_escape_html($email_address)). + '

'); $error_view->appendChild( - '

If you did not receive an email, you can click the button below '. - 'to try sending another one.

'); + '

'. + pht('If you did not receive an email, you can click the button below '. + 'to try sending another one.'). + '

'); $error_view->appendChild( '
'. phabricator_render_form( @@ -57,17 +61,18 @@ final class PhabricatorMustVerifyEmailController 'button', array( ), - 'Send Another Email')). + pht('Send Another Email'))). '
'); - return $this->buildStandardPageResponse( + return $this->buildApplicationPage( array( $sent, $error_view, ), array( - 'title' => 'Must Verify Email', + 'title' => pht('Must Verify Email'), + 'device' => true )); } diff --git a/src/applications/auth/controller/PhabricatorOAuthLoginController.php b/src/applications/auth/controller/PhabricatorOAuthLoginController.php index 09be7d076e..2a6c9da6e1 100644 --- a/src/applications/auth/controller/PhabricatorOAuthLoginController.php +++ b/src/applications/auth/controller/PhabricatorOAuthLoginController.php @@ -68,15 +68,15 @@ final class PhabricatorOAuthLoginController if ($oauth_info->getUserID() != $current_user->getID()) { $dialog = new AphrontDialogView(); $dialog->setUser($current_user); - $dialog->setTitle('Already Linked to Another Account'); - $dialog->appendChild( - hsprintf( - '

The %s account you just authorized is already linked to '. + $dialog->setTitle(pht('Already Linked to Another Account')); + $dialog->appendChild('

'. + pht( + 'The %s account you just authorized is already linked to '. 'another Phabricator account. Before you can associate your %s '. 'account with this Phabriactor account, you must unlink it from '. 'the Phabricator account it is currently linked to.

', - $provider_name, - $provider_name)); + phutil_escape_html($provider_name), + phutil_escape_html($provider_name))).'

'; $dialog->addCancelButton($provider->getSettingsPanelURI()); return id(new AphrontDialogResponse())->setDialog($dialog); @@ -95,14 +95,15 @@ final class PhabricatorOAuthLoginController if ($existing_oauth) { $dialog = new AphrontDialogView(); $dialog->setUser($current_user); - $dialog->setTitle('Already Linked to an Account From This Provider'); - $dialog->appendChild( - hsprintf( - '

The account you are logged in with is already linked to a %s '. + $dialog->setTitle( + pht('Already Linked to an Account From This Provider')); + $dialog->appendChild('

'. + pht( + 'The account you are logged in with is already linked to a %s '. 'account. Before you can link it to a different %s account, you '. 'must unlink the old account.

', - $provider_name, - $provider_name)); + phutil_escape_html($provider_name), + phutil_escape_html($provider_name))).'

'; $dialog->addCancelButton($provider->getSettingsPanelURI()); return id(new AphrontDialogResponse())->setDialog($dialog); } @@ -110,11 +111,11 @@ final class PhabricatorOAuthLoginController if (!$request->isDialogFormPost()) { $dialog = new AphrontDialogView(); $dialog->setUser($current_user); - $dialog->setTitle('Link '.$provider_name.' Account'); + $dialog->setTitle(pht('Link %s Account', $provider_name)); $dialog->appendChild( - hsprintf( + pht( '

Link your %s account to your Phabricator account?

', - $provider_name)); + phutil_escape_html($provider_name))); $dialog->addHiddenInput('confirm_token', $provider->getAccessToken()); $dialog->addHiddenInput('expires', $oauth_info->getTokenExpires()); $dialog->addHiddenInput('state', $this->oauthState); @@ -168,14 +169,14 @@ final class PhabricatorOAuthLoginController if ($known_email) { $dialog = new AphrontDialogView(); $dialog->setUser($current_user); - $dialog->setTitle('Already Linked to Another Account'); - $dialog->appendChild( - hsprintf( - '

The %s account you just authorized has an email address which '. + $dialog->setTitle(pht('Already Linked to Another Account')); + $dialog->appendChild('

'. + pht( + 'The %s account you just authorized has an email address which '. 'is already in use by another Phabricator account. To link the '. 'accounts, log in to your Phabricator account and then go to '. - 'Settings.

', - $provider_name)); + 'Settings.', + phutil_escape_html($provider_name))).'

'; $user = id(new PhabricatorUser()) ->loadOneWhere('phid = %s', $known_email->getUserPHID()); @@ -189,9 +190,9 @@ final class PhabricatorOAuthLoginController ->getProviderName(); } $dialog->appendChild( - hsprintf( + pht( '

The account is associated with: %s.

', - implode(', ', $providers))); + implode(', ', phutil_escape_html($providers)))); } $dialog->addCancelButton('/login/'); @@ -203,14 +204,14 @@ final class PhabricatorOAuthLoginController if (!$provider->isProviderRegistrationEnabled()) { $dialog = new AphrontDialogView(); $dialog->setUser($current_user); - $dialog->setTitle('No Account Registration With '.$provider_name); - $dialog->appendChild( - hsprintf( - '

You can not register a new account using %s; you can only use '. + $dialog->setTitle(pht('No Account Registration with %s', $provider_name)); + $dialog->appendChild('

'. + pht( + 'You can not register a new account using %s; you can only use '. 'your %s account to log into an existing Phabricator account which '. - 'you have registered through other means.

', - $provider_name, - $provider_name)); + 'you have registered through other means.', + phutil_escape_html($provider_name), + phutil_escape_html($provider_name))).'

'; $dialog->addCancelButton('/login/'); return id(new AphrontDialogResponse())->setDialog($dialog); @@ -242,7 +243,7 @@ final class PhabricatorOAuthLoginController return $this->buildStandardPageResponse( $view, array( - 'title' => $provider_name.' Auth Failed', + 'title' => pht('Auth Failed'), )); } diff --git a/src/applications/auth/controller/PhabricatorOAuthUnlinkController.php b/src/applications/auth/controller/PhabricatorOAuthUnlinkController.php index 816dae4bba..bff01b251b 100644 --- a/src/applications/auth/controller/PhabricatorOAuthUnlinkController.php +++ b/src/applications/auth/controller/PhabricatorOAuthUnlinkController.php @@ -16,7 +16,7 @@ final class PhabricatorOAuthUnlinkController extends PhabricatorAuthController { if ($provider->isProviderLinkPermanent()) { throw new Exception( - "You may not unlink accounts from this OAuth provider."); + pht("You may not unlink accounts from this OAuth provider.")); } $provider_key = $provider->getProviderKey(); @@ -33,11 +33,11 @@ final class PhabricatorOAuthUnlinkController extends PhabricatorAuthController { if (!$request->isDialogFormPost()) { $dialog = new AphrontDialogView(); $dialog->setUser($user); - $dialog->setTitle('Really unlink account?'); + $dialog->setTitle(pht('Really unlink account?')); $dialog->appendChild( - '

You will not be able to login using this account '. - 'once you unlink it. Continue?

'); - $dialog->addSubmitButton('Unlink Account'); + '

'.pht('You will not be able to login using this account '. + 'once you unlink it. Continue?').'

'); + $dialog->addSubmitButton(pht('Unlink Account')); $dialog->addCancelButton($provider->getSettingsPanelURI()); return id(new AphrontDialogResponse())->setDialog($dialog); diff --git a/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php b/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php index a88c27fd91..6b81024bf7 100644 --- a/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php +++ b/src/applications/auth/controller/oauthregistration/PhabricatorOAuthDefaultRegistrationController.php @@ -45,10 +45,10 @@ final class PhabricatorOAuthDefaultRegistrationController $user->setUsername($request->getStr('username')); $username = $user->getUsername(); if (!strlen($user->getUsername())) { - $e_username = 'Required'; - $errors[] = 'Username is required.'; + $e_username = pht('Required'); + $errors[] = pht('Username is required.'); } else if (!PhabricatorUser::validateUsername($username)) { - $e_username = 'Invalid'; + $e_username = pht('Invalid'); $errors[] = PhabricatorUser::describeValidUsername(); } else { $e_username = null; @@ -57,8 +57,8 @@ final class PhabricatorOAuthDefaultRegistrationController if (!$new_email) { $new_email = trim($request->getStr('email')); if (!$new_email) { - $e_email = 'Required'; - $errors[] = 'Email is required.'; + $e_email = pht('Required'); + $errors[] = pht('Email is required.'); } else { $e_email = null; } @@ -67,7 +67,7 @@ final class PhabricatorOAuthDefaultRegistrationController if ($new_email) { $email_ok = PhabricatorUserEmail::isAllowedAddress($new_email); if (!$email_ok) { - $e_email = 'Invalid'; + $e_email = pht('Invalid'); $errors[] = PhabricatorUserEmail::describeAllowedAddresses(); } } @@ -75,8 +75,8 @@ final class PhabricatorOAuthDefaultRegistrationController if (!strlen($user->getRealName())) { $user->setRealName($request->getStr('realname')); if (!strlen($user->getRealName())) { - $e_realname = 'Required'; - $errors[] = 'Real name is required.'; + $e_realname = pht('Required'); + $errors[] = pht('Real name is required.'); } else { $e_realname = null; } @@ -142,11 +142,11 @@ final class PhabricatorOAuthDefaultRegistrationController $new_email); if ($same_username) { - $e_username = 'Duplicate'; - $errors[] = 'That username or email is not unique.'; + $e_username = pht('Duplicate'); + $errors[] = pht('That username or email is not unique.'); } else if ($same_email) { - $e_email = 'Duplicate'; - $errors[] = 'That email is not unique.'; + $e_email = pht('Duplicate'); + $errors[] = pht('That email is not unique.'); } else { throw $exception; } @@ -157,7 +157,7 @@ final class PhabricatorOAuthDefaultRegistrationController $error_view = null; if ($errors) { $error_view = new AphrontErrorView(); - $error_view->setTitle('Registration Failed'); + $error_view->setTitle(pht('Registration Failed')); $error_view->setErrors($errors); } @@ -176,7 +176,7 @@ final class PhabricatorOAuthDefaultRegistrationController ->setAction($action_path) ->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Username') + ->setLabel(pht('Username')) ->setName('username') ->setValue($user->getUsername()) ->setError($e_username)); @@ -184,7 +184,7 @@ final class PhabricatorOAuthDefaultRegistrationController if ($show_email_input) { $form->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Email') + ->setLabel(pht('Email')) ->setName('email') ->setValue($request->getStr('email')) ->setCaption(PhabricatorUserEmail::describeAllowedAddresses()) @@ -194,7 +194,7 @@ final class PhabricatorOAuthDefaultRegistrationController if ($provider->retrieveUserRealName() === null) { $form->appendChild( id(new AphrontFormTextControl()) - ->setLabel('Real Name') + ->setLabel(pht('Real Name')) ->setName('realname') ->setValue($request->getStr('realname')) ->setError($e_realname)); @@ -203,20 +203,22 @@ final class PhabricatorOAuthDefaultRegistrationController $form ->appendChild( id(new AphrontFormSubmitControl()) - ->setValue('Create Account')); + ->setValue(pht('Create Account'))); $panel = new AphrontPanelView(); - $panel->setHeader('Create New Account'); + $panel->setHeader(pht('Create New Account')); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->appendChild($form); + $panel->setNoBackground(); - return $this->buildStandardPageResponse( + return $this->buildApplicationPage( array( $error_view, $panel, ), array( - 'title' => 'Create New Account', + 'title' => pht('Create New Account'), + 'device' => true )); } diff --git a/src/applications/auth/view/PhabricatorOAuthFailureView.php b/src/applications/auth/view/PhabricatorOAuthFailureView.php index 4853410dbd..b8fa2afd2f 100644 --- a/src/applications/auth/view/PhabricatorOAuthFailureView.php +++ b/src/applications/auth/view/PhabricatorOAuthFailureView.php @@ -29,7 +29,7 @@ final class PhabricatorOAuthFailureView extends AphrontView { $diagnose = null; $view = new AphrontRequestFailureView(); - $view->setHeader($provider_name.' Auth Failed'); + $view->setHeader(pht('%s Auth Failed', $provider_name)); if ($this->request) { $view->appendChild( hsprintf( @@ -79,7 +79,7 @@ final class PhabricatorOAuthFailureView extends AphrontView { $view->appendChild( '
'. $diagnose. - 'Continue'. + ''.pht('Continue').''. '
'); return $view->render();