diff --git a/email_registration/email_registration.module b/email_registration/email_registration.module
index b6198903e..c84be79b7 100644
--- a/email_registration/email_registration.module
+++ b/email_registration/email_registration.module
@@ -177,7 +177,9 @@ function email_registration_user_login_validate($form, FormStateInterface $form_
     elseif (!$config->get('login_with_username')) {
       $user_input = $form_state->getUserInput();
       $query = isset($user_input['name']) ? ['name' => $user_input['name']] : [];
-      $form_state->setErrorByName('name', t('Unrecognized email address or password. <a href=":password">Forgot your password?</a>', [':password' => Url::fromRoute('user.pass', [], ['query' => $query])->toString()]));
+
+      $link = Link::fromTextAndUrl(t('Forgot your password?'), Url::fromRoute('user.pass', [], ['query' => $query]))->toString();
+      $form_state->setErrorByName('name', t('Unrecognized email address or password. :password', [':password' => $link]));
     }
   }
 }
diff --git a/email_registration/src/Plugin/Commerce/CheckoutPane/EmailRegistrationLogin.php b/email_registration/src/Plugin/Commerce/CheckoutPane/EmailRegistrationLogin.php
index 1bd226bfd..dac7d0e85 100644
--- a/email_registration/src/Plugin/Commerce/CheckoutPane/EmailRegistrationLogin.php
+++ b/email_registration/src/Plugin/Commerce/CheckoutPane/EmailRegistrationLogin.php
@@ -26,17 +26,17 @@ public function buildPaneForm(array $pane_form, FormStateInterface $form_state,

     $config = \Drupal::config('email_registration.settings');
     $login_with_username = $config->get('login_with_username');
-    $pane_form['returning_customer']['name']['#title'] = $login_with_username ? t('Email address or username') : t('Email address');
-    $pane_form['returning_customer']['name']['#description'] = $login_with_username ? t('Enter your email address or username.') : t('Enter your email address.');
+    $pane_form['returning_customer']['name']['#title'] = $login_with_username ? $this->t('Email address or username') : $this->t('Email address');
+    $pane_form['returning_customer']['name']['#description'] = $login_with_username ? $this->t('Enter your email address or username.') : $this->t('Enter your email address.');
     $pane_form['returning_customer']['name']['#element_validate'][] = 'email_registration_user_login_validate';
     $pane_form['returning_customer']['name']['#type'] = $login_with_username ? 'textfield' : 'email';
     $pane_form['returning_customer']['name']['#maxlength'] = Email::EMAIL_MAX_LENGTH;
-    $pane_form['returning_customer']['password']['#description'] = t('Enter the password that accompanies your email address.');
+    $pane_form['returning_customer']['password']['#description'] = $this->t('Enter the password that accompanies your email address.');
     $complete_form['#cache']['tags'][] = 'config:email_registration.settings';

     $pane_form['register']['name']['#type'] = 'value';
     $pane_form['register']['name']['#value'] = 'email_registration_' . user_password();
-    $pane_form['register']['mail']['#title'] = t('Email');
+    $pane_form['register']['mail']['#title'] = $this->t('Email');

     return $pane_form;
   }
@@ -66,10 +66,9 @@ public function validatePaneForm(array &$pane_form, FormStateInterface $form_sta
         elseif (!$config->get('login_with_username')) {
           $user_input = $form_state->getUserInput();
           $query = isset($user_input['email_registration_login']['returning_customer']['name']) ? ['name' => $user_input['email_registration_login']['returning_customer']['name']] : [];
-          $form_state->setError($pane_form['returning_customer'], t('Unrecognized email address or password. <a href=":password">Forgot your password?</a>', [
-            ':password' => Url::fromRoute('user.pass', [], ['query' => $query])
-              ->toString(),
-          ]));
+
+          $link = Link::fromTextAndUrl($this->t('Forgot your password?'), Url::fromRoute('user.pass', [], ['query' => $query]))->toString();
+          $form_state->setError($pane_form['returning_customer'], $this->t('Unrecognized email address or password. :password', [':password' => $link]));
           return;
         }
       }
@@ -77,8 +76,7 @@ public function validatePaneForm(array &$pane_form, FormStateInterface $form_sta
       $password = trim($values['returning_customer']['password']);
       // Generate the "reset password" url.
       $query = !empty($username) ? ['name' => $username] : [];
-      $password_url = Url::fromRoute('user.pass', [], ['query' => $query])
-        ->toString();
+      $password_url = Url::fromRoute('user.pass', [], ['query' => $query]);

       if (user_is_blocked($username)) {
         $form_state->setError($name_element, $this->t('The account with email address %mail has not been activated or is blocked.', ['%mail' => $mail]));
@@ -98,7 +96,8 @@ public function validatePaneForm(array &$pane_form, FormStateInterface $form_sta
       $uid = $this->userAuth->authenticate($username, $password);
       if (!$uid) {
         $this->credentialsCheckFlood->register($this->clientIp, $username);
-        $form_state->setError($name_element, $this->t('Unrecognized email address or password. <a href=":password">Forgot your password?</a>', [':url' => $password_url]));
+        $link = Link::fromTextAndUrl($this->t('Forgot your password?'), $password_url)->toString();
+        $form_state->setError($name_element, $this->t('Unrecognized email address or password. :password', [':password' => $link]));
       }
       $form_state->set('logged_in_uid', $uid);
     }
