diff --git a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php
index 6e63feee306b5ad5990c5cc9716dca611e5300e8..ccd88b412d2c75a4c7780d14519fba1bf24f76c6 100644
--- a/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php
+++ b/core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php
@@ -40,7 +40,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ?EntityIn
     $form_state->set('form_display_2', $form_display_2);
     $form['entity_2'] = [
       '#type' => 'details',
-      '#title' => t('Second entity'),
+      '#title' => $this->t('Second entity'),
       '#tree' => TRUE,
       '#parents' => ['entity_2'],
       '#weight' => 50,
@@ -60,7 +60,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ?EntityIn
 
     $form['save'] = [
       '#type' => 'submit',
-      '#value' => t('Save'),
+      '#value' => $this->t('Save'),
       '#weight' => 100,
     ];
 
diff --git a/core/modules/file/tests/file_test/src/Form/FileTestForm.php b/core/modules/file/tests/file_test/src/Form/FileTestForm.php
index f7164474bebc6f5ba9de4fd83c8b48a9a5b11c9c..d021a538f44c83ba6f826547b4c9433aeee7c4c2 100644
--- a/core/modules/file/tests/file_test/src/Form/FileTestForm.php
+++ b/core/modules/file/tests/file_test/src/Form/FileTestForm.php
@@ -8,12 +8,14 @@
 use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\Form\FormInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 
 /**
  * File test form class.
  */
 class FileTestForm implements FormInterface {
   use FileTestFormTrait;
+  use StringTranslationTrait;
 
   /**
    * {@inheritdoc}
@@ -31,7 +33,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
 
     $form['file_test_upload'] = [
       '#type' => 'file',
-      '#title' => t('Upload a file'),
+      '#title' => $this->t('Upload a file'),
     ];
 
     return $form;
@@ -83,13 +85,13 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
     $file = file_save_upload('file_test_upload', $validators, $destination, 0, static::fileExistsFromName($form_state->getValue('file_test_replace')));
     if ($file) {
       $form_state->setValue('file_test_upload', $file);
-      \Drupal::messenger()->addStatus(t('File @filepath was uploaded.', ['@filepath' => $file->getFileUri()]));
-      \Drupal::messenger()->addStatus(t('File name is @filename.', ['@filename' => $file->getFilename()]));
-      \Drupal::messenger()->addStatus(t('File MIME type is @mimetype.', ['@mimetype' => $file->getMimeType()]));
-      \Drupal::messenger()->addStatus(t('You WIN!'));
+      \Drupal::messenger()->addStatus($this->t('File @filepath was uploaded.', ['@filepath' => $file->getFileUri()]));
+      \Drupal::messenger()->addStatus($this->t('File name is @filename.', ['@filename' => $file->getFilename()]));
+      \Drupal::messenger()->addStatus($this->t('File MIME type is @mimetype.', ['@mimetype' => $file->getMimeType()]));
+      \Drupal::messenger()->addStatus($this->t('You WIN!'));
     }
     elseif ($file === FALSE) {
-      \Drupal::messenger()->addError(t('Epic upload FAIL!'));
+      \Drupal::messenger()->addError($this->t('Epic upload FAIL!'));
     }
   }
 
diff --git a/core/modules/settings_tray/tests/modules/settings_tray_test/src/Form/SettingsTrayFormAnnotationIsClassBlockForm.php b/core/modules/settings_tray/tests/modules/settings_tray_test/src/Form/SettingsTrayFormAnnotationIsClassBlockForm.php
index 1d18f6acf52c436bf009dfc5575302727cd44b97..e2992dad6218511ff8e29a449110c223f2725534 100644
--- a/core/modules/settings_tray/tests/modules/settings_tray_test/src/Form/SettingsTrayFormAnnotationIsClassBlockForm.php
+++ b/core/modules/settings_tray/tests/modules/settings_tray_test/src/Form/SettingsTrayFormAnnotationIsClassBlockForm.php
@@ -6,12 +6,15 @@
 
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Plugin\PluginFormBase;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 
 /**
  * @see \Drupal\settings_tray_test\Plugin\Block\SettingsTrayFormAnnotationIsClassBlock
  */
 class SettingsTrayFormAnnotationIsClassBlockForm extends PluginFormBase {
 
+  use StringTranslationTrait;
+
   /**
    * The block plugin.
    *
@@ -27,7 +30,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
 
     $form['some_setting'] = [
       '#type' => 'select',
-      '#title' => t('Some setting'),
+      '#title' => $this->t('Some setting'),
       '#options' => [
         'a' => 'A',
         'b' => 'B',
diff --git a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php
index 52f353833b06ccb5f04a0cf7f7aee59d52351f47..481ecc127c6a0ff895ca92791804f80592b217aa 100644
--- a/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php
+++ b/core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php
@@ -26,12 +26,12 @@ public function getFormId() {
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['test_value'] = [
-      '#title' => t('Test value'),
+      '#title' => $this->t('Test value'),
       '#type' => 'textfield',
     ];
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
 
     return $form;
diff --git a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
index 9b430bbb66a3614ea6c0367c473a2c0869ff57e8..4e1d86bf05a0794bc14f2a1fdb3d494890d9ddef 100644
--- a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
+++ b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
@@ -30,8 +30,8 @@ public function getFormId() {
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
     $header = [
-      'username' => ['data' => t('Username'), 'field' => 'u.name'],
-      'status' => ['data' => t('Status'), 'field' => 'u.status'],
+      'username' => ['data' => $this->t('Username'), 'field' => 'u.name'],
+      'status' => ['data' => $this->t('Status'), 'field' => 'u.status'],
     ];
 
     $query = Database::getConnection()->select('users_field_data', 'u');
@@ -59,7 +59,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       $options[$account->id()] = [
         'title' => ['data' => ['#title' => $account->getAccountName()]],
         'username' => $account->getAccountName(),
-        'status' => $account->isActive() ? t('active') : t('blocked'),
+        'status' => $account->isActive() ? $this->t('active') : $this->t('blocked'),
       ];
     }
 
@@ -67,7 +67,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#type' => 'tableselect',
       '#header' => $header,
       '#options' => $options,
-      '#empty' => t('No people available.'),
+      '#empty' => $this->t('No people available.'),
     ];
 
     return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php
index d3d50e9b637c0a1af8d9bb1316f3d588e9d1ecc7..7433b573606486f63d1af930f48a0afc3ed996fb 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxForm.php
@@ -84,7 +84,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
 
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
 
     return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php
index 6b1e642ec10248dddd84acf484ed36cdea5c5365..7ad0620124b20e213e7b1107fe5fc639bafd92ba 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxTypeJugglingForm.php
@@ -26,7 +26,7 @@ public function getFormId() {
    */
   public function buildForm(array $form, FormStateInterface $form_state, $default_value = NULL, $return_value = NULL) {
     $form['checkbox'] = [
-      '#title' => t('Checkbox'),
+      '#title' => $this->t('Checkbox'),
       '#type' => 'checkbox',
       '#return_value' => $return_value,
       '#default_value' => $default_value,
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
index 780c7ea7f06e74128a09e1db0858100fb57c97f6..d40097475e6275ecdd9c9d82a380cff673e7c34a 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
@@ -28,18 +28,18 @@ public function getFormId() {
   public function buildForm(array $form, FormStateInterface $form_state, $json = TRUE) {
     $form_state->set('json', $json);
     $form['checkbox_off'] = [
-      '#title' => t('Checkbox off'),
+      '#title' => $this->t('Checkbox off'),
       '#type' => 'checkboxes',
       '#options' => ['foo', 'bar', 'baz'],
     ];
     $form['checkbox_zero_default'] = [
-      '#title' => t('Zero default'),
+      '#title' => $this->t('Zero default'),
       '#type' => 'checkboxes',
       '#options' => ['foo', 'bar', 'baz'],
       '#default_value' => [0],
     ];
     $form['checkbox_string_zero_default'] = [
-      '#title' => t('Zero default (string)'),
+      '#title' => $this->t('Zero default (string)'),
       '#type' => 'checkboxes',
       '#options' => ['foo', 'bar', 'baz'],
       '#default_value' => ['0'],
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
index 5a23cc5aac86d3288ca8d649f96cea608ee2d19f..95338fa240367a04c135231126eb1d3123faa75d 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestClickedButtonForm.php
@@ -88,7 +88,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $first =
    */
   public function validateForm(array &$form, FormStateInterface $form_state) {
     if ($triggering_element = $form_state->getTriggeringElement()) {
-      $this->messenger()->addStatus(t('The clicked button is %name.', ['%name' => $triggering_element['#name']]));
+      $this->messenger()->addStatus($this->t('The clicked button is %name.', ['%name' => $triggering_element['#name']]));
     }
     else {
       $this->messenger()->addStatus('There is no clicked button.');
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php
index 2ada206e40f5c0872794bb7785e5345462769440..30317f64209bf9884ec3e709efde8278df1cfeea 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDisabledElementsForm.php
@@ -255,7 +255,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
 
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
 
     return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php
index debf2772a5740b46f5745f5b82fa23048dbd3860..8eb220c5b55fe0680e598860bab6f656bcc3c7ad 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestEmptySelectForm.php
@@ -27,7 +27,7 @@ public function getFormId() {
   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['empty_select'] = [
       '#type' => 'select',
-      '#title' => t('Empty Select'),
+      '#title' => $this->t('Empty Select'),
       '#multiple' => FALSE,
       '#options' => NULL,
     ];
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
index 0b579de00874ee74c345f27d91038e8582ebbea0..156b84f6438db4efa8a124c52ef87bdba8536412 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanAdvancedForm.php
@@ -28,13 +28,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     // Build an example form containing a managed file and a submit form element.
     $form['image'] = [
       '#type' => 'managed_file',
-      '#title' => t('Image'),
+      '#title' => $this->t('Image'),
       '#upload_location' => 'public://',
       '#default_value' => 0,
     ];
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
     return $form;
   }
@@ -44,7 +44,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
     $form_state->cleanValues();
-    print t('You WIN!');
+    print $this->t('You WIN!');
     exit;
   }
 
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php
index 8907153aac6287023ea150aa1331ed0f5e97bd95..cca51e49da092b93b95c9d911df0ba54ecfa8164 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestFormStateValuesCleanForm.php
@@ -29,11 +29,11 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     // Build an example form containing multiple submit and button elements; not
     // only on the top-level.
     $form = ['#tree' => TRUE];
-    $form['foo'] = ['#type' => 'submit', '#value' => t('Submit')];
-    $form['bar'] = ['#type' => 'submit', '#value' => t('Submit')];
+    $form['foo'] = ['#type' => 'submit', '#value' => $this->t('Submit')];
+    $form['bar'] = ['#type' => 'submit', '#value' => $this->t('Submit')];
     $form['beer'] = ['#type' => 'value', '#value' => 1000];
-    $form['baz']['foo'] = ['#type' => 'button', '#value' => t('Submit')];
-    $form['baz']['baz'] = ['#type' => 'submit', '#value' => t('Submit')];
+    $form['baz']['foo'] = ['#type' => 'button', '#value' => $this->t('Submit')];
+    $form['baz']['baz'] = ['#type' => 'submit', '#value' => $this->t('Submit')];
     $form['baz']['beer'] = ['#type' => 'value', '#value' => 2000];
 
     // Add an arbitrary element and manually set it to be cleaned.
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php
index 21f229a83470acadb277a59ffeac93680431d63e..b32bf75c88bf506038b389ea9ecc822421e350b2 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestInputForgeryForm.php
@@ -30,7 +30,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     // For testing that a user can't submit a value not matching one of the
     // allowed options.
     $form['checkboxes'] = [
-      '#title' => t('Checkboxes'),
+      '#title' => $this->t('Checkboxes'),
       '#type' => 'checkboxes',
       '#options' => [
         'one' => 'One',
@@ -39,7 +39,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
     $form['#post_render'][] = [static::class, 'postRender'];
 
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php
index b238f5a02547532ffbcac33fcead551fe30dc58e..bbbf97247da2410d939e23cc83d9980df861e836 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLabelForm.php
@@ -61,34 +61,34 @@ public function getFormId() {
   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['form_checkboxes_test'] = [
       '#type' => 'checkboxes',
-      '#title' => t('Checkboxes test'),
+      '#title' => $this->t('Checkboxes test'),
       '#options' => [
-        'first-checkbox' => t('First checkbox'),
-        'second-checkbox' => t('Second checkbox'),
-        'third-checkbox' => t('Third checkbox'),
-        '0' => t('0'),
+        'first-checkbox' => $this->t('First checkbox'),
+        'second-checkbox' => $this->t('Second checkbox'),
+        'third-checkbox' => $this->t('Third checkbox'),
+        '0' => $this->t('0'),
       ],
     ];
     $form['form_radios_test'] = [
       '#type' => 'radios',
-      '#title' => t('Radios test'),
+      '#title' => $this->t('Radios test'),
       '#options' => [
-        'first-radio' => t('First radio'),
-        'second-radio' => t('Second radio'),
-        'third-radio' => t('Third radio'),
-        '0' => t('0'),
+        'first-radio' => $this->t('First radio'),
+        'second-radio' => $this->t('Second radio'),
+        'third-radio' => $this->t('Third radio'),
+        '0' => $this->t('0'),
       ],
       // Test #field_prefix and #field_suffix placement.
-      '#field_prefix' => '<span id="form-test-radios-field-prefix">' . t('Radios #field_prefix element') . '</span>',
-      '#field_suffix' => '<span id="form-test-radios-field-suffix">' . t('Radios #field_suffix element') . '</span>',
+      '#field_prefix' => '<span id="form-test-radios-field-prefix">' . $this->t('Radios #field_prefix element') . '</span>',
+      '#field_suffix' => '<span id="form-test-radios-field-suffix">' . $this->t('Radios #field_suffix element') . '</span>',
     ];
     $form['form_checkbox_test'] = [
       '#type' => 'checkbox',
-      '#title' => t('Checkbox test'),
+      '#title' => $this->t('Checkbox test'),
     ];
     $form['form_textfield_test_title_and_required'] = [
       '#type' => 'textfield',
-      '#title' => t('Textfield test for required with title'),
+      '#title' => $this->t('Textfield test for required with title'),
       '#required' => TRUE,
     ];
     $form['form_textfield_test_no_title_required'] = [
@@ -100,20 +100,20 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['form_textfield_test_title'] = [
       '#type' => 'textfield',
-      '#title' => t('Textfield test for title only'),
+      '#title' => $this->t('Textfield test for title only'),
       // Not required.
       // Test #prefix and #suffix placement.
-      '#prefix' => '<div id="form-test-textfield-title-prefix">' . t('Textfield #prefix element') . '</div>',
-      '#suffix' => '<div id="form-test-textfield-title-suffix">' . t('Textfield #suffix element') . '</div>',
+      '#prefix' => '<div id="form-test-textfield-title-prefix">' . $this->t('Textfield #prefix element') . '</div>',
+      '#suffix' => '<div id="form-test-textfield-title-suffix">' . $this->t('Textfield #suffix element') . '</div>',
     ];
     $form['form_textfield_test_title_after'] = [
       '#type' => 'textfield',
-      '#title' => t('Textfield test for title after element'),
+      '#title' => $this->t('Textfield test for title after element'),
       '#title_display' => 'after',
     ];
     $form['form_textfield_test_title_invisible'] = [
       '#type' => 'textfield',
-      '#title' => t('Textfield test for invisible title'),
+      '#title' => $this->t('Textfield test for invisible title'),
       '#title_display' => 'invisible',
     ];
     // Textfield test for title set not to display.
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php
index b0df340b20383a5f9273052d343f5cfb6c216686..9dc7e75be449a6932d26a7c9448ff3b9be6925d3 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLanguageSelectForm.php
@@ -28,30 +28,30 @@ public function getFormId() {
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['languages_all'] = [
-      '#title' => t('Languages: All'),
+      '#title' => $this->t('Languages: All'),
       '#type' => 'language_select',
       '#languages' => LanguageInterface::STATE_ALL,
       '#default_value' => 'xx',
     ];
     $form['languages_configurable'] = [
-      '#title' => t('Languages: Configurable'),
+      '#title' => $this->t('Languages: Configurable'),
       '#type' => 'language_select',
       '#languages' => LanguageInterface::STATE_CONFIGURABLE,
       '#default_value' => 'en',
     ];
     $form['languages_locked'] = [
-      '#title' => t('Languages: Locked'),
+      '#title' => $this->t('Languages: Locked'),
       '#type' => 'language_select',
       '#languages' => LanguageInterface::STATE_LOCKED,
     ];
     $form['languages_config_and_locked'] = [
-      '#title' => t('Languages: Configurable and locked'),
+      '#title' => $this->t('Languages: Configurable and locked'),
       '#type' => 'language_select',
       '#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED,
       '#default_value' => 'dummy_value',
     ];
     $form['language_custom_options'] = [
-      '#title' => t('Languages: Custom'),
+      '#title' => $this->t('Languages: Custom'),
       '#type' => 'language_select',
       '#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_LOCKED,
       '#options' => ['opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'],
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php
index ce7bec14dc3d65a9a0c40aafada39d303539af2d..b554d3838220d233a12f3d3d7cd1ee8879bcbeb2 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestLimitValidationErrorsForm.php
@@ -63,23 +63,23 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#type' => 'submit',
       '#limit_validation_errors' => [['test']],
       '#submit' => ['::partialSubmitForm'],
-      '#value' => t('Partial validate'),
+      '#value' => $this->t('Partial validate'),
     ];
     $form['actions']['partial_numeric_index'] = [
       '#type' => 'submit',
       '#limit_validation_errors' => [['test_numeric_index', 0]],
       '#submit' => ['::partialSubmitForm'],
-      '#value' => t('Partial validate (numeric index)'),
+      '#value' => $this->t('Partial validate (numeric index)'),
     ];
     $form['actions']['substring'] = [
       '#type' => 'submit',
       '#limit_validation_errors' => [['test_substring', 'foo']],
       '#submit' => ['::partialSubmitForm'],
-      '#value' => t('Partial validate (substring)'),
+      '#value' => $this->t('Partial validate (substring)'),
     ];
     $form['actions']['full'] = [
       '#type' => 'submit',
-      '#value' => t('Full validate'),
+      '#value' => $this->t('Full validate'),
     ];
     return $form;
   }
@@ -89,7 +89,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    */
   public function elementValidateLimitValidationErrors($element, FormStateInterface $form_state) {
     if ($element['#value'] == 'invalid') {
-      $form_state->setError($element, t('@label element is invalid', ['@label' => $element['#title']]));
+      $form_state->setError($element, $this->t('@label element is invalid', ['@label' => $element['#title']]));
     }
   }
 
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
index 577d29b2912914d3ea23d858a3765219004ba335..d19a6646e28be27d4b8a5d3f9ae966c48eace8b8 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
@@ -31,7 +31,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
 
     $form['checkboxes'] = [
-      '#title' => t('Checkboxes'),
+      '#title' => $this->t('Checkboxes'),
       '#type' => 'checkboxes',
       '#options' => [
         1 => 'First checkbox',
@@ -90,7 +90,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    */
   public function validateForm(array &$form, FormStateInterface $form_state) {
     if ($form_state->isValueEmpty('textfield')) {
-      $form_state->setErrorByName('textfield', t('Textfield is required.'));
+      $form_state->setErrorByName('textfield', $this->t('Textfield is required.'));
     }
   }
 
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php
index 82b50ddb1fc888961ebeadb449ce1afb569a9548..ebab3c5a76a4c8518480fc700dfd556e29fa7379 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRebuildPreserveValuesForm.php
@@ -30,17 +30,17 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     $form = [
       'checkbox_1_default_off' => [
         '#type' => 'checkbox',
-        '#title' => t('This checkbox defaults to unchecked'),
+        '#title' => $this->t('This checkbox defaults to unchecked'),
         '#default_value' => FALSE,
       ],
       'checkbox_1_default_on' => [
         '#type' => 'checkbox',
-        '#title' => t('This checkbox defaults to checked'),
+        '#title' => $this->t('This checkbox defaults to checked'),
         '#default_value' => TRUE,
       ],
       'text_1' => [
         '#type' => 'textfield',
-        '#title' => t('This textfield has a non-empty default value.'),
+        '#title' => $this->t('This textfield has a non-empty default value.'),
         '#default_value' => 'DEFAULT 1',
       ],
     ];
@@ -59,17 +59,17 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       $form += [
         'checkbox_2_default_off' => [
           '#type' => 'checkbox',
-          '#title' => t('This checkbox defaults to unchecked'),
+          '#title' => $this->t('This checkbox defaults to unchecked'),
           '#default_value' => FALSE,
         ],
         'checkbox_2_default_on' => [
           '#type' => 'checkbox',
-          '#title' => t('This checkbox defaults to checked'),
+          '#title' => $this->t('This checkbox defaults to checked'),
           '#default_value' => TRUE,
         ],
         'text_2' => [
           '#type' => 'textfield',
-          '#title' => t('This textfield has a non-empty default value.'),
+          '#title' => $this->t('This textfield has a non-empty default value.'),
           '#default_value' => 'DEFAULT 2',
         ],
       ];
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
index dd048fd7b393d4359df3be8a95ba2602060111b2..baf646acbbd9cd5f44a791b1d7aed6cdbcf4bd70 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
@@ -28,11 +28,11 @@ public function getFormId() {
   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['redirection'] = [
       '#type' => 'checkbox',
-      '#title' => t('Use redirection'),
+      '#title' => $this->t('Use redirection'),
     ];
     $form['destination'] = [
       '#type' => 'textfield',
-      '#title' => t('Redirect destination'),
+      '#title' => $this->t('Redirect destination'),
       '#states' => [
         'visible' => [
           ':input[name="redirection"]' => ['checked' => TRUE],
@@ -41,7 +41,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['ignore_destination'] = [
       '#type' => 'checkbox',
-      '#title' => t('Ignore destination query parameter'),
+      '#title' => $this->t('Ignore destination query parameter'),
       '#states' => [
         'visible' => [
           ':input[name="redirection"]' => ['checked' => TRUE],
@@ -50,7 +50,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
 
     return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php
index f33b0e67e3bfffcc0544bd1296a8349de4f41428..50314d017ee345a8edf09b1b5400df527c7c098b 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestStatePersistForm.php
@@ -35,7 +35,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
 
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
     return $form;
   }
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
index df570aa35c971e94ec9bb11fe7971bae80643241..1420e444743978634524534eb2dfd2ff5b9de6a6 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectFormBase.php
@@ -40,7 +40,7 @@ public function tableselectFormBuilder($form, FormStateInterface $form_state, $e
       '#header' => $header,
       '#options' => $options,
       '#multiple' => FALSE,
-      '#empty' => t('Empty text.'),
+      '#empty' => $this->t('Empty text.'),
       '#ajax' => [
         'callback' => '::tableselectAjaxCallback',
         'wrapper' => 'tableselect-wrapper',
@@ -49,7 +49,7 @@ public function tableselectFormBuilder($form, FormStateInterface $form_state, $e
 
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
 
     return $form;
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php
index 2ba6935f2f5baeaf4bf9741135de786a5d3751f9..cb669372fa91b8d17f993fae8924479ea1b468f1 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredForm.php
@@ -32,14 +32,14 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#type' => 'textfield',
       '#title' => 'Name',
       '#required' => TRUE,
-      '#required_error' => t('Enter a name.'),
+      '#required_error' => $this->t('Enter a name.'),
     ];
     $form['checkboxes'] = [
       '#type' => 'checkboxes',
       '#title' => 'Checkboxes',
       '#options' => $options,
       '#required' => TRUE,
-      '#form_test_required_error' => t('Choose at least one option.'),
+      '#form_test_required_error' => $this->t('Choose at least one option.'),
       '#element_validate' => $validate,
     ];
     $form['select'] = [
@@ -47,7 +47,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#title' => 'Select',
       '#options' => $options,
       '#required' => TRUE,
-      '#form_test_required_error' => t('Select something.'),
+      '#form_test_required_error' => $this->t('Select something.'),
       '#element_validate' => $validate,
     ];
     $form['radios'] = [
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php
index 5ae05f91c896a58e0db4269d045d30be9d37c749..bad0674aa28ad10b9a4d187ade43bd19392c8637 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php
@@ -30,34 +30,34 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['tab1'] = [
       '#type' => 'fieldset',
-      '#title' => t('Tab 1'),
+      '#title' => $this->t('Tab 1'),
       '#collapsible' => TRUE,
       '#group' => 'vertical_tabs1',
     ];
     $form['tab1']['field1'] = [
-      '#title' => t('Field 1'),
+      '#title' => $this->t('Field 1'),
       '#type' => 'checkbox',
       '#default_value' => TRUE,
     ];
     $form['tab2'] = [
       '#type' => 'fieldset',
-      '#title' => t('Tab 2'),
+      '#title' => $this->t('Tab 2'),
       '#collapsible' => TRUE,
       '#group' => 'vertical_tabs1',
     ];
     $form['tab2']['field2'] = [
-      '#title' => t('Field 2'),
+      '#title' => $this->t('Field 2'),
       '#type' => 'textfield',
       '#default_value' => 'field2',
     ];
 
     $form['fieldset1'] = [
       '#type' => 'fieldset',
-      '#title' => t('Fieldset'),
+      '#title' => $this->t('Fieldset'),
     ];
     $form['fieldset1']['field3'] = [
       '#type' => 'checkbox',
-      '#title' => t('Field 3'),
+      '#title' => $this->t('Field 3'),
       '#default_value' => TRUE,
     ];
 
@@ -66,7 +66,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['container']['field4'] = [
       '#type' => 'checkbox',
-      '#title' => t('Field 4'),
+      '#title' => $this->t('Field 4'),
       '#default_value' => TRUE,
     ];
     $form['container']['sub_container'] = [
@@ -74,7 +74,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['container']['sub_container']['field5'] = [
       '#type' => 'checkbox',
-      '#title' => t('Field 5'),
+      '#title' => $this->t('Field 5'),
       '#default_value' => TRUE,
     ];
 
@@ -83,12 +83,12 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['tab3'] = [
       '#type' => 'fieldset',
-      '#title' => t('Tab 3'),
+      '#title' => $this->t('Tab 3'),
       '#collapsible' => TRUE,
       '#group' => 'vertical_tabs2',
     ];
     $form['tab3']['field6'] = [
-      '#title' => t('Field 6'),
+      '#title' => $this->t('Field 6'),
       '#type' => 'checkbox',
       '#default_value' => TRUE,
     ];
@@ -98,7 +98,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['actions']['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
     return $form;
   }
@@ -109,22 +109,22 @@ public function buildForm(array $form, FormStateInterface $form_state) {
   public function validateForm(array &$form, FormStateInterface $form_state) {
     $values = $form_state->getValues();
     if (empty($values['field1'])) {
-      $form_state->setErrorByName('tab1][field1', t('This checkbox inside a vertical tab does not have its default value.'));
+      $form_state->setErrorByName('tab1][field1', $this->t('This checkbox inside a vertical tab does not have its default value.'));
     }
     if ($values['field2'] != 'field2') {
-      $form_state->setErrorByName('tab2][field2', t('This textfield inside a vertical tab does not have its default value.'));
+      $form_state->setErrorByName('tab2][field2', $this->t('This textfield inside a vertical tab does not have its default value.'));
     }
     if (empty($values['field3'])) {
-      $form_state->setErrorByName('fieldset][field3', t('This checkbox inside a fieldset does not have its default value.'));
+      $form_state->setErrorByName('fieldset][field3', $this->t('This checkbox inside a fieldset does not have its default value.'));
     }
     if (empty($values['field4'])) {
-      $form_state->setErrorByName('container][field4', t('This checkbox inside a container does not have its default value.'));
+      $form_state->setErrorByName('container][field4', $this->t('This checkbox inside a container does not have its default value.'));
     }
     if (empty($values['field5'])) {
-      $form_state->setErrorByName('container][sub_container][field5', t('This checkbox inside a nested container does not have its default value.'));
+      $form_state->setErrorByName('container][sub_container][field5', $this->t('This checkbox inside a nested container does not have its default value.'));
     }
     if (empty($values['field5'])) {
-      $form_state->setErrorByName('tab3][field6', t('This checkbox inside a vertical tab whose fieldset access is allowed does not have its default value.'));
+      $form_state->setErrorByName('tab3][field6', $this->t('This checkbox inside a vertical tab whose fieldset access is allowed does not have its default value.'));
     }
   }
 
@@ -132,7 +132,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
    * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    $this->messenger()->addStatus(t('The form submitted correctly.'));
+    $this->messenger()->addStatus($this->t('The form submitted correctly.'));
   }
 
 }
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php
index c00956bdce7c08ba2164961adb2e31756ae12bf6..878aa6fbed8272c7ba86c6c968f67265d5bf922b 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php
@@ -36,12 +36,12 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     for ($i = 1; $i <= $tab_count; $i++) {
       $form['tab' . $i] = [
         '#type' => 'fieldset',
-        '#title' => t('Tab @num', ['@num' => $i]),
+        '#title' => $this->t('Tab @num', ['@num' => $i]),
         '#group' => 'vertical_tabs',
         '#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
       ];
       $form['tab' . $i]['field' . $i] = [
-        '#title' => t('Field @num', ['@num' => $i]),
+        '#title' => $this->t('Field @num', ['@num' => $i]),
         '#type' => 'textfield',
 
       ];
diff --git a/core/modules/system/tests/modules/form_test/src/Form/IncorrectConfigTargetForm.php b/core/modules/system/tests/modules/form_test/src/Form/IncorrectConfigTargetForm.php
index 8ce44f43f6b562256c55864bc0e2a815d334d2f6..9504b090db19a0f6751e0ea4f0f5394f3243fc56 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/IncorrectConfigTargetForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/IncorrectConfigTargetForm.php
@@ -29,7 +29,7 @@ public function getFormId() {
   public function buildForm(array $form, FormStateInterface $form_state) {
     $form['missing_key'] = [
       '#type' => 'textfield',
-      '#title' => t('Missing key'),
+      '#title' => $this->t('Missing key'),
       '#config_target' => 'form_test.object:does_not_exist',
     ];
     return parent::buildForm($form, $form_state);
diff --git a/core/modules/system/tests/modules/form_test/src/Form/TreeConfigTargetForm.php b/core/modules/system/tests/modules/form_test/src/Form/TreeConfigTargetForm.php
index 2bbe62c5c3e6c04e544d7001abc2f3e2c152367b..faf1d2b8db300a899e12471b0190b200fbd895eb 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/TreeConfigTargetForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/TreeConfigTargetForm.php
@@ -32,17 +32,17 @@ public function buildForm(array $form, FormStateInterface $form_state) {
       '#open' => TRUE,
       '#tree' => TRUE,
       '#input' => TRUE,
-      '#title' => t('Vegetable preferences'),
+      '#title' => $this->t('Vegetable preferences'),
     ];
     $form['vegetables']['favorite'] = [
       '#type' => 'textfield',
-      '#title' => t('Favorite'),
+      '#title' => $this->t('Favorite'),
       '#default_value' => 'Potato',
       '#config_target' => 'form_test.object:favorite_vegetable',
     ];
     $form['vegetables']['nemesis'] = [
       '#type' => 'textfield',
-      '#title' => t('Nemesis'),
+      '#title' => $this->t('Nemesis'),
       '#config_target' => 'form_test.object:nemesis_vegetable',
     ];
     // Since form_test.object contains translatable values, it must specify a
diff --git a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php
index d69b4bba04fd33626031d9f3a8f81ac1234add2f..58d7398add29d68005a9f2fb15fd9292a2acb7f2 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php
@@ -6,12 +6,15 @@
 
 use Drupal\Core\Form\FormInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 
 /**
  * Implements a test form that has a validation error.
  */
 class ViewsTestDataErrorForm implements FormInterface {
 
+  use StringTranslationTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -28,7 +31,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     ];
     $form['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Submit'),
+      '#value' => $this->t('Submit'),
     ];
 
     return $form;
@@ -38,7 +41,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    * {@inheritdoc}
    */
   public function validateForm(array &$form, FormStateInterface $form_state) {
-    $form_state->setErrorByName('text', t('Form validation error'));
+    $form_state->setErrorByName('text', $this->t('Form validation error'));
   }
 
   /**
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index bcef3985d1a206b49f1e3477911636cde5beb0b7..ae70a1eb056f12b1c8fbbf3c47cdd40251ce7f27 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -184,6 +184,7 @@
   <rule ref="DrupalPractice.Objects.GlobalFunction">
     <include-pattern>*/Plugin/*</include-pattern>
     <include-pattern>*/ListBuilder/*</include-pattern>
+    <include-pattern>*/tests/*/Form/*</include-pattern>
   </rule>
 
   <!-- Generic sniffs -->