From ea9a55e5d0e9239e6aaf429699235e08b0a7aadc Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Wed, 28 Sep 2022 09:52:30 +0100
Subject: [PATCH] Issue #3181778 by quietone, longwave, aldairsoares,
 beatrizrodrigues, Aline Teixeira Ramos, KapilV, raman.b, anushrikumari,
 CChiste, mallezie, Ratan Priya, rakesh.regar, Kevin.Notari, vicheldt,
 mauryarahul11, yogeshmpawar, bbrala, alexpott, bruno.bicudo: [w/c September
 17th] Replace t() with $this->t() in all plugins

---
 .../Core/Action/Plugin/Action/EmailAction.php | 14 ++--
 .../Core/Action/Plugin/Action/GotoAction.php  |  4 +-
 .../Action/Plugin/Action/MessageAction.php    |  4 +-
 .../Derivative/DefaultSelectionDeriver.php    |  4 +-
 .../EntityReferenceSelection/Broken.php       |  2 +-
 .../Field/FieldFormatter/DecimalFormatter.php |  8 +-
 .../EntityReferenceEntityFormatter.php        |  4 +-
 .../EntityReferenceLabelFormatter.php         |  4 +-
 .../FieldFormatter/NumericFormatterBase.php   | 18 ++---
 .../Plugin/Field/FieldType/DecimalItem.php    | 11 +--
 .../Plugin/Field/FieldType/EmailItem.php      |  8 +-
 .../Field/FieldType/EntityReferenceItem.php   |  8 +-
 .../Plugin/Field/FieldType/IntegerItem.php    |  5 +-
 .../Field/FieldType/NumericItemBase.php       | 23 +++---
 .../Plugin/Field/FieldType/StringItem.php     |  6 +-
 .../Plugin/Field/FieldType/StringItemBase.php |  2 -
 .../FieldWidget/BooleanCheckboxWidget.php     |  4 +-
 .../Field/FieldWidget/EmailDefaultWidget.php  | 10 +--
 .../EntityReferenceAutocompleteWidget.php     | 22 +++---
 .../Plugin/Field/FieldWidget/NumberWidget.php |  8 +-
 .../FieldWidget/OptionsButtonsWidget.php      |  2 +-
 .../Field/FieldWidget/OptionsSelectWidget.php |  6 +-
 .../Field/FieldWidget/OptionsWidgetBase.php   |  3 +-
 .../FieldWidget/StringTextareaWidget.php      | 10 +--
 .../FieldWidget/StringTextfieldWidget.php     | 10 +--
 .../aggregator/fetcher/DefaultFetcher.php     |  4 +-
 .../aggregator/parser/DefaultParser.php       |  5 +-
 .../aggregator/processor/DefaultProcessor.php | 18 ++---
 .../aggregator/processor/TestProcessor.php    |  4 +-
 .../src/Plugin/CKEditorPlugin/Llama.php       |  2 +
 .../src/Plugin/CKEditorPlugin/LlamaButton.php |  2 +-
 .../LlamaContextualAndButton.php              |  4 +-
 .../src/Plugin/CKEditorPlugin/LlamaCss.php    |  2 +-
 .../ckeditor5/src/Plugin/Editor/CKEditor5.php |  2 +-
 .../Plugin/Field/FieldType/CommentItem.php    | 45 +++++------
 .../Field/FieldWidget/CommentWidget.php       | 16 ++--
 .../ContentTranslationContextualLinks.php     |  5 +-
 .../DateTimeDefaultFormatter.php              |  6 +-
 .../Field/FieldType/DateTimeFieldItemList.php | 14 ++--
 .../Plugin/Field/FieldType/DateTimeItem.php   | 15 ++--
 .../FieldWidget/DateTimeDatelistWidget.php    | 30 ++++----
 .../modules/src/Plugin/Editor/TRexEditor.php  |  2 +-
 .../src/Plugin/Editor/UnicornEditor.php       |  2 +-
 .../TestFieldDefaultFormatter.php             |  4 +-
 .../TestFieldEmptySettingFormatter.php        |  4 +-
 .../TestFieldMultipleFormatter.php            |  4 +-
 .../TestFieldPrepareViewFormatter.php         |  4 +-
 .../src/Plugin/Field/FieldType/TestItem.php   | 13 ++--
 .../TestItemWithPreconfiguredOptions.php      |  5 +-
 .../Field/FieldWidget/TestFieldWidget.php     |  6 +-
 .../FieldWidget/TestFieldWidgetMultiple.php   |  6 +-
 .../Field/FieldFormatter/TableFormatter.php   |  2 +-
 .../src/Plugin/Field/FieldType/FileItem.php   | 40 +++++-----
 .../Plugin/Field/FieldWidget/FileWidget.php   | 25 +++---
 .../Field/FieldFormatter/ImageFormatter.php   | 20 ++---
 .../src/Plugin/Field/FieldType/ImageItem.php  | 77 ++++++++++---------
 .../Plugin/Field/FieldWidget/ImageWidget.php  | 19 ++---
 .../Plugin/ImageEffect/ConvertImageEffect.php |  2 +-
 .../Plugin/ImageEffect/CropImageEffect.php    | 22 +++---
 .../Plugin/ImageEffect/ResizeImageEffect.php  |  8 +-
 .../Plugin/ImageEffect/RotateImageEffect.php  | 12 +--
 .../Plugin/ImageEffect/ScaleImageEffect.php   |  4 +-
 .../FieldFormatter/DummyAjaxFormatter.php     |  2 +-
 .../ImageEffect/AjaxTestImageEffect.php       |  2 +-
 .../src/Plugin/Condition/Language.php         |  4 +-
 .../src/Plugin/Derivative/LanguageBlock.php   |  7 +-
 .../Field/FieldFormatter/LinkFormatter.php    | 26 +++----
 .../src/Plugin/Field/FieldType/LinkItem.php   | 23 +++---
 .../Plugin/Field/FieldWidget/LinkWidget.php   | 11 +--
 .../media/src/Plugin/media/Source/OEmbed.php  |  4 +-
 .../src/Plugin/media/Source/OEmbedDeriver.php |  7 +-
 .../Field/FieldWidget/MediaLibraryWidget.php  | 11 +--
 .../src/Plugin/migrate/source/MenuLink.php    | 50 ++++++------
 .../migrate/src/Plugin/migrate/id_map/Sql.php |  2 +-
 .../src/Plugin/migrate/source/EmptySource.php |  2 +-
 .../Plugin/migrate/source/SqlCountCache.php   |  2 +-
 .../src/Plugin/Action/AssignOwnerNode.php     |  8 +-
 .../Plugin/Action/UnpublishByKeywordNode.php  |  4 +-
 .../node/src/Plugin/Search/NodeSearch.php     | 24 +++---
 .../node/src/Plugin/migrate/D6NodeDeriver.php |  4 +-
 .../node/src/Plugin/migrate/D7NodeDeriver.php |  4 +-
 .../Plugin/migrate/source/d6/NodeRevision.php |  2 +-
 .../Plugin/migrate/source/d7/NodeRevision.php |  2 +-
 .../Plugin/Field/FieldType/ListFloatItem.php  | 15 ++--
 .../Field/FieldType/ListIntegerItem.php       | 15 ++--
 .../Plugin/Field/FieldType/ListItemBase.php   | 11 +--
 .../Plugin/Field/FieldType/ListStringItem.php | 13 ++--
 .../Plugin/Field/FieldWidget/PathWidget.php   |  2 +-
 .../ResponsiveImageFormatter.php              | 18 ++---
 .../Plugin/Search/SearchExtraTypeSearch.php   |  8 +-
 .../src/Plugin/ImageToolkit/GDToolkit.php     | 10 +--
 .../Plugin/Field/FieldType/FieldTestItem.php  |  2 -
 .../src/Plugin/MockBlockManager.php           | 25 +++---
 .../mock_block/MockLayoutBlockDeriver.php     |  5 +-
 .../mock_block/MockMenuBlockDeriver.php       |  9 ++-
 .../Plugin/migrate/D7TaxonomyTermDeriver.php  |  4 +-
 .../Plugin/views/filter/TaxonomyIndexTid.php  |  2 +-
 .../FieldFormatter/TelephoneLinkFormatter.php |  6 +-
 .../Plugin/Field/FieldType/TelephoneItem.php  |  5 +-
 .../FieldWidget/TelephoneDefaultWidget.php    |  8 +-
 .../FieldFormatter/TextTrimmedFormatter.php   |  8 +-
 .../src/Plugin/Field/FieldType/TextItem.php   |  6 +-
 .../Field/FieldType/TextWithSummaryItem.php   | 15 ++--
 .../FieldWidget/TextareaWithSummaryWidget.php | 10 +--
 .../src/Plugin/Action/ChangeUserRoleBase.php  |  2 +-
 .../src/Plugin/Derivative/ViewsBlock.php      |  2 +-
 .../src/Plugin/Derivative/ViewsEntityRow.php  |  5 +-
 .../Derivative/ViewsExposedFilterBlock.php    |  5 +-
 .../ViewsSelection.php                        |  3 +-
 .../src/Plugin/views/BrokenHandlerTrait.php   |  6 +-
 .../src/Plugin/views/area/DisplayLink.php     |  8 +-
 .../views/area/TokenizeAreaPluginBase.php     |  4 +-
 .../views/src/Plugin/views/area/View.php      |  2 +-
 .../views/argument/ArgumentPluginBase.php     |  4 +-
 .../views/display/DisplayPluginBase.php       |  2 +-
 .../views/src/Plugin/views/field/Boolean.php  | 10 +--
 .../Plugin/views/field/FieldPluginBase.php    |  7 +-
 .../src/Plugin/views/filter/InOperator.php    |  2 +-
 .../views/field/FieldFormButtonTest.php       |  2 +-
 .../Plugin/RelationshipJoinTestBase.php       |  5 +-
 core/phpcs.xml.dist                           |  3 +
 .../Discovery/AnnotatedClassDiscoveryTest.php |  3 +-
 ...omDirectoryAnnotatedClassDiscoveryTest.php |  3 +-
 123 files changed, 602 insertions(+), 529 deletions(-)

diff --git a/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php b/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php
index b345418d370e..2a675fb99038 100644
--- a/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php
+++ b/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php
@@ -163,25 +163,25 @@ public function defaultConfiguration() {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['recipient'] = [
       '#type' => 'textfield',
-      '#title' => t('Recipient email address'),
+      '#title' => $this->t('Recipient email address'),
       '#default_value' => $this->configuration['recipient'],
       '#maxlength' => '254',
-      '#description' => t('You may also use tokens: [node:author:mail], [comment:author:mail], etc. Separate recipients with a comma.'),
+      '#description' => $this->t('You may also use tokens: [node:author:mail], [comment:author:mail], etc. Separate recipients with a comma.'),
     ];
     $form['subject'] = [
       '#type' => 'textfield',
-      '#title' => t('Subject'),
+      '#title' => $this->t('Subject'),
       '#default_value' => $this->configuration['subject'],
       '#maxlength' => '254',
-      '#description' => t('The subject of the message.'),
+      '#description' => $this->t('The subject of the message.'),
     ];
     $form['message'] = [
       '#type' => 'textarea',
-      '#title' => t('Message'),
+      '#title' => $this->t('Message'),
       '#default_value' => $this->configuration['message'],
       '#cols' => '80',
       '#rows' => '20',
-      '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
+      '#description' => $this->t('The message that should be sent. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
     ];
     return $form;
   }
@@ -192,7 +192,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
     if (!$this->emailValidator->isValid($form_state->getValue('recipient')) && strpos($form_state->getValue('recipient'), ':mail') === FALSE) {
       // We want the literal %author placeholder to be emphasized in the error message.
-      $form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', ['%author' => '[node:author:mail]']));
+      $form_state->setErrorByName('recipient', $this->t('Enter a valid email address or use a token email address such as %author.', ['%author' => '[node:author:mail]']));
     }
   }
 
diff --git a/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php b/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php
index 9fb6b0b61e8c..befc21f6a529 100644
--- a/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php
+++ b/core/lib/Drupal/Core/Action/Plugin/Action/GotoAction.php
@@ -114,8 +114,8 @@ public function defaultConfiguration() {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['url'] = [
       '#type' => 'textfield',
-      '#title' => t('URL'),
-      '#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', ['@url' => 'http://example.com']),
+      '#title' => $this->t('URL'),
+      '#description' => $this->t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', ['@url' => 'http://example.com']),
       '#default_value' => $this->configuration['url'],
       '#required' => TRUE,
     ];
diff --git a/core/lib/Drupal/Core/Action/Plugin/Action/MessageAction.php b/core/lib/Drupal/Core/Action/Plugin/Action/MessageAction.php
index 7c892eeed239..19575278cc17 100644
--- a/core/lib/Drupal/Core/Action/Plugin/Action/MessageAction.php
+++ b/core/lib/Drupal/Core/Action/Plugin/Action/MessageAction.php
@@ -106,11 +106,11 @@ public function defaultConfiguration() {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['message'] = [
       '#type' => 'textarea',
-      '#title' => t('Message'),
+      '#title' => $this->t('Message'),
       '#default_value' => $this->configuration['message'],
       '#required' => TRUE,
       '#rows' => '8',
-      '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
+      '#description' => $this->t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
     ];
     return $form;
   }
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php
index d46490a8f6bd..086063a3df18 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Plugin\Derivative\DeriverBase;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -17,6 +18,7 @@
  * @see plugin_api
  */
 class DefaultSelectionDeriver extends DeriverBase implements ContainerDeriverInterface {
+  use StringTranslationTrait;
 
   /**
    * The entity type manager.
@@ -51,7 +53,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
       $this->derivatives[$entity_type_id] = $base_plugin_definition;
       $this->derivatives[$entity_type_id]['entity_types'] = [$entity_type_id];
-      $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', ['@entity_type' => $entity_type->getLabel()]);
+      $this->derivatives[$entity_type_id]['label'] = $this->t('@entity_type selection', ['@entity_type' => $entity_type->getLabel()]);
       $this->derivatives[$entity_type_id]['base_plugin_label'] = (string) $base_plugin_definition['label'];
 
       // If the entity type doesn't provide a 'label' key in its plugin
diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php
index e8251e631f74..aa53c397d30f 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php
@@ -21,7 +21,7 @@ class Broken extends SelectionPluginBase {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['selection_handler'] = [
-      '#markup' => t('The selected selection handler is broken.'),
+      '#markup' => $this->t('The selected selection handler is broken.'),
     ];
     return $form;
   }
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
index 58e8fffc771b..312f846d3d76 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php
@@ -42,18 +42,18 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
 
     $elements['decimal_separator'] = [
       '#type' => 'select',
-      '#title' => t('Decimal marker'),
-      '#options' => ['.' => t('Decimal point'), ',' => t('Comma')],
+      '#title' => $this->t('Decimal marker'),
+      '#options' => ['.' => $this->t('Decimal point'), ',' => $this->t('Comma')],
       '#default_value' => $this->getSetting('decimal_separator'),
       '#weight' => 5,
     ];
     $elements['scale'] = [
       '#type' => 'number',
-      '#title' => t('Scale', [], ['context' => 'decimal places']),
+      '#title' => $this->t('Scale', [], ['context' => 'decimal places']),
       '#min' => 0,
       '#max' => 10,
       '#default_value' => $this->getSetting('scale'),
-      '#description' => t('The number of digits to the right of the decimal.'),
+      '#description' => $this->t('The number of digits to the right of the decimal.'),
       '#weight' => 6,
     ];
 
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
index 8f95e07b538e..38429246f51d 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php
@@ -130,7 +130,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     $elements['view_mode'] = [
       '#type' => 'select',
       '#options' => $this->entityDisplayRepository->getViewModeOptions($this->getFieldSetting('target_type')),
-      '#title' => t('View mode'),
+      '#title' => $this->t('View mode'),
       '#default_value' => $this->getSetting('view_mode'),
       '#required' => TRUE,
     ];
@@ -146,7 +146,7 @@ public function settingsSummary() {
 
     $view_modes = $this->entityDisplayRepository->getViewModeOptions($this->getFieldSetting('target_type'));
     $view_mode = $this->getSetting('view_mode');
-    $summary[] = t('Rendered as @mode', ['@mode' => $view_modes[$view_mode] ?? $view_mode]);
+    $summary[] = $this->t('Rendered as @mode', ['@mode' => $view_modes[$view_mode] ?? $view_mode]);
 
     return $summary;
   }
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
index ed9a6596d83e..5316105a82ce 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
@@ -35,7 +35,7 @@ public static function defaultSettings() {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $elements['link'] = [
-      '#title' => t('Link label to the referenced entity'),
+      '#title' => $this->t('Link label to the referenced entity'),
       '#type' => 'checkbox',
       '#default_value' => $this->getSetting('link'),
     ];
@@ -48,7 +48,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = $this->getSetting('link') ? t('Link to the referenced entity') : t('No link');
+    $summary[] = $this->getSetting('link') ? $this->t('Link to the referenced entity') : $this->t('No link');
     return $summary;
   }
 
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
index bc3efc759266..2ff9dc021051 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
@@ -16,16 +16,16 @@ abstract class NumericFormatterBase extends FormatterBase {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $options = [
-      ''  => t('- None -'),
-      '.' => t('Decimal point'),
-      ',' => t('Comma'),
-      ' ' => t('Space'),
-      chr(8201) => t('Thin space'),
-      "'" => t('Apostrophe'),
+      ''  => $this->t('- None -'),
+      '.' => $this->t('Decimal point'),
+      ',' => $this->t('Comma'),
+      ' ' => $this->t('Space'),
+      chr(8201) => $this->t('Thin space'),
+      "'" => $this->t('Apostrophe'),
     ];
     $elements['thousand_separator'] = [
       '#type' => 'select',
-      '#title' => t('Thousand marker'),
+      '#title' => $this->t('Thousand marker'),
       '#options' => $options,
       '#default_value' => $this->getSetting('thousand_separator'),
       '#weight' => 0,
@@ -33,7 +33,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
 
     $elements['prefix_suffix'] = [
       '#type' => 'checkbox',
-      '#title' => t('Display prefix and suffix'),
+      '#title' => $this->t('Display prefix and suffix'),
       '#default_value' => $this->getSetting('prefix_suffix'),
       '#weight' => 10,
     ];
@@ -49,7 +49,7 @@ public function settingsSummary() {
 
     $summary[] = $this->numberFormat(1234.1234567890);
     if ($this->getSetting('prefix_suffix')) {
-      $summary[] = t('Display with prefix and suffix.');
+      $summary[] = $this->t('Display with prefix and suffix.');
     }
 
     return $summary;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
index 0c9e8195bc11..15b7b65545fb 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php
@@ -6,6 +6,7 @@
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\TypedData\DataDefinition;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Defines the 'decimal' field type.
@@ -36,7 +37,7 @@ public static function defaultStorageSettings() {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('string')
-      ->setLabel(t('Decimal value'))
+      ->setLabel(new TranslatableMarkup('Decimal value'))
       ->setRequired(TRUE);
 
     return $properties;
@@ -66,21 +67,21 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
 
     $element['precision'] = [
       '#type' => 'number',
-      '#title' => t('Precision'),
+      '#title' => $this->t('Precision'),
       '#min' => 10,
       '#max' => 32,
       '#default_value' => $settings['precision'],
-      '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
+      '#description' => $this->t('The total number of digits to store in the database, including those to the right of the decimal.'),
       '#disabled' => $has_data,
     ];
 
     $element['scale'] = [
       '#type' => 'number',
-      '#title' => t('Scale', [], ['context' => 'decimal places']),
+      '#title' => $this->t('Scale', [], ['context' => 'decimal places']),
       '#min' => 0,
       '#max' => 10,
       '#default_value' => $settings['scale'],
-      '#description' => t('The number of digits to the right of the decimal.'),
+      '#description' => $this->t('The number of digits to the right of the decimal.'),
       '#disabled' => $has_data,
     ];
 
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php
index a6801fc229f5..59e918ae94e3 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php
@@ -8,6 +8,7 @@
 use Drupal\Core\Field\FieldItemBase;
 use Drupal\Core\Render\Element\Email;
 use Drupal\Core\TypedData\DataDefinition;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Defines the 'email' field type.
@@ -27,7 +28,7 @@ class EmailItem extends FieldItemBase {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('email')
-      ->setLabel(t('Email'))
+      ->setLabel(new TranslatableMarkup('Email'))
       ->setRequired(TRUE);
 
     return $properties;
@@ -58,7 +59,10 @@ public function getConstraints() {
       'value' => [
         'Length' => [
           'max' => Email::EMAIL_MAX_LENGTH,
-          'maxMessage' => t('%name: the email address can not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH]),
+          'maxMessage' => $this->t('%name: the email address can not be longer than @max characters.', [
+            '%name' => $this->getFieldDefinition()->getLabel(),
+            '@max' => Email::EMAIL_MAX_LENGTH,
+          ]),
         ],
       ],
     ]);
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
index 0bf634ea5ea6..146b9fd68e32 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
@@ -362,7 +362,7 @@ protected static function getRandomBundle(EntityTypeInterface $entity_type, arra
   public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
     $element['target_type'] = [
       '#type' => 'select',
-      '#title' => t('Type of item to reference'),
+      '#title' => $this->t('Type of item to reference'),
       '#default_value' => $this->getSetting('target_type'),
       '#required' => TRUE,
       '#disabled' => $has_data,
@@ -413,7 +413,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     ];
     $form['handler'] = [
       '#type' => 'details',
-      '#title' => t('Reference type'),
+      '#title' => $this->t('Reference type'),
       '#open' => TRUE,
       '#tree' => TRUE,
       '#process' => [[static::class, 'formProcessMergeParent']],
@@ -421,7 +421,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $form['handler']['handler'] = [
       '#type' => 'select',
-      '#title' => t('Reference method'),
+      '#title' => $this->t('Reference method'),
       '#options' => $handlers_options,
       '#default_value' => $field->getSetting('handler'),
       '#required' => TRUE,
@@ -430,7 +430,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     ];
     $form['handler']['handler_submit'] = [
       '#type' => 'submit',
-      '#value' => t('Change handler'),
+      '#value' => $this->t('Change handler'),
       '#limit_validation_errors' => [],
       '#attributes' => [
         'class' => ['js-hide'],
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php
index 8469126729a6..1ce7a4463f37 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php
@@ -5,6 +5,7 @@
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\TypedData\DataDefinition;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Defines the 'integer' field type.
@@ -49,7 +50,7 @@ public static function defaultFieldSettings() {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('integer')
-      ->setLabel(t('Integer value'))
+      ->setLabel(new TranslatableMarkup('Integer value'))
       ->setRequired(TRUE);
 
     return $properties;
@@ -69,7 +70,7 @@ public function getConstraints() {
         'value' => [
           'Range' => [
             'min' => 0,
-            'minMessage' => t('%name: The integer must be larger or equal to %min.', [
+            'minMessage' => $this->t('%name: The integer must be larger or equal to %min.', [
               '%name' => $this->getFieldDefinition()->getLabel(),
               '%min' => 0,
             ]),
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php
index a0c2af0e21bd..d1f3d644dbcb 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php
@@ -31,29 +31,29 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $element['min'] = [
       '#type' => 'number',
-      '#title' => t('Minimum'),
+      '#title' => $this->t('Minimum'),
       '#default_value' => $settings['min'],
-      '#description' => t('The minimum value that should be allowed in this field. Leave blank for no minimum.'),
+      '#description' => $this->t('The minimum value that should be allowed in this field. Leave blank for no minimum.'),
     ];
     $element['max'] = [
       '#type' => 'number',
-      '#title' => t('Maximum'),
+      '#title' => $this->t('Maximum'),
       '#default_value' => $settings['max'],
-      '#description' => t('The maximum value that should be allowed in this field. Leave blank for no maximum.'),
+      '#description' => $this->t('The maximum value that should be allowed in this field. Leave blank for no maximum.'),
     ];
     $element['prefix'] = [
       '#type' => 'textfield',
-      '#title' => t('Prefix'),
+      '#title' => $this->t('Prefix'),
       '#default_value' => $settings['prefix'],
       '#size' => 60,
-      '#description' => t("Define a string that should be prefixed to the value, like '$ ' or '&euro; '. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
+      '#description' => $this->t("Define a string that should be prefixed to the value, like '$ ' or '&euro; '. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
     ];
     $element['suffix'] = [
       '#type' => 'textfield',
-      '#title' => t('Suffix'),
+      '#title' => $this->t('Suffix'),
       '#default_value' => $settings['suffix'],
       '#size' => 60,
-      '#description' => t("Define a string that should be suffixed to the value, like ' m', ' kb/s'. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
+      '#description' => $this->t("Define a string that should be suffixed to the value, like ' m', ' kb/s'. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
     ];
 
     return $element;
@@ -85,7 +85,7 @@ public function getConstraints() {
         'value' => [
           'Range' => [
             'min' => $min,
-            'minMessage' => t('%name: the value may be no less than %min.', ['%name' => $label, '%min' => $min]),
+            'minMessage' => $this->t('%name: the value may be no less than %min.', ['%name' => $label, '%min' => $min]),
           ],
         ],
       ]);
@@ -97,7 +97,10 @@ public function getConstraints() {
         'value' => [
           'Range' => [
             'max' => $max,
-            'maxMessage' => t('%name: the value may be no greater than %max.', ['%name' => $label, '%max' => $max]),
+            'maxMessage' => $this->t('%name: the value may be no greater than %max.', [
+              '%name' => $label,
+              '%max' => $max,
+            ]),
           ],
         ],
       ]);
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
index b51764c2948d..172f904b2657 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
@@ -58,7 +58,7 @@ public function getConstraints() {
         'value' => [
           'Length' => [
             'max' => $max_length,
-            'maxMessage' => t('%name: may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
+            'maxMessage' => $this->t('%name: may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
           ],
         ],
       ]);
@@ -84,10 +84,10 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
 
     $element['max_length'] = [
       '#type' => 'number',
-      '#title' => t('Maximum length'),
+      '#title' => $this->t('Maximum length'),
       '#default_value' => $this->getSetting('max_length'),
       '#required' => TRUE,
-      '#description' => t('The maximum length of the field in characters.'),
+      '#description' => $this->t('The maximum length of the field in characters.'),
       '#min' => 1,
       '#disabled' => $has_data,
     ];
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php
index f59c10c985f9..fc08eb5014b5 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php
@@ -25,8 +25,6 @@ public static function defaultStorageSettings() {
    * {@inheritdoc}
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
-    // This is called very early by the user entity roles field. Prevent
-    // early t() calls by using the TranslatableMarkup.
     $properties['value'] = DataDefinition::create('string')
       ->setLabel(new TranslatableMarkup('Text value'))
       ->setSetting('case_sensitive', $field_definition->getSetting('case_sensitive'))
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php
index 7991a6f64da3..a954dac07d2c 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php
@@ -35,7 +35,7 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['display_label'] = [
       '#type' => 'checkbox',
-      '#title' => t('Use field label instead of the "On" label as the label.'),
+      '#title' => $this->t('Use field label instead of the "On" label as the label.'),
       '#default_value' => $this->getSetting('display_label'),
       '#weight' => -1,
     ];
@@ -49,7 +49,7 @@ public function settingsSummary() {
     $summary = [];
 
     $display_label = $this->getSetting('display_label');
-    $summary[] = t('Use field label: @display_label', ['@display_label' => ($display_label ? t('Yes') : t('No'))]);
+    $summary[] = $this->t('Use field label: @display_label', ['@display_label' => ($display_label ? $this->t('Yes') : $this->t('No'))]);
 
     return $summary;
   }
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php
index 76d0bdd24e68..bf7bb404200d 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php
@@ -43,9 +43,9 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     ];
     $element['placeholder'] = [
       '#type' => 'textfield',
-      '#title' => t('Placeholder'),
+      '#title' => $this->t('Placeholder'),
       '#default_value' => $this->getSetting('placeholder'),
-      '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
+      '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
     ];
     return $element;
   }
@@ -58,12 +58,12 @@ public function settingsSummary() {
 
     $placeholder = $this->getSetting('placeholder');
     if (!empty($placeholder)) {
-      $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
+      $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
     }
     else {
-      $summary[] = t('No placeholder');
+      $summary[] = $this->t('No placeholder');
     }
-    $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
+    $summary[] = $this->t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
 
     return $summary;
   }
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
index 2ce3912d8bda..22a1b2a085f2 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
@@ -40,10 +40,10 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['match_operator'] = [
       '#type' => 'radios',
-      '#title' => t('Autocomplete matching'),
+      '#title' => $this->t('Autocomplete matching'),
       '#default_value' => $this->getSetting('match_operator'),
       '#options' => $this->getMatchOperatorOptions(),
-      '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of entities.'),
+      '#description' => $this->t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of entities.'),
     ];
     $element['match_limit'] = [
       '#type' => 'number',
@@ -54,16 +54,16 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     ];
     $element['size'] = [
       '#type' => 'number',
-      '#title' => t('Size of textfield'),
+      '#title' => $this->t('Size of textfield'),
       '#default_value' => $this->getSetting('size'),
       '#min' => 1,
       '#required' => TRUE,
     ];
     $element['placeholder'] = [
       '#type' => 'textfield',
-      '#title' => t('Placeholder'),
+      '#title' => $this->t('Placeholder'),
       '#default_value' => $this->getSetting('placeholder'),
-      '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
+      '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
     ];
     return $element;
   }
@@ -75,16 +75,16 @@ public function settingsSummary() {
     $summary = [];
 
     $operators = $this->getMatchOperatorOptions();
-    $summary[] = t('Autocomplete matching: @match_operator', ['@match_operator' => $operators[$this->getSetting('match_operator')]]);
+    $summary[] = $this->t('Autocomplete matching: @match_operator', ['@match_operator' => $operators[$this->getSetting('match_operator')]]);
     $size = $this->getSetting('match_limit') ?: $this->t('unlimited');
     $summary[] = $this->t('Autocomplete suggestion list size: @size', ['@size' => $size]);
-    $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
+    $summary[] = $this->t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
     $placeholder = $this->getSetting('placeholder');
     if (!empty($placeholder)) {
-      $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
+      $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
     }
     else {
-      $summary[] = t('No placeholder');
+      $summary[] = $this->t('No placeholder');
     }
 
     return $summary;
@@ -207,8 +207,8 @@ protected function getSelectionHandlerSetting($setting_name) {
    */
   protected function getMatchOperatorOptions() {
     return [
-      'STARTS_WITH' => t('Starts with'),
-      'CONTAINS' => t('Contains'),
+      'STARTS_WITH' => $this->t('Starts with'),
+      'CONTAINS' => $this->t('Contains'),
     ];
   }
 
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php
index 976b52832e71..f3ad573408cd 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php
@@ -38,9 +38,9 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['placeholder'] = [
       '#type' => 'textfield',
-      '#title' => t('Placeholder'),
+      '#title' => $this->t('Placeholder'),
       '#default_value' => $this->getSetting('placeholder'),
-      '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
+      '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
     ];
     return $element;
   }
@@ -53,10 +53,10 @@ public function settingsSummary() {
 
     $placeholder = $this->getSetting('placeholder');
     if (!empty($placeholder)) {
-      $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
+      $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
     }
     else {
-      $summary[] = t('No placeholder');
+      $summary[] = $this->t('No placeholder');
     }
 
     return $summary;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php
index 7787106d85f3..5c9603ee5b5e 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php
@@ -64,7 +64,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
    */
   protected function getEmptyLabel() {
     if (!$this->required && !$this->multiple) {
-      return t('N/A');
+      return $this->t('N/A');
     }
   }
 
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php
index b623c8755eec..33e92109d253 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php
@@ -62,7 +62,7 @@ protected function getEmptyLabel() {
     if ($this->multiple) {
       // Multiple select: add a 'none' option for non-required fields.
       if (!$this->required) {
-        return t('- None -');
+        return $this->t('- None -');
       }
     }
     else {
@@ -70,10 +70,10 @@ protected function getEmptyLabel() {
       // and a 'select a value' option for required fields that do not come
       // with a value selected.
       if (!$this->required) {
-        return t('- None -');
+        return $this->t('- None -');
       }
       if (!$this->has_value) {
-        return t('- Select a value -');
+        return $this->t('- Select a value -');
       }
     }
   }
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
index 2e415eafde8e..976d35827d80 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
@@ -9,6 +9,7 @@
 use Drupal\Core\Field\WidgetBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Form\OptGroup;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Base class for the 'options_*' widgets.
@@ -88,7 +89,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
    */
   public static function validateElement(array $element, FormStateInterface $form_state) {
     if ($element['#required'] && $element['#value'] == '_none') {
-      $form_state->setError($element, t('@name field is required.', ['@name' => $element['#title']]));
+      $form_state->setError($element, new TranslatableMarkup('@name field is required.', ['@name' => $element['#title']]));
     }
 
     // Massage submitted form values.
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php
index 5f21b5edd49d..e3f4a218c319 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php
@@ -35,16 +35,16 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['rows'] = [
       '#type' => 'number',
-      '#title' => t('Rows'),
+      '#title' => $this->t('Rows'),
       '#default_value' => $this->getSetting('rows'),
       '#required' => TRUE,
       '#min' => 1,
     ];
     $element['placeholder'] = [
       '#type' => 'textfield',
-      '#title' => t('Placeholder'),
+      '#title' => $this->t('Placeholder'),
       '#default_value' => $this->getSetting('placeholder'),
-      '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
+      '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
     ];
     return $element;
   }
@@ -55,10 +55,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
   public function settingsSummary() {
     $summary = [];
 
-    $summary[] = t('Number of rows: @rows', ['@rows' => $this->getSetting('rows')]);
+    $summary[] = $this->t('Number of rows: @rows', ['@rows' => $this->getSetting('rows')]);
     $placeholder = $this->getSetting('placeholder');
     if (!empty($placeholder)) {
-      $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
+      $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
     }
 
     return $summary;
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php
index a0bb425f0cb8..4d86a33f831f 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php
@@ -35,16 +35,16 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['size'] = [
       '#type' => 'number',
-      '#title' => t('Size of textfield'),
+      '#title' => $this->t('Size of textfield'),
       '#default_value' => $this->getSetting('size'),
       '#required' => TRUE,
       '#min' => 1,
     ];
     $element['placeholder'] = [
       '#type' => 'textfield',
-      '#title' => t('Placeholder'),
+      '#title' => $this->t('Placeholder'),
       '#default_value' => $this->getSetting('placeholder'),
-      '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
+      '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
     ];
     return $element;
   }
@@ -55,10 +55,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
   public function settingsSummary() {
     $summary = [];
 
-    $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
+    $summary[] = $this->t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
     $placeholder = $this->getSetting('placeholder');
     if (!empty($placeholder)) {
-      $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
+      $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
     }
 
     return $summary;
diff --git a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
index f306b9b4f05d..097bcf48de63 100644
--- a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
+++ b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
@@ -8,6 +8,7 @@
 use Drupal\Core\Http\ClientFactory;
 use Drupal\Core\Messenger\MessengerInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use GuzzleHttp\Exception\TransferException;
 use GuzzleHttp\Psr7\Request;
 use Psr\Http\Message\RequestInterface;
@@ -28,6 +29,7 @@
  * )
  */
 class DefaultFetcher implements FetcherInterface, ContainerFactoryPluginInterface {
+  use StringTranslationTrait;
 
   /**
    * The HTTP client to fetch the feed data with.
@@ -127,7 +129,7 @@ public function fetch(FeedInterface $feed) {
     }
     catch (TransferException $e) {
       $this->logger->warning('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]);
-      $this->messenger->addWarning(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]));
+      $this->messenger->addWarning($this->t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]));
       return FALSE;
     }
   }
diff --git a/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php b/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php
index 66448fa5a6fc..3266ac36299a 100644
--- a/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php
+++ b/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php
@@ -5,6 +5,7 @@
 use Drupal\aggregator\Plugin\ParserInterface;
 use Drupal\aggregator\FeedInterface;
 use Drupal\Core\Messenger\MessengerTrait;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Laminas\Feed\Reader\Reader;
 use Laminas\Feed\Reader\Exception\ExceptionInterface;
 
@@ -20,7 +21,7 @@
  * )
  */
 class DefaultParser implements ParserInterface {
-
+  use StringTranslationTrait;
   use MessengerTrait;
 
   /**
@@ -34,7 +35,7 @@ public function parse(FeedInterface $feed) {
     }
     catch (ExceptionInterface $e) {
       watchdog_exception('aggregator', $e);
-      $this->messenger()->addError(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]));
+      $this->messenger()->addError($this->t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]));
 
       return FALSE;
     }
diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php
index fb229ac80140..4e9c7605ca8b 100644
--- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php
+++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php
@@ -124,14 +124,14 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     }, array_combine($counts, $counts));
     $intervals = [3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800];
     $period = array_map([$this->dateFormatter, 'formatInterval'], array_combine($intervals, $intervals));
-    $period[FeedStorageInterface::CLEAR_NEVER] = t('Never');
+    $period[FeedStorageInterface::CLEAR_NEVER] = $this->t('Never');
 
     $form['processors'][$info['id']] = [];
     // Only wrap into details if there is a basic configuration.
     if (isset($form['basic_conf'])) {
       $form['processors'][$info['id']] = [
         '#type' => 'details',
-        '#title' => t('Default processor settings'),
+        '#title' => $this->t('Default processor settings'),
         '#description' => $info['description'],
         '#open' => in_array($info['id'], $processors),
       ];
@@ -139,7 +139,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
 
     $form['processors'][$info['id']]['aggregator_summary_items'] = [
       '#type' => 'select',
-      '#title' => t('Number of items shown in listing pages'),
+      '#title' => $this->t('Number of items shown in listing pages'),
       '#default_value' => $config->get('source.list_max'),
       '#empty_value' => 0,
       '#options' => $items,
@@ -147,23 +147,23 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
 
     $form['processors'][$info['id']]['aggregator_clear'] = [
       '#type' => 'select',
-      '#title' => t('Discard items older than'),
+      '#title' => $this->t('Discard items older than'),
       '#default_value' => $config->get('items.expire'),
       '#options' => $period,
-      '#description' => t('Requires a correctly configured <a href=":cron">cron maintenance task</a>.', [':cron' => Url::fromRoute('system.status')->toString()]),
+      '#description' => $this->t('Requires a correctly configured <a href=":cron">cron maintenance task</a>.', [':cron' => Url::fromRoute('system.status')->toString()]),
     ];
 
     $lengths = [0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000];
     $options = array_map(function ($length) {
-      return ($length == 0) ? t('Unlimited') : $this->formatPlural($length, '1 character', '@count characters');
+      return ($length == 0) ? $this->t('Unlimited') : $this->formatPlural($length, '1 character', '@count characters');
     }, array_combine($lengths, $lengths));
 
     $form['processors'][$info['id']]['aggregator_teaser_length'] = [
       '#type' => 'select',
-      '#title' => t('Length of trimmed description'),
+      '#title' => $this->t('Length of trimmed description'),
       '#default_value' => $config->get('items.teaser_length'),
       '#options' => $options,
-      '#description' => t('The maximum number of characters used in the trimmed version of content.'),
+      '#description' => $this->t('The maximum number of characters used in the trimmed version of content.'),
     ];
     return $form;
   }
@@ -244,7 +244,7 @@ public function delete(FeedInterface $feed) {
       $this->itemStorage->delete($items);
     }
     // @todo This should be moved out to caller with a different message maybe.
-    $this->messenger->addStatus(t('The news items from %site have been deleted.', ['%site' => $feed->label()]));
+    $this->messenger->addStatus($this->t('The news items from %site have been deleted.', ['%site' => $feed->label()]));
   }
 
   /**
diff --git a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php
index 294697a2bc28..62dbba33149e 100644
--- a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php
+++ b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php
@@ -77,13 +77,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
 
     $form['processors'][$info['id']] = [
       '#type' => 'details',
-      '#title' => t('Test processor settings'),
+      '#title' => $this->t('Test processor settings'),
       '#description' => $info['description'],
       '#open' => in_array($info['id'], $processors),
     ];
     // Add some dummy settings to verify settingsForm is called.
     $form['processors'][$info['id']]['dummy_length'] = [
-      '#title' => t('Dummy length setting'),
+      '#title' => $this->t('Dummy length setting'),
       '#type' => 'number',
       '#min' => 1,
       '#max' => 1000,
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
index b724ff159252..9b83ae3a66e6 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
@@ -4,6 +4,7 @@
 
 use Drupal\ckeditor\CKEditorPluginInterface;
 use Drupal\Component\Plugin\PluginBase;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\editor\Entity\Editor;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -27,6 +28,7 @@
  * )
  */
 class Llama extends PluginBase implements CKEditorPluginInterface, ContainerFactoryPluginInterface {
+  use StringTranslationTrait;
 
   /**
    * The module list service.
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
index 646eaa6d25da..ca6d4a9192be 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
@@ -20,7 +20,7 @@ class LlamaButton extends Llama implements CKEditorPluginButtonsInterface {
   public function getButtons() {
     return [
       'Llama' => [
-        'label' => t('Insert Llama'),
+        'label' => $this->t('Insert Llama'),
       ],
     ];
   }
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
index 3033904f2952..c9a4d3374263 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
@@ -41,7 +41,7 @@ public function isEnabled(Editor $editor) {
   public function getButtons() {
     return [
       'Llama' => [
-        'label' => t('Insert Llama'),
+        'label' => $this->t('Insert Llama'),
       ],
     ];
   }
@@ -65,7 +65,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor
     }
 
     $form['ultra_llama_mode'] = [
-      '#title' => t('Ultra llama mode'),
+      '#title' => $this->t('Ultra llama mode'),
       '#type' => 'checkbox',
       '#default_value' => $config['ultra_llama_mode'],
     ];
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
index 23ffc8b5c96d..15f60e031eba 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
@@ -22,7 +22,7 @@ class LlamaCss extends Llama implements CKEditorPluginButtonsInterface, CKEditor
   public function getButtons() {
     return [
       'LlamaCSS' => [
-        'label' => t('Insert Llama CSS'),
+        'label' => $this->t('Insert Llama CSS'),
       ],
     ];
   }
diff --git a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php
index a31831a2c5b7..070fb96792b9 100644
--- a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php
+++ b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php
@@ -312,7 +312,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
           'warning' => [$css_warning],
         ],
         '#status_headings' => [
-          'warning' => t('Warning message'),
+          'warning' => $this->t('Warning message'),
         ],
       ];
     }
diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
index 255b5ab7c13c..b3934b9d9c7e 100644
--- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
+++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
@@ -12,6 +12,7 @@
 use Drupal\Core\Field\FieldItemBase;
 use Drupal\Core\Session\AnonymousUserSession;
 use Drupal\Core\Url;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Plugin implementation of the 'comment' field type.
@@ -55,26 +56,26 @@ public static function defaultFieldSettings() {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['status'] = DataDefinition::create('integer')
-      ->setLabel(t('Comment status'))
+      ->setLabel(new TranslatableMarkup('Comment status'))
       ->setRequired(TRUE);
 
     $properties['cid'] = DataDefinition::create('integer')
-      ->setLabel(t('Last comment ID'));
+      ->setLabel(new TranslatableMarkup('Last comment ID'));
 
     $properties['last_comment_timestamp'] = DataDefinition::create('integer')
-      ->setLabel(t('Last comment timestamp'))
-      ->setDescription(t('The time that the last comment was created.'));
+      ->setLabel(new TranslatableMarkup('Last comment timestamp'))
+      ->setDescription(new TranslatableMarkup('The time that the last comment was created.'));
 
     $properties['last_comment_name'] = DataDefinition::create('string')
-      ->setLabel(t('Last comment name'))
-      ->setDescription(t('The name of the user posting the last comment.'));
+      ->setLabel(new TranslatableMarkup('Last comment name'))
+      ->setDescription(new TranslatableMarkup('The name of the user posting the last comment.'));
 
     $properties['last_comment_uid'] = DataDefinition::create('integer')
-      ->setLabel(t('Last comment user ID'));
+      ->setLabel(new TranslatableMarkup('Last comment user ID'));
 
     $properties['comment_count'] = DataDefinition::create('integer')
-      ->setLabel(t('Number of comments'))
-      ->setDescription(t('The number of comments.'));
+      ->setLabel(new TranslatableMarkup('Number of comments'))
+      ->setDescription(new TranslatableMarkup('The number of comments.'));
 
     return $properties;
   }
@@ -108,13 +109,13 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $element['default_mode'] = [
       '#type' => 'checkbox',
-      '#title' => t('Threading'),
+      '#title' => $this->t('Threading'),
       '#default_value' => $settings['default_mode'],
-      '#description' => t('Show comment replies in a threaded list.'),
+      '#description' => $this->t('Show comment replies in a threaded list.'),
     ];
     $element['per_page'] = [
       '#type' => 'number',
-      '#title' => t('Comments per page'),
+      '#title' => $this->t('Comments per page'),
       '#default_value' => $settings['per_page'],
       '#required' => TRUE,
       '#min' => 1,
@@ -122,28 +123,28 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     ];
     $element['anonymous'] = [
       '#type' => 'select',
-      '#title' => t('Anonymous commenting'),
+      '#title' => $this->t('Anonymous commenting'),
       '#default_value' => $settings['anonymous'],
       '#options' => [
-        CommentInterface::ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
-        CommentInterface::ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
-        CommentInterface::ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'),
+        CommentInterface::ANONYMOUS_MAYNOT_CONTACT => $this->t('Anonymous posters may not enter their contact information'),
+        CommentInterface::ANONYMOUS_MAY_CONTACT => $this->t('Anonymous posters may leave their contact information'),
+        CommentInterface::ANONYMOUS_MUST_CONTACT => $this->t('Anonymous posters must leave their contact information'),
       ],
       '#access' => $anonymous_user->hasPermission('post comments'),
     ];
     $element['form_location'] = [
       '#type' => 'checkbox',
-      '#title' => t('Show reply form on the same page as comments'),
+      '#title' => $this->t('Show reply form on the same page as comments'),
       '#default_value' => $settings['form_location'],
     ];
     $element['preview'] = [
       '#type' => 'radios',
-      '#title' => t('Preview comment'),
+      '#title' => $this->t('Preview comment'),
       '#default_value' => $settings['preview'],
       '#options' => [
-        DRUPAL_DISABLED => t('Disabled'),
-        DRUPAL_OPTIONAL => t('Optional'),
-        DRUPAL_REQUIRED => t('Required'),
+        DRUPAL_DISABLED => $this->t('Disabled'),
+        DRUPAL_OPTIONAL => $this->t('Optional'),
+        DRUPAL_REQUIRED => $this->t('Required'),
       ],
     ];
 
@@ -185,7 +186,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
     }
     $element['comment_type'] = [
       '#type' => 'select',
-      '#title' => t('Comment type'),
+      '#title' => $this->t('Comment type'),
       '#options' => $options,
       '#required' => TRUE,
       '#description' => $this->t('Select the Comment type to use for this comment field. Manage the comment types from the <a href=":url">administration overview page</a>.', [':url' => Url::fromRoute('entity.comment_type.collection')->toString()]),
diff --git a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php
index c9478f622c29..a7159513becf 100644
--- a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php
+++ b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php
@@ -29,22 +29,22 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
 
     $element['status'] = [
       '#type' => 'radios',
-      '#title' => t('Comments'),
+      '#title' => $this->t('Comments'),
       '#title_display' => 'invisible',
       '#default_value' => $items->status,
       '#options' => [
-        CommentItemInterface::OPEN => t('Open'),
-        CommentItemInterface::CLOSED => t('Closed'),
-        CommentItemInterface::HIDDEN => t('Hidden'),
+        CommentItemInterface::OPEN => $this->t('Open'),
+        CommentItemInterface::CLOSED => $this->t('Closed'),
+        CommentItemInterface::HIDDEN => $this->t('Hidden'),
       ],
       CommentItemInterface::OPEN => [
-        '#description' => t('Users with the "Post comments" permission can post comments.'),
+        '#description' => $this->t('Users with the "Post comments" permission can post comments.'),
       ],
       CommentItemInterface::CLOSED => [
-        '#description' => t('Users cannot post comments, but existing comments will be displayed.'),
+        '#description' => $this->t('Users cannot post comments, but existing comments will be displayed.'),
       ],
       CommentItemInterface::HIDDEN => [
-        '#description' => t('Comments are hidden from view.'),
+        '#description' => $this->t('Comments are hidden from view.'),
       ],
     ];
     // If the entity doesn't have any comments, the "hidden" option makes no
@@ -53,7 +53,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
     if (!$this->isDefaultValueWidget($form_state) && !$items->comment_count) {
       $element['status'][CommentItemInterface::HIDDEN]['#access'] = FALSE;
       // Also adjust the description of the "closed" option.
-      $element['status'][CommentItemInterface::CLOSED]['#description'] = t('Users cannot post comments.');
+      $element['status'][CommentItemInterface::CLOSED]['#description'] = $this->t('Users cannot post comments.');
     }
     // If the advanced settings tabs-set is available (normally rendered in the
     // second column on wide-resolutions), place the field as a details element
diff --git a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php
index 7a4cad5e3dee..91fd520caab4 100644
--- a/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php
+++ b/core/modules/content_translation/src/Plugin/Derivative/ContentTranslationContextualLinks.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Plugin\Derivative\DeriverBase;
 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
 use Drupal\content_translation\ContentTranslationManagerInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -14,6 +15,8 @@
  */
 class ContentTranslationContextualLinks extends DeriverBase implements ContainerDeriverInterface {
 
+  use StringTranslationTrait;
+
   /**
    * The content translation manager.
    *
@@ -46,7 +49,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
   public function getDerivativeDefinitions($base_plugin_definition) {
     // Create contextual links for translatable entity types.
     foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
-      $this->derivatives[$entity_type_id]['title'] = t('Translate');
+      $this->derivatives[$entity_type_id]['title'] = $this->t('Translate');
       $this->derivatives[$entity_type_id]['route_name'] = "entity.$entity_type_id.content_translation_overview";
       $this->derivatives[$entity_type_id]['group'] = $entity_type_id;
     }
diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
index fa6549665af5..23d01ea3faf7 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
@@ -52,8 +52,8 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
 
     $form['format_type'] = [
       '#type' => 'select',
-      '#title' => t('Date format'),
-      '#description' => t("Choose a format for displaying the date. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date."),
+      '#title' => $this->t('Date format'),
+      '#description' => $this->t("Choose a format for displaying the date. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date."),
       '#options' => $options,
       '#default_value' => $this->getSetting('format_type'),
     ];
@@ -68,7 +68,7 @@ public function settingsSummary() {
     $summary = parent::settingsSummary();
 
     $date = new DrupalDateTime();
-    $summary[] = t('Format: @display', ['@display' => $this->formatDate($date)]);
+    $summary[] = $this->t('Format: @display', ['@display' => $this->formatDate($date)]);
 
     return $summary;
   }
diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
index 5f77efcd6cd6..8c2bc82a2992 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
@@ -34,19 +34,19 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state)
         '#parents' => ['default_value_input'],
         'default_date_type' => [
           '#type' => 'select',
-          '#title' => t('Default date'),
-          '#description' => t('Set a default value for this date.'),
+          '#title' => $this->t('Default date'),
+          '#description' => $this->t('Set a default value for this date.'),
           '#default_value' => $default_value[0]['default_date_type'] ?? '',
           '#options' => [
-            static::DEFAULT_VALUE_NOW => t('Current date'),
-            static::DEFAULT_VALUE_CUSTOM => t('Relative date'),
+            static::DEFAULT_VALUE_NOW => $this->t('Current date'),
+            static::DEFAULT_VALUE_CUSTOM => $this->t('Relative date'),
           ],
           '#empty_value' => '',
         ],
         'default_date' => [
           '#type' => 'textfield',
-          '#title' => t('Relative default value'),
-          '#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See <a href=\"http://php.net/manual/function.strtotime.php\">strtotime</a> for more details."),
+          '#title' => $this->t('Relative default value'),
+          '#description' => $this->t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See <a href=\"http://php.net/manual/function.strtotime.php\">strtotime</a> for more details."),
           '#default_value' => (isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] == static::DEFAULT_VALUE_CUSTOM) ? $default_value[0]['default_date'] : '',
           '#states' => [
             'visible' => [
@@ -67,7 +67,7 @@ public function defaultValuesFormValidate(array $element, array &$form, FormStat
     if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_CUSTOM) {
       $is_strtotime = @strtotime($form_state->getValue(['default_value_input', 'default_date']));
       if (!$is_strtotime) {
-        $form_state->setErrorByName('default_value_input][default_date', t('The relative date value entered is invalid.'));
+        $form_state->setErrorByName('default_value_input][default_date', $this->t('The relative date value entered is invalid.'));
       }
     }
   }
diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php
index 3264069008ee..5e17728b99bc 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php
@@ -7,6 +7,7 @@
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\TypedData\DataDefinition;
 use Drupal\Core\Field\FieldItemBase;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Plugin implementation of the 'datetime' field type.
@@ -47,12 +48,12 @@ public static function defaultStorageSettings() {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('datetime_iso8601')
-      ->setLabel(t('Date value'))
+      ->setLabel(new TranslatableMarkup('Date value'))
       ->setRequired(TRUE);
 
     $properties['date'] = DataDefinition::create('any')
-      ->setLabel(t('Computed date'))
-      ->setDescription(t('The computed DateTime object.'))
+      ->setLabel(new TranslatableMarkup('Computed date'))
+      ->setDescription(new TranslatableMarkup('The computed DateTime object.'))
       ->setComputed(TRUE)
       ->setClass('\Drupal\datetime\DateTimeComputed')
       ->setSetting('date source', 'value');
@@ -86,12 +87,12 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
 
     $element['datetime_type'] = [
       '#type' => 'select',
-      '#title' => t('Date type'),
-      '#description' => t('Choose the type of date to create.'),
+      '#title' => $this->t('Date type'),
+      '#description' => $this->t('Choose the type of date to create.'),
       '#default_value' => $this->getSetting('datetime_type'),
       '#options' => [
-        static::DATETIME_TYPE_DATETIME => t('Date and time'),
-        static::DATETIME_TYPE_DATE => t('Date only'),
+        static::DATETIME_TYPE_DATETIME => $this->t('Date and time'),
+        static::DATETIME_TYPE_DATE => $this->t('Date only'),
       ],
       '#disabled' => $has_data,
     ];
diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php
index 276d92c43191..0d85d34a0511 100644
--- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php
+++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php
@@ -93,29 +93,33 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
 
     $element['date_order'] = [
       '#type' => 'select',
-      '#title' => t('Date part order'),
+      '#title' => $this->t('Date part order'),
       '#default_value' => $this->getSetting('date_order'),
-      '#options' => ['MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')],
+      '#options' => [
+        'MDY' => $this->t('Month/Day/Year'),
+        'DMY' => $this->t('Day/Month/Year'),
+        'YMD' => $this->t('Year/Month/Day'),
+      ],
     ];
 
     if ($this->getFieldSetting('datetime_type') == 'datetime') {
       $element['time_type'] = [
         '#type' => 'select',
-        '#title' => t('Time type'),
+        '#title' => $this->t('Time type'),
         '#default_value' => $this->getSetting('time_type'),
-        '#options' => ['24' => t('24 hour time'), '12' => t('12 hour time')],
+        '#options' => ['24' => $this->t('24 hour time'), '12' => $this->t('12 hour time')],
       ];
 
       $element['increment'] = [
         '#type' => 'select',
-        '#title' => t('Time increments'),
+        '#title' => $this->t('Time increments'),
         '#default_value' => $this->getSetting('increment'),
         '#options' => [
-          1 => t('1 minute'),
-          5 => t('5 minute'),
-          10 => t('10 minute'),
-          15 => t('15 minute'),
-          30 => t('30 minute'),
+          1 => $this->t('1 minute'),
+          5 => $this->t('5 minute'),
+          10 => $this->t('10 minute'),
+          15 => $this->t('15 minute'),
+          30 => $this->t('30 minute'),
         ],
       ];
     }
@@ -140,10 +144,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
   public function settingsSummary() {
     $summary = [];
 
-    $summary[] = t('Date part order: @order', ['@order' => $this->getSetting('date_order')]);
+    $summary[] = $this->t('Date part order: @order', ['@order' => $this->getSetting('date_order')]);
     if ($this->getFieldSetting('datetime_type') == 'datetime') {
-      $summary[] = t('Time type: @time_type', ['@time_type' => $this->getSetting('time_type')]);
-      $summary[] = t('Time increments: @increment', ['@increment' => $this->getSetting('increment')]);
+      $summary[] = $this->t('Time type: @time_type', ['@time_type' => $this->getSetting('time_type')]);
+      $summary[] = $this->t('Time increments: @increment', ['@increment' => $this->getSetting('increment')]);
     }
 
     return $summary;
diff --git a/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php b/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
index 5c8be2216e6d..70af7d822df8 100644
--- a/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
+++ b/core/modules/editor/tests/modules/src/Plugin/Editor/TRexEditor.php
@@ -34,7 +34,7 @@ public function getDefaultSettings() {
    */
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['stumpy_arms'] = [
-      '#title' => t('Stumpy arms'),
+      '#title' => $this->t('Stumpy arms'),
       '#type' => 'checkbox',
       '#default_value' => TRUE,
     ];
diff --git a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
index f6a35434a43f..fc7e4f4544ef 100644
--- a/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
+++ b/core/modules/editor/tests/modules/src/Plugin/Editor/UnicornEditor.php
@@ -35,7 +35,7 @@ public function getDefaultSettings() {
    */
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['ponies_too'] = [
-      '#title' => t('Pony mode'),
+      '#title' => $this->t('Pony mode'),
       '#type' => 'checkbox',
       '#default_value' => TRUE,
     ];
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php
index 80f860bfafd3..74065a5672a7 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php
@@ -36,7 +36,7 @@ public static function defaultSettings() {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['test_formatter_setting'] = [
-      '#title' => t('Setting'),
+      '#title' => $this->t('Setting'),
       '#type' => 'textfield',
       '#size' => 20,
       '#default_value' => $this->getSetting('test_formatter_setting'),
@@ -50,7 +50,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('@setting: @value', ['@setting' => 'test_formatter_setting', '@value' => $this->getSetting('test_formatter_setting')]);
+    $summary[] = $this->t('@setting: @value', ['@setting' => 'test_formatter_setting', '@value' => $this->getSetting('test_formatter_setting')]);
     return $summary;
   }
 
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php
index f36fea2c3914..86b8465e10f6 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php
@@ -34,7 +34,7 @@ public static function defaultSettings() {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['field_empty_setting'] = [
-      '#title' => t('Setting'),
+      '#title' => $this->t('Setting'),
       '#type' => 'textfield',
       '#size' => 20,
       '#default_value' => $this->getSetting('field_empty_setting'),
@@ -50,7 +50,7 @@ public function settingsSummary() {
     $summary = [];
     $setting = $this->getSetting('field_empty_setting');
     if (!empty($setting)) {
-      $summary[] = t('Default empty setting now has a value.');
+      $summary[] = $this->t('Default empty setting now has a value.');
     }
     return $summary;
   }
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php
index 978e18fbac6e..7f6bab89edd2 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php
@@ -37,7 +37,7 @@ public static function defaultSettings() {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['test_formatter_setting_multiple'] = [
-      '#title' => t('Setting'),
+      '#title' => $this->t('Setting'),
       '#type' => 'textfield',
       '#size' => 20,
       '#default_value' => $this->getSetting('test_formatter_setting_multiple'),
@@ -51,7 +51,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('@setting: @value', ['@setting' => 'test_formatter_setting_multiple', '@value' => $this->getSetting('test_formatter_setting_multiple')]);
+    $summary[] = $this->t('@setting: @value', ['@setting' => 'test_formatter_setting_multiple', '@value' => $this->getSetting('test_formatter_setting_multiple')]);
     return $summary;
   }
 
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php
index 39bff8d87737..038fd151f82e 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php
@@ -35,7 +35,7 @@ public static function defaultSettings() {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['test_formatter_setting_additional'] = [
-      '#title' => t('Setting'),
+      '#title' => $this->t('Setting'),
       '#type' => 'textfield',
       '#size' => 20,
       '#default_value' => $this->getSetting('test_formatter_setting_additional'),
@@ -49,7 +49,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('@setting: @value', ['@setting' => 'test_formatter_setting_additional', '@value' => $this->getSetting('test_formatter_setting_additional')]);
+    $summary[] = $this->t('@setting: @value', ['@setting' => 'test_formatter_setting_additional', '@value' => $this->getSetting('test_formatter_setting_additional')]);
     return $summary;
   }
 
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php
index d889f816f101..ad2a135a2172 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php
@@ -3,6 +3,7 @@
 namespace Drupal\field_test\Plugin\Field\FieldType;
 
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\TypedData\DataDefinition;
 use Drupal\Core\Field\FieldItemBase;
@@ -47,7 +48,7 @@ public static function defaultFieldSettings() {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('integer')
-      ->setLabel(t('Test integer value'))
+      ->setLabel(new TranslatableMarkup('Test integer value'))
       ->setRequired(TRUE);
 
     return $properties;
@@ -76,10 +77,10 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
   public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
     $form['test_field_storage_setting'] = [
       '#type' => 'textfield',
-      '#title' => t('Field test field storage setting'),
+      '#title' => $this->t('Field test field storage setting'),
       '#default_value' => $this->getSetting('test_field_storage_setting'),
       '#required' => FALSE,
-      '#description' => t('A dummy form element to simulate field storage setting.'),
+      '#description' => $this->t('A dummy form element to simulate field storage setting.'),
     ];
 
     return $form;
@@ -91,10 +92,10 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
   public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     $form['test_field_setting'] = [
       '#type' => 'textfield',
-      '#title' => t('Field test field setting'),
+      '#title' => $this->t('Field test field setting'),
       '#default_value' => $this->getSetting('test_field_setting'),
       '#required' => FALSE,
-      '#description' => t('A dummy form element to simulate field setting.'),
+      '#description' => $this->t('A dummy form element to simulate field setting.'),
     ];
 
     return $form;
@@ -119,7 +120,7 @@ public function getConstraints() {
       'value' => [
         'TestField' => [
           'value' => -1,
-          'message' => t('%name does not accept the value @value.', ['%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1]),
+          'message' => $this->t('%name does not accept the value @value.', ['%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1]),
         ],
       ],
     ]);
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php
index 6c98205f4f19..1c5754238af4 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Defines the 'test_field_with_preconfigured_options' entity field item.
@@ -24,8 +25,8 @@ class TestItemWithPreconfiguredOptions extends TestItem implements Preconfigured
   public static function getPreconfiguredOptions() {
     return [
       'custom_options' => [
-        'label' => t('All custom options'),
-        'category' => t('Custom category'),
+        'label' => new TranslatableMarkup('All custom options'),
+        'category' => new TranslatableMarkup('Custom category'),
         'field_storage_config' => [
           'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
           'settings' => [
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
index b2f9738f24c8..ef4efd2078cb 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
@@ -40,8 +40,8 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['test_widget_setting'] = [
       '#type' => 'textfield',
-      '#title' => t('Field test field widget setting'),
-      '#description' => t('A dummy form element to simulate field widget setting.'),
+      '#title' => $this->t('Field test field widget setting'),
+      '#description' => $this->t('A dummy form element to simulate field widget setting.'),
       '#default_value' => $this->getSetting('test_widget_setting'),
       '#required' => FALSE,
     ];
@@ -53,7 +53,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('@setting: @value', ['@setting' => 'test_widget_setting', '@value' => $this->getSetting('test_widget_setting')]);
+    $summary[] = $this->t('@setting: @value', ['@setting' => 'test_widget_setting', '@value' => $this->getSetting('test_widget_setting')]);
     return $summary;
   }
 
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php
index 3f9c0ea09f03..eaf7e77e68a9 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php
@@ -40,8 +40,8 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['test_widget_setting_multiple'] = [
       '#type' => 'textfield',
-      '#title' => t('Field test field widget setting'),
-      '#description' => t('A dummy form element to simulate field widget setting.'),
+      '#title' => $this->t('Field test field widget setting'),
+      '#description' => $this->t('A dummy form element to simulate field widget setting.'),
       '#default_value' => $this->getSetting('test_widget_setting_multiple'),
       '#required' => FALSE,
     ];
@@ -53,7 +53,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('@setting: @value', ['@setting' => 'test_widget_setting_multiple', '@value' => $this->getSetting('test_widget_setting_multiple')]);
+    $summary[] = $this->t('@setting: @value', ['@setting' => 'test_widget_setting_multiple', '@value' => $this->getSetting('test_widget_setting_multiple')]);
     return $summary;
   }
 
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
index e6a8db603877..3c0aa914fabf 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
@@ -24,7 +24,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
     $elements = [];
 
     if ($files = $this->getEntitiesToView($items, $langcode)) {
-      $header = [t('Attachment'), t('Size')];
+      $header = [$this->t('Attachment'), $this->t('Size')];
       $rows = [];
       foreach ($files as $file) {
         $item = $file->_referringItem;
diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
index 758d483e0139..dc37bf03502c 100644
--- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
+++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
@@ -12,6 +12,7 @@
 use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\StreamWrapper\StreamWrapperInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\TypedData\DataDefinition;
 
 /**
@@ -96,11 +97,11 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel
     $properties = parent::propertyDefinitions($field_definition);
 
     $properties['display'] = DataDefinition::create('boolean')
-      ->setLabel(t('Display'))
-      ->setDescription(t('Flag to control whether this file should be displayed when viewing content'));
+      ->setLabel(new TranslatableMarkup('Display'))
+      ->setDescription(new TranslatableMarkup('Flag to control whether this file should be displayed when viewing content'));
 
     $properties['description'] = DataDefinition::create('string')
-      ->setLabel(t('Description'));
+      ->setLabel(new TranslatableMarkup('Description'));
 
     return $properties;
   }
@@ -115,15 +116,15 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
 
     $element['display_field'] = [
       '#type' => 'checkbox',
-      '#title' => t('Enable <em>Display</em> field'),
+      '#title' => $this->t('Enable <em>Display</em> field'),
       '#default_value' => $this->getSetting('display_field'),
-      '#description' => t('The display option allows users to choose if a file should be shown when viewing the content.'),
+      '#description' => $this->t('The display option allows users to choose if a file should be shown when viewing the content.'),
     ];
     $element['display_default'] = [
       '#type' => 'checkbox',
-      '#title' => t('Files displayed by default'),
+      '#title' => $this->t('Files displayed by default'),
       '#default_value' => $this->getSetting('display_default'),
-      '#description' => t('This setting only has an effect if the display option is enabled.'),
+      '#description' => $this->t('This setting only has an effect if the display option is enabled.'),
       '#states' => [
         'visible' => [
           ':input[name="settings[display_field]"]' => ['checked' => TRUE],
@@ -134,10 +135,10 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
     $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE);
     $element['uri_scheme'] = [
       '#type' => 'radios',
-      '#title' => t('Upload destination'),
+      '#title' => $this->t('Upload destination'),
       '#options' => $scheme_options,
       '#default_value' => $this->getSetting('uri_scheme'),
-      '#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
+      '#description' => $this->t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
       '#disabled' => $has_data,
     ];
 
@@ -153,9 +154,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $element['file_directory'] = [
       '#type' => 'textfield',
-      '#title' => t('File directory'),
+      '#title' => $this->t('File directory'),
       '#default_value' => $settings['file_directory'],
-      '#description' => t('Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes.'),
+      '#description' => $this->t('Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes.'),
       '#element_validate' => [[static::class, 'validateDirectory']],
       '#weight' => 3,
     ];
@@ -164,7 +165,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     $extensions = str_replace(' ', ', ', $settings['file_extensions']);
     $element['file_extensions'] = [
       '#type' => 'textfield',
-      '#title' => t('Allowed file extensions'),
+      '#title' => $this->t('Allowed file extensions'),
       '#default_value' => $extensions,
       '#description' => $this->t("Separate extensions with a comma or space. Each extension can contain alphanumeric characters, '.', and '_', and should start and end with an alphanumeric character."),
       '#element_validate' => [[static::class, 'validateExtensions']],
@@ -177,9 +178,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $element['max_filesize'] = [
       '#type' => 'textfield',
-      '#title' => t('Maximum upload size'),
+      '#title' => $this->t('Maximum upload size'),
       '#default_value' => $settings['max_filesize'],
-      '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', ['%limit' => format_size(Environment::getUploadMaxSize())]),
+      '#description' => $this->t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', ['%limit' => format_size(Environment::getUploadMaxSize())]),
       '#size' => 10,
       '#element_validate' => [[static::class, 'validateMaxFilesize']],
       '#weight' => 5,
@@ -187,9 +188,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $element['description_field'] = [
       '#type' => 'checkbox',
-      '#title' => t('Enable <em>Description</em> field'),
+      '#title' => $this->t('Enable <em>Description</em> field'),
       '#default_value' => $settings['description_field'] ?? '',
-      '#description' => t('The description field allows users to enter a description about the uploaded file.'),
+      '#description' => $this->t('The description field allows users to enter a description about the uploaded file.'),
       '#weight' => 11,
     ];
 
@@ -228,7 +229,7 @@ public static function validateExtensions($element, FormStateInterface $form_sta
       $extension_array = array_unique(array_filter(explode(' ', $extensions)));
       $extensions = implode(' ', $extension_array);
       if (!preg_match('/^([a-z0-9]+([._][a-z0-9])* ?)+$/', $extensions)) {
-        $form_state->setError($element, t("The list of allowed extensions is not valid. Allowed characters are a-z, 0-9, '.', and '_'. The first and last characters cannot be '.' or '_', and these two characters cannot appear next to each other. Separate extensions with a comma or space."));
+        $form_state->setError($element, new TranslatableMarkup("The list of allowed extensions is not valid. Allowed characters are a-z, 0-9, '.', and '_'. The first and last characters cannot be '.' or '_', and these two characters cannot appear next to each other. Separate extensions with a comma or space."));
       }
       else {
         $form_state->setValueForElement($element, $extensions);
@@ -239,7 +240,8 @@ public static function validateExtensions($element, FormStateInterface $form_sta
       if (!in_array('txt', $extension_array, TRUE) && !\Drupal::config('system.file')->get('allow_insecure_uploads')) {
         foreach ($extension_array as $extension) {
           if (preg_match(FileSystemInterface::INSECURE_EXTENSION_REGEX, 'test.' . $extension)) {
-            $form_state->setError($element, t('Add %txt_extension to the list of allowed extensions to securely upload files with a %extension extension. The %txt_extension extension will then be added automatically.', ['%extension' => $extension, '%txt_extension' => 'txt']));
+            $form_state->setError($element, new TranslatableMarkup('Add %txt_extension to the list of allowed extensions to securely upload files with a %extension extension. The %txt_extension extension will then be added automatically.', ['%extension' => $extension, '%txt_extension' => 'txt']));
+
             break;
           }
         }
@@ -260,7 +262,7 @@ public static function validateMaxFilesize($element, FormStateInterface $form_st
     $element['#value'] = trim($element['#value']);
     $form_state->setValue(['settings', 'max_filesize'], $element['#value']);
     if (!empty($element['#value']) && !Bytes::validate($element['#value'])) {
-      $form_state->setError($element, t('The "@name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', ['@name' => $element['#title']]));
+      $form_state->setError($element, new TranslatableMarkup('The "@name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', ['@name' => $element['#title']]));
     }
   }
 
diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
index bca41a067442..492182c7da9c 100644
--- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
+++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php
@@ -10,6 +10,7 @@
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Render\Element;
 use Drupal\Core\Render\ElementInfoManagerInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\file\Element\ManagedFile;
 use Drupal\file\Entity\File;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -63,13 +64,13 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['progress_indicator'] = [
       '#type' => 'radios',
-      '#title' => t('Progress indicator'),
+      '#title' => $this->t('Progress indicator'),
       '#options' => [
-        'throbber' => t('Throbber'),
-        'bar' => t('Bar with progress meter'),
+        'throbber' => $this->t('Throbber'),
+        'bar' => $this->t('Bar with progress meter'),
       ],
       '#default_value' => $this->getSetting('progress_indicator'),
-      '#description' => t('The throbber display does not show the status of uploads but takes up less space. The progress bar is helpful for monitoring progress on large uploads.'),
+      '#description' => $this->t('The throbber display does not show the status of uploads but takes up less space. The progress bar is helpful for monitoring progress on large uploads.'),
       '#weight' => 16,
       '#access' => file_progress_implementation(),
     ];
@@ -81,7 +82,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('Progress indicator: @progress_indicator', ['@progress_indicator' => $this->getSetting('progress_indicator')]);
+    $summary[] = $this->t('Progress indicator: @progress_indicator', ['@progress_indicator' => $this->getSetting('progress_indicator')]);
     return $summary;
   }
 
@@ -137,7 +138,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
           // defined by widget.
           $element['_weight'] = [
             '#type' => 'weight',
-            '#title' => t('Weight for row @number', ['@number' => $delta + 1]),
+            '#title' => $this->t('Weight for row @number', ['@number' => $delta + 1]),
             '#title_display' => 'invisible',
             // Note: this 'delta' is the FAPI #type 'weight' element's property.
             '#delta' => $max,
@@ -193,7 +194,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
       // Add some properties that will eventually be added to the file upload
       // field. These are added here so that they may be referenced easily
       // through a hook_form_alter().
-      $elements['#file_upload_title'] = t('Add a new file');
+      $elements['#file_upload_title'] = $this->t('Add a new file');
       $elements['#file_upload_description'] = [
         '#theme' => 'file_upload_help',
         '#description' => '',
@@ -368,7 +369,7 @@ public static function validateMultipleCount($element, FormStateInterface $form_
         '@count' => $total_uploaded_count,
         '%list' => implode(', ', $removed_names),
       ];
-      $message = t('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args);
+      $message = new TranslatableMarkup('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args);
       \Drupal::messenger()->addWarning($message);
       $values['fids'] = array_slice($values['fids'], 0, $keep);
       NestedArray::setValue($form_state->getValues(), $element['#parents'], $values);
@@ -391,7 +392,7 @@ public static function process($element, FormStateInterface $form_state, $form)
     if ($element['#display_field']) {
       $element['display'] = [
         '#type' => empty($item['fids']) ? 'hidden' : 'checkbox',
-        '#title' => t('Include file in display'),
+        '#title' => new TranslatableMarkup('Include file in display'),
         '#attributes' => ['class' => ['file-display']],
       ];
       if (isset($item['display'])) {
@@ -413,10 +414,10 @@ public static function process($element, FormStateInterface $form_state, $form)
       $config = \Drupal::config('file.settings');
       $element['description'] = [
         '#type' => $config->get('description.type'),
-        '#title' => t('Description'),
+        '#title' => new TranslatableMarkup('Description'),
         '#value' => $item['description'] ?? '',
         '#maxlength' => $config->get('description.length'),
-        '#description' => t('The description may be used as the label of the link to the file.'),
+        '#description' => new TranslatableMarkup('The description may be used as the label of the link to the file.'),
       ];
     }
 
@@ -483,7 +484,7 @@ public static function processMultiple($element, FormStateInterface $form_state,
         $description = static::getDescriptionFromElement($element[$key]);
         $element[$key]['_weight'] = [
           '#type' => 'weight',
-          '#title' => $description ? t('Weight for @title', ['@title' => $description]) : t('Weight for new file'),
+          '#title' => $description ? new TranslatableMarkup('Weight for @title', ['@title' => $description]) : new TranslatableMarkup('Weight for new file'),
           '#title_display' => 'invisible',
           '#delta' => $count,
           '#default_value' => $delta,
diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
index 549d6d45c3b3..9f51708b1c18 100644
--- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
+++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
@@ -129,24 +129,24 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
       Url::fromRoute('entity.image_style.collection')
     );
     $element['image_style'] = [
-      '#title' => t('Image style'),
+      '#title' => $this->t('Image style'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('image_style'),
-      '#empty_option' => t('None (original image)'),
+      '#empty_option' => $this->t('None (original image)'),
       '#options' => $image_styles,
       '#description' => $description_link->toRenderable() + [
         '#access' => $this->currentUser->hasPermission('administer image styles'),
       ],
     ];
     $link_types = [
-      'content' => t('Content'),
-      'file' => t('File'),
+      'content' => $this->t('Content'),
+      'file' => $this->t('File'),
     ];
     $element['image_link'] = [
-      '#title' => t('Link image to'),
+      '#title' => $this->t('Link image to'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('image_link'),
-      '#empty_option' => t('Nothing'),
+      '#empty_option' => $this->t('Nothing'),
       '#options' => $link_types,
     ];
 
@@ -189,15 +189,15 @@ public function settingsSummary() {
     // their styles in code.
     $image_style_setting = $this->getSetting('image_style');
     if (isset($image_styles[$image_style_setting])) {
-      $summary[] = t('Image style: @style', ['@style' => $image_styles[$image_style_setting]]);
+      $summary[] = $this->t('Image style: @style', ['@style' => $image_styles[$image_style_setting]]);
     }
     else {
-      $summary[] = t('Original image');
+      $summary[] = $this->t('Original image');
     }
 
     $link_types = [
-      'content' => t('Linked to content'),
-      'file' => t('Linked to file'),
+      'content' => $this->t('Linked to content'),
+      'file' => $this->t('Linked to file'),
     ];
     // Display this setting only if image is linked.
     $image_link_setting = $this->getSetting('image_link');
diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
index fa6ea636e290..731cdbed4f0d 100644
--- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
+++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
@@ -10,6 +10,7 @@
 use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\StreamWrapper\StreamWrapperInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\TypedData\DataDefinition;
 use Drupal\file\Entity\File;
 use Drupal\file\Plugin\Field\FieldType\FileItem;
@@ -142,20 +143,20 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel
     unset($properties['description']);
 
     $properties['alt'] = DataDefinition::create('string')
-      ->setLabel(t('Alternative text'))
-      ->setDescription(t("Alternative image text, for the image's 'alt' attribute."));
+      ->setLabel(new TranslatableMarkup('Alternative text'))
+      ->setDescription(new TranslatableMarkup("Alternative image text, for the image's 'alt' attribute."));
 
     $properties['title'] = DataDefinition::create('string')
-      ->setLabel(t('Title'))
-      ->setDescription(t("Image title text, for the image's 'title' attribute."));
+      ->setLabel(new TranslatableMarkup('Title'))
+      ->setDescription(new TranslatableMarkup("Image title text, for the image's 'title' attribute."));
 
     $properties['width'] = DataDefinition::create('integer')
-      ->setLabel(t('Width'))
-      ->setDescription(t('The width of the image in pixels.'));
+      ->setLabel(new TranslatableMarkup('Width'))
+      ->setDescription(new TranslatableMarkup('The width of the image in pixels.'));
 
     $properties['height'] = DataDefinition::create('integer')
-      ->setLabel(t('Height'))
-      ->setDescription(t('The height of the image in pixels.'));
+      ->setLabel(new TranslatableMarkup('Height'))
+      ->setDescription(new TranslatableMarkup('The height of the image in pixels.'));
 
     return $properties;
   }
@@ -174,15 +175,15 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
     $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE);
     $element['uri_scheme'] = [
       '#type' => 'radios',
-      '#title' => t('Upload destination'),
+      '#title' => $this->t('Upload destination'),
       '#options' => $scheme_options,
       '#default_value' => $settings['uri_scheme'],
-      '#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
+      '#description' => $this->t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'),
     ];
 
     // Add default_image element.
     static::defaultImageForm($element, $settings);
-    $element['default_image']['#description'] = t('If no image is uploaded, this image will be shown on display.');
+    $element['default_image']['#description'] = $this->t('If no image is uploaded, this image will be shown on display.');
 
     return $element;
   }
@@ -200,14 +201,14 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     $max_resolution = explode('x', $settings['max_resolution']) + ['', ''];
     $element['max_resolution'] = [
       '#type' => 'item',
-      '#title' => t('Maximum image resolution'),
+      '#title' => $this->t('Maximum image resolution'),
       '#element_validate' => [[static::class, 'validateResolution']],
       '#weight' => 4.1,
-      '#description' => t('The maximum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height. Resizing images on upload will cause the loss of <a href="http://wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image.'),
+      '#description' => $this->t('The maximum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height. Resizing images on upload will cause the loss of <a href="http://wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image.'),
     ];
     $element['max_resolution']['x'] = [
       '#type' => 'number',
-      '#title' => t('Maximum width'),
+      '#title' => $this->t('Maximum width'),
       '#title_display' => 'invisible',
       '#default_value' => $max_resolution[0],
       '#min' => 1,
@@ -216,25 +217,25 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     ];
     $element['max_resolution']['y'] = [
       '#type' => 'number',
-      '#title' => t('Maximum height'),
+      '#title' => $this->t('Maximum height'),
       '#title_display' => 'invisible',
       '#default_value' => $max_resolution[1],
       '#min' => 1,
-      '#field_suffix' => ' ' . t('pixels'),
+      '#field_suffix' => ' ' . $this->t('pixels'),
       '#suffix' => '</div>',
     ];
 
     $min_resolution = explode('x', $settings['min_resolution']) + ['', ''];
     $element['min_resolution'] = [
       '#type' => 'item',
-      '#title' => t('Minimum image resolution'),
+      '#title' => $this->t('Minimum image resolution'),
       '#element_validate' => [[static::class, 'validateResolution']],
       '#weight' => 4.2,
-      '#description' => t('The minimum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a smaller image is uploaded, it will be rejected.'),
+      '#description' => $this->t('The minimum allowed image size expressed as WIDTH×HEIGHT (e.g. 640×480). Leave blank for no restriction. If a smaller image is uploaded, it will be rejected.'),
     ];
     $element['min_resolution']['x'] = [
       '#type' => 'number',
-      '#title' => t('Minimum width'),
+      '#title' => $this->t('Minimum width'),
       '#title_display' => 'invisible',
       '#default_value' => $min_resolution[0],
       '#min' => 1,
@@ -243,11 +244,11 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     ];
     $element['min_resolution']['y'] = [
       '#type' => 'number',
-      '#title' => t('Minimum height'),
+      '#title' => $this->t('Minimum height'),
       '#title_display' => 'invisible',
       '#default_value' => $min_resolution[1],
       '#min' => 1,
-      '#field_suffix' => ' ' . t('pixels'),
+      '#field_suffix' => ' ' . $this->t('pixels'),
       '#suffix' => '</div>',
     ];
 
@@ -257,16 +258,16 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     // Add title and alt configuration options.
     $element['alt_field'] = [
       '#type' => 'checkbox',
-      '#title' => t('Enable <em>Alt</em> field'),
+      '#title' => $this->t('Enable <em>Alt</em> field'),
       '#default_value' => $settings['alt_field'],
-      '#description' => t('Short description of the image used by screen readers and displayed when the image is not loaded. Enabling this field is recommended.'),
+      '#description' => $this->t('Short description of the image used by screen readers and displayed when the image is not loaded. Enabling this field is recommended.'),
       '#weight' => 9,
     ];
     $element['alt_field_required'] = [
       '#type' => 'checkbox',
-      '#title' => t('<em>Alt</em> field required'),
+      '#title' => $this->t('<em>Alt</em> field required'),
       '#default_value' => $settings['alt_field_required'],
-      '#description' => t('Making this field required is recommended.'),
+      '#description' => $this->t('Making this field required is recommended.'),
       '#weight' => 10,
       '#states' => [
         'visible' => [
@@ -276,14 +277,14 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     ];
     $element['title_field'] = [
       '#type' => 'checkbox',
-      '#title' => t('Enable <em>Title</em> field'),
+      '#title' => $this->t('Enable <em>Title</em> field'),
       '#default_value' => $settings['title_field'],
-      '#description' => t('The title attribute is used as a tooltip when the mouse hovers over the image. Enabling this field is not recommended as it can cause problems with screen readers.'),
+      '#description' => $this->t('The title attribute is used as a tooltip when the mouse hovers over the image. Enabling this field is not recommended as it can cause problems with screen readers.'),
       '#weight' => 11,
     ];
     $element['title_field_required'] = [
       '#type' => 'checkbox',
-      '#title' => t('<em>Title</em> field required'),
+      '#title' => $this->t('<em>Title</em> field required'),
       '#default_value' => $settings['title_field_required'],
       '#weight' => 12,
       '#states' => [
@@ -295,7 +296,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     // Add default_image element.
     static::defaultImageForm($element, $settings);
-    $element['default_image']['#description'] = t("If no image is uploaded, this image will be shown on display and will override the field's default image.");
+    $element['default_image']['#description'] = $this->t("If no image is uploaded, this image will be shown on display and will override the field's default image.");
 
     return $element;
   }
@@ -395,9 +396,9 @@ public static function validateResolution($element, FormStateInterface $form_sta
     if (!empty($element['x']['#value']) || !empty($element['y']['#value'])) {
       foreach (['x', 'y'] as $dimension) {
         if (!$element[$dimension]['#value']) {
-          // We expect the field name placeholder value to be wrapped in t()
+          // We expect the field name placeholder value to be wrapped in $this->t()
           // here, so it won't be escaped again as it's already marked safe.
-          $form_state->setError($element[$dimension], t('Both a height and width value must be specified in the @name field.', ['@name' => $element['#title']]));
+          $form_state->setError($element[$dimension], new TranslatableMarkup('Both a height and width value must be specified in the @name field.', ['@name' => $element['#title']]));
           return;
         }
       }
@@ -419,7 +420,7 @@ public static function validateResolution($element, FormStateInterface $form_sta
   protected function defaultImageForm(array &$element, array $settings) {
     $element['default_image'] = [
       '#type' => 'details',
-      '#title' => t('Default image'),
+      '#title' => $this->t('Default image'),
       '#open' => TRUE,
     ];
     // Convert the stored UUID to a FID.
@@ -430,8 +431,8 @@ protected function defaultImageForm(array &$element, array $settings) {
     }
     $element['default_image']['uuid'] = [
       '#type' => 'managed_file',
-      '#title' => t('Image'),
-      '#description' => t('Image to be shown if no image is uploaded.'),
+      '#title' => $this->t('Image'),
+      '#description' => $this->t('Image to be shown if no image is uploaded.'),
       '#default_value' => $fids,
       '#upload_location' => $settings['uri_scheme'] . '://default_images/',
       '#element_validate' => [
@@ -442,15 +443,15 @@ protected function defaultImageForm(array &$element, array $settings) {
     ];
     $element['default_image']['alt'] = [
       '#type' => 'textfield',
-      '#title' => t('Alternative text'),
-      '#description' => t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),
+      '#title' => $this->t('Alternative text'),
+      '#description' => $this->t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),
       '#default_value' => $settings['default_image']['alt'],
       '#maxlength' => 512,
     ];
     $element['default_image']['title'] = [
       '#type' => 'textfield',
-      '#title' => t('Title'),
-      '#description' => t('The title attribute is used as a tooltip when the mouse hovers over the image.'),
+      '#title' => $this->t('Title'),
+      '#description' => $this->t('The title attribute is used as a tooltip when the mouse hovers over the image.'),
       '#default_value' => $settings['default_image']['title'],
       '#maxlength' => 1024,
     ];
diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
index 5a602339a226..3037615d8aed 100644
--- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -7,6 +7,7 @@
 use Drupal\Core\Image\ImageFactory;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Render\ElementInfoManagerInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\file\Entity\File;
 use Drupal\file\Plugin\Field\FieldWidget\FileWidget;
 use Drupal\image\Entity\ImageStyle;
@@ -71,12 +72,12 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     $element = parent::settingsForm($form, $form_state);
 
     $element['preview_image_style'] = [
-      '#title' => t('Preview image style'),
+      '#title' => $this->t('Preview image style'),
       '#type' => 'select',
       '#options' => image_style_options(FALSE),
-      '#empty_option' => '<' . t('no preview') . '>',
+      '#empty_option' => '<' . $this->t('no preview') . '>',
       '#default_value' => $this->getSetting('preview_image_style'),
-      '#description' => t('The preview image will be shown while editing the content.'),
+      '#description' => $this->t('The preview image will be shown while editing the content.'),
       '#weight' => 15,
     ];
 
@@ -96,10 +97,10 @@ public function settingsSummary() {
     // their styles in code.
     $image_style_setting = $this->getSetting('preview_image_style');
     if (isset($image_styles[$image_style_setting])) {
-      $preview_image_style = t('Preview image style: @style', ['@style' => $image_styles[$image_style_setting]]);
+      $preview_image_style = $this->t('Preview image style: @style', ['@style' => $image_styles[$image_style_setting]]);
     }
     else {
-      $preview_image_style = t('No preview');
+      $preview_image_style = $this->t('No preview');
     }
 
     array_unshift($summary, $preview_image_style);
@@ -256,10 +257,10 @@ public static function process($element, FormStateInterface $form_state, $form)
 
     // Add the additional alt and title fields.
     $element['alt'] = [
-      '#title' => t('Alternative text'),
+      '#title' => new TranslatableMarkup('Alternative text'),
       '#type' => 'textfield',
       '#default_value' => $item['alt'] ?? '',
-      '#description' => t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),
+      '#description' => new TranslatableMarkup('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'),
       // @see https://www.drupal.org/node/465106#alt-text
       '#maxlength' => 512,
       '#weight' => -12,
@@ -269,9 +270,9 @@ public static function process($element, FormStateInterface $form_state, $form)
     ];
     $element['title'] = [
       '#type' => 'textfield',
-      '#title' => t('Title'),
+      '#title' => new TranslatableMarkup('Title'),
       '#default_value' => $item['title'] ?? '',
-      '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'),
+      '#description' => new TranslatableMarkup('The title is used as a tool tip when the user hovers the mouse over the image.'),
       '#maxlength' => 1024,
       '#weight' => -11,
       '#access' => (bool) $item['fids'] && $element['#title_field'],
diff --git a/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php
index 61fb4d478c89..4e848326cf6a 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php
@@ -67,7 +67,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     );
     $form['extension'] = [
       '#type' => 'select',
-      '#title' => t('Convert to'),
+      '#title' => $this->t('Convert to'),
       '#default_value' => $this->configuration['extension'],
       '#required' => TRUE,
       '#options' => $options,
diff --git a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php
index cdacda96b7cf..8f99de88134f 100644
--- a/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php
@@ -59,21 +59,21 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['anchor'] = [
       '#type' => 'radios',
-      '#title' => t('Anchor'),
+      '#title' => $this->t('Anchor'),
       '#options' => [
-        'left-top' => t('Top left'),
-        'center-top' => t('Top center'),
-        'right-top' => t('Top right'),
-        'left-center' => t('Center left'),
-        'center-center' => t('Center'),
-        'right-center' => t('Center right'),
-        'left-bottom' => t('Bottom left'),
-        'center-bottom' => t('Bottom center'),
-        'right-bottom' => t('Bottom right'),
+        'left-top' => $this->t('Top left'),
+        'center-top' => $this->t('Top center'),
+        'right-top' => $this->t('Top right'),
+        'left-center' => $this->t('Center left'),
+        'center-center' => $this->t('Center'),
+        'right-center' => $this->t('Center right'),
+        'left-bottom' => $this->t('Bottom left'),
+        'center-bottom' => $this->t('Bottom center'),
+        'right-bottom' => $this->t('Bottom right'),
       ],
       '#theme' => 'image_anchor',
       '#default_value' => $this->configuration['anchor'],
-      '#description' => t('The part of the image that will be retained during the crop.'),
+      '#description' => $this->t('The part of the image that will be retained during the crop.'),
     ];
     return $form;
   }
diff --git a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php
index dba34298def9..26f70705db41 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ResizeImageEffect.php
@@ -66,17 +66,17 @@ public function defaultConfiguration() {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['width'] = [
       '#type' => 'number',
-      '#title' => t('Width'),
+      '#title' => $this->t('Width'),
       '#default_value' => $this->configuration['width'],
-      '#field_suffix' => ' ' . t('pixels'),
+      '#field_suffix' => ' ' . $this->t('pixels'),
       '#required' => TRUE,
       '#min' => 1,
     ];
     $form['height'] = [
       '#type' => 'number',
-      '#title' => t('Height'),
+      '#title' => $this->t('Height'),
       '#default_value' => $this->configuration['height'],
-      '#field_suffix' => ' ' . t('pixels'),
+      '#field_suffix' => ' ' . $this->t('pixels'),
       '#required' => TRUE,
       '#min' => 1,
     ];
diff --git a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
index 7e394a3cce67..d6453dbf9460 100644
--- a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
@@ -83,24 +83,24 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     $form['degrees'] = [
       '#type' => 'number',
       '#default_value' => $this->configuration['degrees'],
-      '#title' => t('Rotation angle'),
-      '#description' => t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative are counter-clockwise.'),
+      '#title' => $this->t('Rotation angle'),
+      '#description' => $this->t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative are counter-clockwise.'),
       '#field_suffix' => '°',
       '#required' => TRUE,
     ];
     $form['bgcolor'] = [
       '#type' => 'textfield',
       '#default_value' => $this->configuration['bgcolor'],
-      '#title' => t('Background color'),
-      '#description' => t('The background color to use for exposed areas of the image. Use web-style hex colors (#FFFFFF for white, #000000 for black). Leave blank for transparency on image types that support it.'),
+      '#title' => $this->t('Background color'),
+      '#description' => $this->t('The background color to use for exposed areas of the image. Use web-style hex colors (#FFFFFF for white, #000000 for black). Leave blank for transparency on image types that support it.'),
       '#size' => 7,
       '#maxlength' => 7,
     ];
     $form['random'] = [
       '#type' => 'checkbox',
       '#default_value' => $this->configuration['random'],
-      '#title' => t('Randomize'),
-      '#description' => t('Randomize the rotation angle for each image. The angle specified above is used as a maximum.'),
+      '#title' => $this->t('Randomize'),
+      '#description' => $this->t('Randomize the rotation angle for each image. The angle specified above is used as a maximum.'),
     ];
     return $form;
   }
diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
index bfb6d942fb9a..13e5aaa2d2fd 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
@@ -69,8 +69,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     $form['upscale'] = [
       '#type' => 'checkbox',
       '#default_value' => $this->configuration['upscale'],
-      '#title' => t('Allow Upscaling'),
-      '#description' => t('Let scale make images larger than their original size.'),
+      '#title' => $this->t('Allow Upscaling'),
+      '#description' => $this->t('Let scale make images larger than their original size.'),
     ];
     return $form;
   }
diff --git a/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyAjaxFormatter.php b/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyAjaxFormatter.php
index cebc54becaad..0952a48dc6d8 100644
--- a/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyAjaxFormatter.php
+++ b/core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldFormatter/DummyAjaxFormatter.php
@@ -24,7 +24,7 @@ class DummyAjaxFormatter extends FormatterBase {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('Renders nothing');
+    $summary[] = $this->t('Renders nothing');
     return $summary;
   }
 
diff --git a/core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/AjaxTestImageEffect.php b/core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/AjaxTestImageEffect.php
index a18c2637c083..1a8cfd7eea88 100644
--- a/core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/AjaxTestImageEffect.php
+++ b/core/modules/image/tests/modules/image_module_test/src/Plugin/ImageEffect/AjaxTestImageEffect.php
@@ -33,7 +33,7 @@ public function defaultConfiguration() {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['test_parameter'] = [
       '#type' => 'number',
-      '#title' => t('Test parameter'),
+      '#title' => $this->t('Test parameter'),
       '#default_value' => $this->configuration['test_parameter'],
       '#min' => 0,
     ];
diff --git a/core/modules/language/src/Plugin/Condition/Language.php b/core/modules/language/src/Plugin/Condition/Language.php
index f727dc7705f1..62008496ecfe 100644
--- a/core/modules/language/src/Plugin/Condition/Language.php
+++ b/core/modules/language/src/Plugin/Condition/Language.php
@@ -122,9 +122,9 @@ public function summary() {
       $languages = array_pop($language_names);
     }
     if (!empty($this->configuration['negate'])) {
-      return t('The language is not @languages.', ['@languages' => $languages]);
+      return $this->t('The language is not @languages.', ['@languages' => $languages]);
     }
-    return t('The language is @languages.', ['@languages' => $languages]);
+    return $this->t('The language is @languages.', ['@languages' => $languages]);
   }
 
   /**
diff --git a/core/modules/language/src/Plugin/Derivative/LanguageBlock.php b/core/modules/language/src/Plugin/Derivative/LanguageBlock.php
index 93cc5b1c98ef..54f0c1745f13 100644
--- a/core/modules/language/src/Plugin/Derivative/LanguageBlock.php
+++ b/core/modules/language/src/Plugin/Derivative/LanguageBlock.php
@@ -3,6 +3,7 @@
 namespace Drupal\language\Plugin\Derivative;
 
 use Drupal\Component\Plugin\Derivative\DeriverBase;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\language\ConfigurableLanguageManagerInterface;
 
 /**
@@ -10,6 +11,8 @@
  */
 class LanguageBlock extends DeriverBase {
 
+  use StringTranslationTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -21,12 +24,12 @@ public function getDerivativeDefinitions($base_plugin_definition) {
       $configurable_types = $language_manager->getLanguageTypes();
       foreach ($configurable_types as $type) {
         $this->derivatives[$type] = $base_plugin_definition;
-        $this->derivatives[$type]['admin_label'] = t('Language switcher (@type)', ['@type' => $info[$type]['name']]);
+        $this->derivatives[$type]['admin_label'] = $this->t('Language switcher (@type)', ['@type' => $info[$type]['name']]);
       }
       // If there is just one configurable type then change the title of the
       // block.
       if (count($configurable_types) == 1) {
-        $this->derivatives[reset($configurable_types)]['admin_label'] = t('Language switcher');
+        $this->derivatives[reset($configurable_types)]['admin_label'] = $this->t('Language switcher');
       }
     }
 
diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php
index 83f1a2f27053..16bcb513e8ab 100644
--- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php
+++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php
@@ -94,21 +94,21 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
 
     $elements['trim_length'] = [
       '#type' => 'number',
-      '#title' => t('Trim link text length'),
-      '#field_suffix' => t('characters'),
+      '#title' => $this->t('Trim link text length'),
+      '#field_suffix' => $this->t('characters'),
       '#default_value' => $this->getSetting('trim_length'),
       '#min' => 1,
-      '#description' => t('Leave blank to allow unlimited link text lengths.'),
+      '#description' => $this->t('Leave blank to allow unlimited link text lengths.'),
     ];
     $elements['url_only'] = [
       '#type' => 'checkbox',
-      '#title' => t('URL only'),
+      '#title' => $this->t('URL only'),
       '#default_value' => $this->getSetting('url_only'),
       '#access' => $this->getPluginId() == 'link',
     ];
     $elements['url_plain'] = [
       '#type' => 'checkbox',
-      '#title' => t('Show URL as plain text'),
+      '#title' => $this->t('Show URL as plain text'),
       '#default_value' => $this->getSetting('url_plain'),
       '#access' => $this->getPluginId() == 'link',
       '#states' => [
@@ -119,13 +119,13 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     ];
     $elements['rel'] = [
       '#type' => 'checkbox',
-      '#title' => t('Add rel="nofollow" to links'),
+      '#title' => $this->t('Add rel="nofollow" to links'),
       '#return_value' => 'nofollow',
       '#default_value' => $this->getSetting('rel'),
     ];
     $elements['target'] = [
       '#type' => 'checkbox',
-      '#title' => t('Open link in new window'),
+      '#title' => $this->t('Open link in new window'),
       '#return_value' => '_blank',
       '#default_value' => $this->getSetting('target'),
     ];
@@ -142,24 +142,24 @@ public function settingsSummary() {
     $settings = $this->getSettings();
 
     if (!empty($settings['trim_length'])) {
-      $summary[] = t('Link text trimmed to @limit characters', ['@limit' => $settings['trim_length']]);
+      $summary[] = $this->t('Link text trimmed to @limit characters', ['@limit' => $settings['trim_length']]);
     }
     else {
-      $summary[] = t('Link text not trimmed');
+      $summary[] = $this->t('Link text not trimmed');
     }
     if ($this->getPluginId() == 'link' && !empty($settings['url_only'])) {
       if (!empty($settings['url_plain'])) {
-        $summary[] = t('Show URL only as plain-text');
+        $summary[] = $this->t('Show URL only as plain-text');
       }
       else {
-        $summary[] = t('Show URL only');
+        $summary[] = $this->t('Show URL only');
       }
     }
     if (!empty($settings['rel'])) {
-      $summary[] = t('Add rel="@rel"', ['@rel' => $settings['rel']]);
+      $summary[] = $this->t('Add rel="@rel"', ['@rel' => $settings['rel']]);
     }
     if (!empty($settings['target'])) {
-      $summary[] = t('Open link in new window');
+      $summary[] = $this->t('Open link in new window');
     }
 
     return $summary;
diff --git a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
index 84556f8be093..9154eee1cd8a 100644
--- a/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
+++ b/core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
@@ -10,6 +10,7 @@
 use Drupal\Core\TypedData\DataDefinition;
 use Drupal\Core\TypedData\MapDataDefinition;
 use Drupal\Core\Url;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\link\LinkItemInterface;
 
 /**
@@ -41,13 +42,13 @@ public static function defaultFieldSettings() {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['uri'] = DataDefinition::create('uri')
-      ->setLabel(t('URI'));
+      ->setLabel(new TranslatableMarkup('URI'));
 
     $properties['title'] = DataDefinition::create('string')
-      ->setLabel(t('Link text'));
+      ->setLabel(new TranslatableMarkup('Link text'));
 
     $properties['options'] = MapDataDefinition::create()
-      ->setLabel(t('Options'));
+      ->setLabel(new TranslatableMarkup('Options'));
 
     return $properties;
   }
@@ -89,23 +90,23 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $element['link_type'] = [
       '#type' => 'radios',
-      '#title' => t('Allowed link type'),
+      '#title' => $this->t('Allowed link type'),
       '#default_value' => $this->getSetting('link_type'),
       '#options' => [
-        static::LINK_INTERNAL => t('Internal links only'),
-        static::LINK_EXTERNAL => t('External links only'),
-        static::LINK_GENERIC => t('Both internal and external links'),
+        static::LINK_INTERNAL => $this->t('Internal links only'),
+        static::LINK_EXTERNAL => $this->t('External links only'),
+        static::LINK_GENERIC => $this->t('Both internal and external links'),
       ],
     ];
 
     $element['title'] = [
       '#type' => 'radios',
-      '#title' => t('Allow link text'),
+      '#title' => $this->t('Allow link text'),
       '#default_value' => $this->getSetting('title'),
       '#options' => [
-        DRUPAL_DISABLED => t('Disabled'),
-        DRUPAL_OPTIONAL => t('Optional'),
-        DRUPAL_REQUIRED => t('Required'),
+        DRUPAL_DISABLED => $this->t('Disabled'),
+        DRUPAL_OPTIONAL => $this->t('Optional'),
+        DRUPAL_REQUIRED => $this->t('Required'),
       ],
     ];
 
diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
index 3d6d80f622b2..031f89bebad3 100644
--- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
+++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\link\Plugin\Field\FieldWidget;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Url;
 use Drupal\Core\Entity\Element\EntityAutocomplete;
 use Drupal\Core\Field\FieldItemListInterface;
@@ -71,7 +72,7 @@ protected static function getUriAsDisplayableString($uri) {
       $displayable_string = $uri_reference;
     }
     elseif ($scheme === 'entity') {
-      [$entity_type, $entity_id] = explode('/', substr($uri, 7), 2);
+      list($entity_type, $entity_id) = explode('/', substr($uri, 7), 2);
       // Show the 'entity:' URI as the entity autocomplete would.
       // @todo Support entity types other than 'node'. Will be fixed in
       //   https://www.drupal.org/node/2423093.
@@ -147,7 +148,7 @@ public static function validateUriElement($element, FormStateInterface $form_sta
     // @todo '<front>' is valid input for BC reasons, may be removed by
     //   https://www.drupal.org/node/2421941
     if (parse_url($uri, PHP_URL_SCHEME) === 'internal' && !in_array($element['#value'][0], ['/', '?', '#'], TRUE) && substr($element['#value'], 0, 7) !== '<front>') {
-      $form_state->setError($element, t('Manually entered paths should start with one of the following characters: / ? #'));
+      $form_state->setError($element, new TranslatableMarkup('Manually entered paths should start with one of the following characters: / ? #'));
       return;
     }
   }
@@ -159,9 +160,9 @@ public static function validateUriElement($element, FormStateInterface $form_sta
    */
   public static function validateTitleElement(&$element, FormStateInterface $form_state, $form) {
     if ($element['uri']['#value'] !== '' && $element['title']['#value'] === '') {
-      // We expect the field name placeholder value to be wrapped in t() here,
+      // We expect the field name placeholder value to be wrapped in $this->t() here,
       // so it won't be escaped again as it's already marked safe.
-      $form_state->setError($element['title'], t('@title field is required if there is @uri input.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
+      $form_state->setError($element['title'], new TranslatableMarkup('@title field is required if there is @uri input.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
     }
   }
 
@@ -172,7 +173,7 @@ public static function validateTitleElement(&$element, FormStateInterface $form_
    */
   public static function validateTitleNoLink(&$element, FormStateInterface $form_state, $form) {
     if ($element['uri']['#value'] === '' && $element['title']['#value'] !== '') {
-      $form_state->setError($element['uri'], t('The @uri field is required when the @title field is specified.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
+      $form_state->setError($element['uri'], new TranslatableMarkup('The @uri field is required when the @title field is specified.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
     }
   }
 
diff --git a/core/modules/media/src/Plugin/media/Source/OEmbed.php b/core/modules/media/src/Plugin/media/Source/OEmbed.php
index bfe8a7d86269..c1a870731e72 100644
--- a/core/modules/media/src/Plugin/media/Source/OEmbed.php
+++ b/core/modules/media/src/Plugin/media/Source/OEmbed.php
@@ -50,8 +50,8 @@
  * function example_media_source_info_alter(array &$sources) {
  *   $sources['artwork'] = [
  *     'id' => 'artwork',
- *     'label' => t('Artwork'),
- *     'description' => t('Use artwork from Flickr and DeviantArt.'),
+ *     'label' => $this->t('Artwork'),
+ *     'description' => $this->t('Use artwork from Flickr and DeviantArt.'),
  *     'allowed_field_types' => ['string'],
  *     'default_thumbnail_filename' => 'no-thumbnail.png',
  *     'providers' => ['Deviantart.com', 'Flickr'],
diff --git a/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php b/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php
index 8da3265f5b74..bdbc53556173 100644
--- a/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php
+++ b/core/modules/media/src/Plugin/media/Source/OEmbedDeriver.php
@@ -3,6 +3,7 @@
 namespace Drupal\media\Plugin\media\Source;
 
 use Drupal\Component\Plugin\Derivative\DeriverBase;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 
 /**
  * Derives media source plugin definitions for supported oEmbed providers.
@@ -13,6 +14,8 @@
  */
 class OEmbedDeriver extends DeriverBase {
 
+  use StringTranslationTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -20,8 +23,8 @@ public function getDerivativeDefinitions($base_plugin_definition) {
     $this->derivatives = [
       'video' => [
         'id' => 'video',
-        'label' => t('Remote video'),
-        'description' => t('Use remote video URL for reusable media.'),
+        'label' => $this->t('Remote video'),
+        'description' => $this->t('Use remote video URL for reusable media.'),
         'providers' => ['YouTube', 'Vimeo'],
         'default_thumbnail_filename' => 'video.png',
       ] + $base_plugin_definition,
diff --git a/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php b/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php
index 7e76940a0b35..abecd54dc179 100644
--- a/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php
+++ b/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php
@@ -18,6 +18,7 @@
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Security\TrustedCallbackInterface;
 use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Url;
 use Drupal\field_ui\FieldUI;
 use Drupal\media\Entity\Media;
@@ -205,7 +206,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
         'label' => ['#markup' => $label],
         'weight' => [
           '#type' => 'weight',
-          '#title' => t('Weight for @title', ['@title' => $label]),
+          '#title' => $this->t('Weight for @title', ['@title' => $label]),
           '#title_display' => 'invisible',
           '#default_value' => $weight,
           '#attributes' => ['class' => ['weight']],
@@ -267,7 +268,7 @@ public function settingsSummary() {
       foreach ($media_types as $media_type) {
         $media_type_labels[] = $media_type->label();
       }
-      $summary[] = t('Tab order: @order', ['@order' => implode(', ', $media_type_labels)]);
+      $summary[] = $this->t('Tab order: @order', ['@order' => implode(', ', $media_type_labels)]);
     }
     return $summary;
   }
@@ -699,7 +700,7 @@ public static function updateWidget(array $form, FormStateInterface $form_state)
 
     // Announce the updated content to screen readers.
     if ($is_remove_button) {
-      $announcement = t('@label has been removed.', [
+      $announcement = new TranslatableMarkup('@label has been removed.', [
         '@label' => Media::load($field_state['removed_item_id'])->label(),
       ]);
     }
@@ -851,7 +852,7 @@ public static function validateItems(array $form, FormStateInterface $form_state
     }, $element['#target_bundles']);
     foreach ($media as $media_item) {
       if ($element['#target_bundles'] && !in_array($media_item->bundle(), $element['#target_bundles'], TRUE)) {
-        $form_state->setError($element, t('The media item "@label" is not of an accepted type. Allowed types: @types', [
+        $form_state->setError($element, new TranslatableMarkup('The media item "@label" is not of an accepted type. Allowed types: @types', [
           '@label' => $media_item->label(),
           '@types' => implode(', ', $bundle_labels),
         ]));
@@ -1000,7 +1001,7 @@ public static function validateRequired(array $element, FormStateInterface $form
     // the Form API's default validation would also catch this, the validation
     // error message is too vague, so a more precise one is provided here.
     if (count($field_state['items']) === 0) {
-      $form_state->setError($element, t('@name field is required.', ['@name' => $element['#title']]));
+      $form_state->setError($element, new TranslatableMarkup('@name field is required.', ['@name' => $element['#title']]));
     }
   }
 
diff --git a/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
index f4309c131ca7..b998b6eb1e87 100644
--- a/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
+++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
@@ -73,31 +73,31 @@ public function query() {
    */
   public function fields() {
     $fields = [
-      'menu_name' => t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."),
-      'mlid' => t('The menu link ID (mlid) is the integer primary key.'),
-      'plid' => t('The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.'),
-      'link_path' => t('The Drupal path or external path this link points to.'),
-      'router_path' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.'),
-      'link_title' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'),
-      'options' => t('A serialized array of options to set on the URL, such as a query string or HTML attributes.'),
-      'module' => t('The name of the module that generated this link.'),
-      'hidden' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu link that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),
-      'external' => t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'),
-      'has_children' => t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'),
-      'expanded' => t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)'),
-      'weight' => t('Link weight among links in the same menu at the same depth.'),
-      'depth' => t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'),
-      'customized' => t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'),
-      'p1' => t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
-      'p2' => t('The second mlid in the materialized path. See p1.'),
-      'p3' => t('The third mlid in the materialized path. See p1.'),
-      'p4' => t('The fourth mlid in the materialized path. See p1.'),
-      'p5' => t('The fifth mlid in the materialized path. See p1.'),
-      'p6' => t('The sixth mlid in the materialized path. See p1.'),
-      'p7' => t('The seventh mlid in the materialized path. See p1.'),
-      'p8' => t('The eighth mlid in the materialized path. See p1.'),
-      'p9' => t('The ninth mlid in the materialized path. See p1.'),
-      'updated' => t('Flag that indicates that this link was generated during the update from Drupal 5.'),
+      'menu_name' => $this->t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."),
+      'mlid' => $this->t('The menu link ID (mlid) is the integer primary key.'),
+      'plid' => $this->t('The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.'),
+      'link_path' => $this->t('The Drupal path or external path this link points to.'),
+      'router_path' => $this->t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.'),
+      'link_title' => $this->t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'),
+      'options' => $this->t('A serialized array of options to set on the URL, such as a query string or HTML attributes.'),
+      'module' => $this->t('The name of the module that generated this link.'),
+      'hidden' => $this->t('A flag for whether the link should be rendered in menus. (1 = a disabled menu link that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),
+      'external' => $this->t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'),
+      'has_children' => $this->t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'),
+      'expanded' => $this->t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)'),
+      'weight' => $this->t('Link weight among links in the same menu at the same depth.'),
+      'depth' => $this->t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'),
+      'customized' => $this->t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'),
+      'p1' => $this->t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
+      'p2' => $this->t('The second mlid in the materialized path. See p1.'),
+      'p3' => $this->t('The third mlid in the materialized path. See p1.'),
+      'p4' => $this->t('The fourth mlid in the materialized path. See p1.'),
+      'p5' => $this->t('The fifth mlid in the materialized path. See p1.'),
+      'p6' => $this->t('The sixth mlid in the materialized path. See p1.'),
+      'p7' => $this->t('The seventh mlid in the materialized path. See p1.'),
+      'p8' => $this->t('The eighth mlid in the materialized path. See p1.'),
+      'p9' => $this->t('The ninth mlid in the materialized path. See p1.'),
+      'updated' => $this->t('Flag that indicates that this link was generated during the update from Drupal 5.'),
     ];
     $schema = $this->getDatabase()->schema();
     if ($schema->fieldExists('menu_links', 'language')) {
diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
index d0f31ffa0b4e..c419fa884289 100644
--- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -678,7 +678,7 @@ public function saveIdMapping(Row $row, array $destination_id_values, $source_ro
       $fields['destid' . ++$count] = $dest_id;
     }
     if ($count && $count != count($this->destinationIdFields())) {
-      $this->message->display(t('Could not save to map table due to missing destination id values'), 'error');
+      $this->message->display($this->t('Could not save to map table due to missing destination id values'), 'error');
       return;
     }
     if ($this->migration->getTrackLastImported()) {
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
index 123eb9c4cbe6..2991aeec7a26 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
@@ -34,7 +34,7 @@ class EmptySource extends SourcePluginBase {
    */
   public function fields() {
     return [
-      'id' => t('ID'),
+      'id' => $this->t('ID'),
     ];
   }
 
diff --git a/core/modules/migrate/tests/modules/migrate_sql_count_cache_test/src/Plugin/migrate/source/SqlCountCache.php b/core/modules/migrate/tests/modules/migrate_sql_count_cache_test/src/Plugin/migrate/source/SqlCountCache.php
index 48026d10a64f..5d01930706a3 100644
--- a/core/modules/migrate/tests/modules/migrate_sql_count_cache_test/src/Plugin/migrate/source/SqlCountCache.php
+++ b/core/modules/migrate/tests/modules/migrate_sql_count_cache_test/src/Plugin/migrate/source/SqlCountCache.php
@@ -18,7 +18,7 @@ class SqlCountCache extends SqlBase {
    */
   public function fields() {
     return [
-      'id' => t('Id'),
+      'id' => $this->t('Id'),
     ];
   }
 
diff --git a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
index ae9a7402b6b9..287dcb01898f 100644
--- a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
+++ b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
@@ -76,7 +76,7 @@ public function defaultConfiguration() {
    * {@inheritdoc}
    */
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
-    $description = t('The username of the user to which you would like to assign ownership.');
+    $description = $this->t('The username of the user to which you would like to assign ownership.');
     $count = $this->connection->query("SELECT COUNT(*) FROM {users}")->fetchField();
 
     // Use dropdown for fewer than 200 users; textbox for more than that.
@@ -88,7 +88,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
       }
       $form['owner_uid'] = [
         '#type' => 'select',
-        '#title' => t('Username'),
+        '#title' => $this->t('Username'),
         '#default_value' => $this->configuration['owner_uid'],
         '#options' => $options,
         '#description' => $description,
@@ -97,7 +97,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     else {
       $form['owner_uid'] = [
         '#type' => 'entity_autocomplete',
-        '#title' => t('Username'),
+        '#title' => $this->t('Username'),
         '#target_type' => 'user',
         '#selection_settings' => [
           'include_anonymous' => FALSE,
@@ -119,7 +119,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
     $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE [uid] = :uid AND [default_langcode] = 1', 0, 1, [':uid' => $form_state->getValue('owner_uid')])->fetchField();
     if (!$exists) {
-      $form_state->setErrorByName('owner_uid', t('Enter a valid username.'));
+      $form_state->setErrorByName('owner_uid', $this->t('Enter a valid username.'));
     }
   }
 
diff --git a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php
index 94abf8b63422..42f344d52ca2 100644
--- a/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php
+++ b/core/modules/node/src/Plugin/Action/UnpublishByKeywordNode.php
@@ -49,9 +49,9 @@ public function defaultConfiguration() {
    */
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['keywords'] = [
-      '#title' => t('Keywords'),
+      '#title' => $this->t('Keywords'),
       '#type' => 'textarea',
-      '#description' => t('The content will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
+      '#description' => $this->t('The content will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'),
       '#default_value' => Tags::implode($this->configuration['keywords']),
     ];
     return $form;
diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php
index 0342c5f01d29..1f6e16653006 100644
--- a/core/modules/node/src/Plugin/Search/NodeSearch.php
+++ b/core/modules/node/src/Plugin/Search/NodeSearch.php
@@ -584,14 +584,14 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) {
     // Add advanced search keyword-related boxes.
     $form['advanced'] = [
       '#type' => 'details',
-      '#title' => t('Advanced search'),
+      '#title' => $this->t('Advanced search'),
       '#attributes' => ['class' => ['search-advanced']],
       '#access' => $this->account && $this->account->hasPermission('use advanced search'),
       '#open' => $used_advanced,
     ];
     $form['advanced']['keywords-fieldset'] = [
       '#type' => 'fieldset',
-      '#title' => t('Keywords'),
+      '#title' => $this->t('Keywords'),
     ];
 
     $form['advanced']['keywords'] = [
@@ -601,7 +601,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) {
 
     $form['advanced']['keywords-fieldset']['keywords']['or'] = [
       '#type' => 'textfield',
-      '#title' => t('Containing any of the words'),
+      '#title' => $this->t('Containing any of the words'),
       '#size' => 30,
       '#maxlength' => 255,
       '#default_value' => $defaults['or'] ?? '',
@@ -609,7 +609,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) {
 
     $form['advanced']['keywords-fieldset']['keywords']['phrase'] = [
       '#type' => 'textfield',
-      '#title' => t('Containing the phrase'),
+      '#title' => $this->t('Containing the phrase'),
       '#size' => 30,
       '#maxlength' => 255,
       '#default_value' => $defaults['phrase'] ?? '',
@@ -617,7 +617,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) {
 
     $form['advanced']['keywords-fieldset']['keywords']['negative'] = [
       '#type' => 'textfield',
-      '#title' => t('Containing none of the words'),
+      '#title' => $this->t('Containing none of the words'),
       '#size' => 30,
       '#maxlength' => 255,
       '#default_value' => $defaults['negative'] ?? '',
@@ -627,11 +627,11 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) {
     $types = array_map(['\Drupal\Component\Utility\Html', 'escape'], node_type_get_names());
     $form['advanced']['types-fieldset'] = [
       '#type' => 'fieldset',
-      '#title' => t('Types'),
+      '#title' => $this->t('Types'),
     ];
     $form['advanced']['types-fieldset']['type'] = [
       '#type' => 'checkboxes',
-      '#title' => t('Only of the type(s)'),
+      '#title' => $this->t('Only of the type(s)'),
       '#prefix' => '<div class="criterion">',
       '#suffix' => '</div>',
       '#options' => $types,
@@ -640,7 +640,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) {
 
     $form['advanced']['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Advanced search'),
+      '#value' => $this->t('Advanced search'),
       '#prefix' => '<div class="action">',
       '#suffix' => '</div>',
       '#weight' => 100,
@@ -651,16 +651,16 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) {
     $language_list = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL);
     foreach ($language_list as $langcode => $language) {
       // Make locked languages appear special in the list.
-      $language_options[$langcode] = $language->isLocked() ? t('- @name -', ['@name' => $language->getName()]) : $language->getName();
+      $language_options[$langcode] = $language->isLocked() ? $this->t('- @name -', ['@name' => $language->getName()]) : $language->getName();
     }
     if (count($language_options) > 1) {
       $form['advanced']['lang-fieldset'] = [
         '#type' => 'fieldset',
-        '#title' => t('Languages'),
+        '#title' => $this->t('Languages'),
       ];
       $form['advanced']['lang-fieldset']['language'] = [
         '#type' => 'checkboxes',
-        '#title' => t('Languages'),
+        '#title' => $this->t('Languages'),
         '#prefix' => '<div class="criterion">',
         '#suffix' => '</div>',
         '#options' => $language_options,
@@ -823,7 +823,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     // Output form for defining rank factor weights.
     $form['content_ranking'] = [
       '#type' => 'details',
-      '#title' => t('Content ranking'),
+      '#title' => $this->t('Content ranking'),
       '#open' => TRUE,
     ];
     $form['content_ranking']['info'] = [
diff --git a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php
index a8fa1d0bbe1b..b5fdc54a90ff 100644
--- a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php
+++ b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Plugin\Derivative\DeriverBase;
 use Drupal\Core\Database\DatabaseExceptionWrapper;
 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\migrate\Exception\RequirementsException;
 use Drupal\migrate\Plugin\MigrationDeriverTrait;
 use Drupal\migrate_drupal\FieldDiscoveryInterface;
@@ -15,6 +16,7 @@
  */
 class D6NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
   use MigrationDeriverTrait;
+  use StringTranslationTrait;
 
   /**
    * The base plugin ID this derivative is for.
@@ -89,7 +91,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
         $node_type = $row->getSourceProperty('type');
         $values = $base_plugin_definition;
 
-        $values['label'] = t("@label (@type)", [
+        $values['label'] = $this->t("@label (@type)", [
           '@label' => $values['label'],
           '@type' => $node_type,
         ]);
diff --git a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php
index 380aab81e4ef..59b071413c6a 100644
--- a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php
+++ b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Plugin\Derivative\DeriverBase;
 use Drupal\Core\Database\DatabaseExceptionWrapper;
 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\migrate\Exception\RequirementsException;
 use Drupal\migrate\Plugin\MigrationDeriverTrait;
 use Drupal\migrate_drupal\FieldDiscoveryInterface;
@@ -15,6 +16,7 @@
  */
 class D7NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
   use MigrationDeriverTrait;
+  use StringTranslationTrait;
 
   /**
    * The base plugin ID this derivative is for.
@@ -89,7 +91,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
         $node_type = $row->getSourceProperty('type');
         $values = $base_plugin_definition;
 
-        $values['label'] = t('@label (@type)', [
+        $values['label'] = $this->t('@label (@type)', [
           '@label' => $values['label'],
           '@type' => $row->getSourceProperty('name'),
         ]);
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php b/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php
index a3420165e011..810c157b5c4f 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/NodeRevision.php
@@ -30,7 +30,7 @@ class NodeRevision extends Node {
   public function fields() {
     // Use all the node fields plus the vid that identifies the version.
     return parent::fields() + [
-      'vid' => t('The primary identifier for this version.'),
+      'vid' => $this->t('The primary identifier for this version.'),
       'log' => $this->t('Revision Log message'),
       'timestamp' => $this->t('Revision timestamp'),
     ];
diff --git a/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php b/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php
index 1b13b7bbf888..5be6ac3b3e23 100644
--- a/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php
+++ b/core/modules/node/src/Plugin/migrate/source/d7/NodeRevision.php
@@ -28,7 +28,7 @@ class NodeRevision extends Node {
   public function fields() {
     // Use all the node fields plus the vid that identifies the version.
     return parent::fields() + [
-      'vid' => t('The primary identifier for this version.'),
+      'vid' => $this->t('The primary identifier for this version.'),
       'log' => $this->t('Revision Log message'),
       'timestamp' => $this->t('Revision timestamp'),
     ];
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
index 855d5b46c348..a09152d509e4 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListFloatItem.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\TypedData\DataDefinition;
 
 /**
@@ -25,7 +26,7 @@ class ListFloatItem extends ListItemBase {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('float')
-      ->setLabel(t('Float value'))
+      ->setLabel(new TranslatableMarkup('Float value'))
       ->setRequired(TRUE);
 
     return $properties;
@@ -51,12 +52,12 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
    * {@inheritdoc}
    */
   protected function allowedValuesDescription() {
-    $description = '<p>' . t('The possible values this field can contain. Enter one value per line, in the format key|label.');
-    $description .= '<br/>' . t('The key is the stored value, and must be numeric. The label will be used in displayed values and edit forms.');
-    $description .= '<br/>' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
-    $description .= '<br/>' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
+    $description = '<p>' . $this->t('The possible values this field can contain. Enter one value per line, in the format key|label.');
+    $description .= '<br/>' . $this->t('The key is the stored value, and must be numeric. The label will be used in displayed values and edit forms.');
+    $description .= '<br/>' . $this->t('The label is optional: if a line contains a single number, it will be used as key and label.');
+    $description .= '<br/>' . $this->t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
     $description .= '</p>';
-    $description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '</p>';
+    $description .= '<p>' . $this->t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '</p>';
     return $description;
   }
 
@@ -83,7 +84,7 @@ protected static function extractAllowedValues($string, $has_data) {
    */
   protected static function validateAllowedValue($option) {
     if (!is_numeric($option)) {
-      return t('Allowed values list: each key must be a valid integer or decimal.');
+      return new TranslatableMarkup('Allowed values list: each key must be a valid integer or decimal.');
     }
   }
 
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php
index 8a9600751909..eabec6f0222b 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListIntegerItem.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\TypedData\DataDefinition;
 
 /**
@@ -25,7 +26,7 @@ class ListIntegerItem extends ListItemBase {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('integer')
-      ->setLabel(t('Integer value'))
+      ->setLabel(new TranslatableMarkup('Integer value'))
       ->setRequired(TRUE);
 
     return $properties;
@@ -51,12 +52,12 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
    * {@inheritdoc}
    */
   protected function allowedValuesDescription() {
-    $description = '<p>' . t('The possible values this field can contain. Enter one value per line, in the format key|label.');
-    $description .= '<br/>' . t('The key is the stored value, and must be numeric. The label will be used in displayed values and edit forms.');
-    $description .= '<br/>' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
-    $description .= '<br/>' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
+    $description = '<p>' . $this->t('The possible values this field can contain. Enter one value per line, in the format key|label.');
+    $description .= '<br/>' . $this->t('The key is the stored value, and must be numeric. The label will be used in displayed values and edit forms.');
+    $description .= '<br/>' . $this->t('The label is optional: if a line contains a single number, it will be used as key and label.');
+    $description .= '<br/>' . $this->t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
     $description .= '</p>';
-    $description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '</p>';
+    $description .= '<p>' . $this->t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '</p>';
     return $description;
   }
 
@@ -65,7 +66,7 @@ protected function allowedValuesDescription() {
    */
   protected static function validateAllowedValue($option) {
     if (!preg_match('/^-?\d+$/', $option)) {
-      return t('Allowed values list: keys must be integers.');
+      return new TranslatableMarkup('Allowed values list: keys must be integers.');
     }
   }
 
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
index 7c367589409c..62c32aa513a1 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
@@ -7,6 +7,7 @@
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Form\OptGroup;
 use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\TypedData\OptionsProviderInterface;
 
 /**
@@ -84,7 +85,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
 
     $element['allowed_values'] = [
       '#type' => 'textarea',
-      '#title' => t('Allowed values list'),
+      '#title' => $this->t('Allowed values list'),
       '#default_value' => $this->allowedValuesString($allowed_values),
       '#rows' => 10,
       '#access' => empty($allowed_values_function),
@@ -99,8 +100,8 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
 
     $element['allowed_values_function'] = [
       '#type' => 'item',
-      '#title' => t('Allowed values list'),
-      '#markup' => t('The value of this field is being determined by the %function function and may not be changed.', ['%function' => $allowed_values_function]),
+      '#title' => $this->t('Allowed values list'),
+      '#markup' => $this->t('The value of this field is being determined by the %function function and may not be changed.', ['%function' => $allowed_values_function]),
       '#access' => !empty($allowed_values_function),
       '#value' => $allowed_values_function,
     ];
@@ -131,7 +132,7 @@ public static function validateAllowedValues($element, FormStateInterface $form_
     $values = static::extractAllowedValues($element['#value'], $element['#field_has_data']);
 
     if (!is_array($values)) {
-      $form_state->setError($element, t('Allowed values list: invalid input.'));
+      $form_state->setError($element, new TranslatableMarkup('Allowed values list: invalid input.'));
     }
     else {
       // Check that keys are valid for the field type.
@@ -146,7 +147,7 @@ public static function validateAllowedValues($element, FormStateInterface $form_
       if ($element['#field_has_data']) {
         $lost_keys = array_keys(array_diff_key($element['#allowed_values'], $values));
         if (_options_values_in_use($element['#entity_type'], $element['#field_name'], $lost_keys)) {
-          $form_state->setError($element, t('Allowed values list: some values are being removed while currently in use.'));
+          $form_state->setError($element, new TranslatableMarkup('Allowed values list: some values are being removed while currently in use.'));
         }
       }
 
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
index 555030764325..acd86c0fa201 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\TypedData\DataDefinition;
 
 /**
@@ -25,7 +26,7 @@ class ListStringItem extends ListItemBase {
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('string')
-      ->setLabel(t('Text value'))
+      ->setLabel(new TranslatableMarkup('Text value'))
       ->addConstraint('Length', ['max' => 255])
       ->setRequired(TRUE);
 
@@ -53,11 +54,11 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
    * {@inheritdoc}
    */
   protected function allowedValuesDescription() {
-    $description = '<p>' . t('The possible values this field can contain. Enter one value per line, in the format key|label.');
-    $description .= '<br/>' . t('The key is the stored value. The label will be used in displayed values and edit forms.');
-    $description .= '<br/>' . t('The label is optional: if a line contains a single string, it will be used as key and label.');
+    $description = '<p>' . $this->t('The possible values this field can contain. Enter one value per line, in the format key|label.');
+    $description .= '<br/>' . $this->t('The key is the stored value. The label will be used in displayed values and edit forms.');
+    $description .= '<br/>' . $this->t('The label is optional: if a line contains a single string, it will be used as key and label.');
     $description .= '</p>';
-    $description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '</p>';
+    $description .= '<p>' . $this->t('Allowed HTML tags in labels: @tags', ['@tags' => FieldFilteredMarkup::displayAllowedTags()]) . '</p>';
     return $description;
   }
 
@@ -66,7 +67,7 @@ protected function allowedValuesDescription() {
    */
   protected static function validateAllowedValue($option) {
     if (mb_strlen($option) > 255) {
-      return t('Allowed values list: each key must be a string at most 255 characters long.');
+      return new TranslatableMarkup('Allowed values list: each key must be a string at most 255 characters long.');
     }
   }
 
diff --git a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
index 20d3aa8f5183..088ef784e216 100644
--- a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
+++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
@@ -56,7 +56,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
     if (isset($form['advanced'])) {
       $element += [
         '#type' => 'details',
-        '#title' => t('URL path settings'),
+        '#title' => $this->t('URL path settings'),
         '#open' => !empty($items[$delta]->alias),
         '#group' => 'advanced',
         '#access' => $entity->get('path')->access('edit'),
diff --git a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php
index c7594d98e5ca..0afb59ee64b4 100644
--- a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php
+++ b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php
@@ -137,7 +137,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     }
 
     $elements['responsive_image_style'] = [
-      '#title' => t('Responsive image style'),
+      '#title' => $this->t('Responsive image style'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('responsive_image_style') ?: NULL,
       '#required' => TRUE,
@@ -149,14 +149,14 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     ];
 
     $link_types = [
-      'content' => t('Content'),
-      'file' => t('File'),
+      'content' => $this->t('Content'),
+      'file' => $this->t('File'),
     ];
     $elements['image_link'] = [
-      '#title' => t('Link image to'),
+      '#title' => $this->t('Link image to'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('image_link'),
-      '#empty_option' => t('Nothing'),
+      '#empty_option' => $this->t('Nothing'),
       '#options' => $link_types,
     ];
 
@@ -171,11 +171,11 @@ public function settingsSummary() {
 
     $responsive_image_style = $this->responsiveImageStyleStorage->load($this->getSetting('responsive_image_style'));
     if ($responsive_image_style) {
-      $summary[] = t('Responsive image style: @responsive_image_style', ['@responsive_image_style' => $responsive_image_style->label()]);
+      $summary[] = $this->t('Responsive image style: @responsive_image_style', ['@responsive_image_style' => $responsive_image_style->label()]);
 
       $link_types = [
-        'content' => t('Linked to content'),
-        'file' => t('Linked to file'),
+        'content' => $this->t('Linked to content'),
+        'file' => $this->t('Linked to file'),
       ];
       // Display this setting only if image is linked.
       if (isset($link_types[$this->getSetting('image_link')])) {
@@ -183,7 +183,7 @@ public function settingsSummary() {
       }
     }
     else {
-      $summary[] = t('Select a responsive image style.');
+      $summary[] = $this->t('Select a responsive image style.');
     }
 
     return $summary;
diff --git a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php
index 2ae2682ba7d7..6037653f750b 100644
--- a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php
+++ b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php
@@ -91,16 +91,16 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     // Output form for defining rank factor weights.
     $form['extra_type_settings'] = [
       '#type' => 'fieldset',
-      '#title' => t('Extra type settings'),
+      '#title' => $this->t('Extra type settings'),
       '#tree' => TRUE,
     ];
 
     $form['extra_type_settings']['boost'] = [
       '#type' => 'select',
-      '#title' => t('Boost method'),
+      '#title' => $this->t('Boost method'),
       '#options' => [
-        'bi' => t('Bistro mathematics'),
-        'ii' => t('Infinite Improbability'),
+        'bi' => $this->t('Bistro mathematics'),
+        'ii' => $this->t('Infinite Improbability'),
       ],
       '#default_value' => $this->configuration['boost'],
     ];
diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
index 9218ae3ce686..cc0993f76e74 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
@@ -168,12 +168,12 @@ public function getResource() {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form['image_jpeg_quality'] = [
       '#type' => 'number',
-      '#title' => t('JPEG quality'),
-      '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
+      '#title' => $this->t('JPEG quality'),
+      '#description' => $this->t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
       '#min' => 0,
       '#max' => 100,
       '#default_value' => $this->configFactory->getEditable('system.image.gd')->get('jpeg_quality', FALSE),
-      '#field_suffix' => t('%'),
+      '#field_suffix' => $this->t('%'),
     ];
     return $form;
   }
@@ -395,14 +395,14 @@ public function getRequirements() {
 
     $info = gd_info();
     $requirements['version'] = [
-      'title' => t('GD library'),
+      'title' => $this->t('GD library'),
       'value' => $info['GD Version'],
     ];
 
     // Check for filter and rotate support.
     if (!function_exists('imagefilter') || !function_exists('imagerotate')) {
       $requirements['version']['severity'] = REQUIREMENT_WARNING;
-      $requirements['version']['description'] = t('The GD Library for PHP is enabled, but was compiled without support for functions used by the rotate and desaturate effects. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="http://php.net/manual/book.image.php">the PHP manual</a>.');
+      $requirements['version']['description'] = $this->t('The GD Library for PHP is enabled, but was compiled without support for functions used by the rotate and desaturate effects. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="http://php.net/manual/book.image.php">the PHP manual</a>.');
     }
 
     return $requirements;
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
index da2dc46240cb..1549978b4239 100644
--- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
@@ -32,8 +32,6 @@ class FieldTestItem extends FieldItemBase {
    * {@inheritdoc}
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
-    // This is called very early by the user entity roles field. Prevent
-    // early t() calls by using the TranslatableMarkup.
     $properties['value'] = DataDefinition::create('string')
       ->setLabel(new TranslatableMarkup('Test value'))
       ->setRequired(TRUE);
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php
index 766aa7a8d534..d53901f6b2c1 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php
@@ -8,12 +8,15 @@
 use Drupal\Component\Plugin\Factory\ReflectionFactory;
 use Drupal\Core\Plugin\Context\ContextDefinition;
 use Drupal\Core\Plugin\Context\EntityContextDefinition;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 
 /**
  * Defines a plugin manager used by Plugin API derivative unit tests.
  */
 class MockBlockManager extends PluginManagerBase {
 
+  use StringTranslationTrait;
+
   public function __construct() {
 
     // Create the object that can be used to return definitions for all the
@@ -38,7 +41,7 @@ public function __construct() {
     // A simple plugin: the user login block.
     $this->discovery->setDefinition('user_login', [
       'id' => 'user_login',
-      'label' => t('User login'),
+      'label' => $this->t('User login'),
       'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserLoginBlock',
     ]);
 
@@ -56,7 +59,7 @@ public function __construct() {
     // A plugin defining itself as a derivative.
     $this->discovery->setDefinition('menu:foo', [
       'id' => 'menu',
-      'label' => t('Base label'),
+      'label' => $this->t('Base label'),
       'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlock',
     ]);
 
@@ -68,7 +71,7 @@ public function __construct() {
     // derivatives are available to the system.
     $this->discovery->setDefinition('layout', [
       'id' => 'layout',
-      'label' => t('Layout'),
+      'label' => $this->t('Layout'),
       'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlock',
       'deriver' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver',
     ]);
@@ -77,38 +80,38 @@ public function __construct() {
     // user object in order to return the user name from the getTitle() method.
     $this->discovery->setDefinition('user_name', [
       'id' => 'user_name',
-      'label' => t('User name'),
+      'label' => $this->t('User name'),
       'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
       'context_definitions' => [
-        'user' => $this->createContextDefinition('entity:user', t('User')),
+        'user' => $this->createContextDefinition('entity:user', $this->t('User')),
       ],
     ]);
 
     // An optional context version of the previous block plugin.
     $this->discovery->setDefinition('user_name_optional', [
       'id' => 'user_name_optional',
-      'label' => t('User name optional'),
+      'label' => $this->t('User name optional'),
       'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
       'context_definitions' => [
-        'user' => $this->createContextDefinition('entity:user', t('User'), FALSE),
+        'user' => $this->createContextDefinition('entity:user', $this->t('User'), FALSE),
       ],
     ]);
 
     // A block plugin that requires a typed data string context to function.
     $this->discovery->setDefinition('string_context', [
       'id' => 'string_context',
-      'label' => t('String typed data'),
+      'label' => $this->t('String typed data'),
       'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\TypedDataStringBlock',
     ]);
 
     // A complex context plugin that requires both a user and node for context.
     $this->discovery->setDefinition('complex_context', [
       'id' => 'complex_context',
-      'label' => t('Complex context'),
+      'label' => $this->t('Complex context'),
       'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock',
       'context_definitions' => [
-        'user' => $this->createContextDefinition('entity:user', t('User')),
-        'node' => $this->createContextDefinition('entity:node', t('Node')),
+        'user' => $this->createContextDefinition('entity:user', $this->t('User')),
+        'node' => $this->createContextDefinition('entity:node', $this->t('Node')),
       ],
     ]);
 
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
index 93fca538b885..9f25c046faca 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
@@ -3,6 +3,7 @@
 namespace Drupal\plugin_test\Plugin\plugin_test\mock_block;
 
 use Drupal\Component\Plugin\Derivative\DeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 
 /**
  * Mock implementation of DeriverInterface for the mock layout block plugin.
@@ -11,6 +12,8 @@
  */
 class MockLayoutBlockDeriver implements DeriverInterface {
 
+  use StringTranslationTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -41,7 +44,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
       // customized one, but in a real implementation, this would be fetched
       // from some \Drupal::config() object.
       'foo' => [
-        'label' => t('Layout Foo'),
+        'label' => $this->t('Layout Foo'),
       ] + $base_plugin_definition,
     ];
 
diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
index 22ef9809a667..254bbdb71330 100644
--- a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
+++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php
@@ -3,6 +3,7 @@
 namespace Drupal\plugin_test\Plugin\plugin_test\mock_block;
 
 use Drupal\Component\Plugin\Derivative\DeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 
 /**
  * Mock implementation of DeriverInterface for the mock menu block plugin.
@@ -11,6 +12,8 @@
  */
 class MockMenuBlockDeriver implements DeriverInterface {
 
+  use StringTranslationTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -36,14 +39,14 @@ public function getDerivativeDefinitions($base_plugin_definition) {
     // Drupal's configuration to find out which menus actually exist.
     $derivatives = [
       'main_menu' => [
-        'label' => t('Main menu'),
+        'label' => $this->t('Main menu'),
       ] + $base_plugin_definition,
       'navigation' => [
-        'label' => t('Navigation'),
+        'label' => $this->t('Navigation'),
       ] + $base_plugin_definition,
       'foo' => [
         // Instead of the derivative label, the specific label will be used.
-        'label' => t('Derivative label'),
+        'label' => $this->t('Derivative label'),
         // This setting will be merged in.
         'setting' => 'default',
       ] + $base_plugin_definition,
diff --git a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php
index c116f813ede1..2306b87f472c 100644
--- a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php
+++ b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Plugin\Derivative\DeriverBase;
 use Drupal\Core\Database\DatabaseExceptionWrapper;
 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\migrate\Exception\RequirementsException;
 use Drupal\migrate\Plugin\MigrationDeriverTrait;
 use Drupal\migrate_drupal\FieldDiscoveryInterface;
@@ -15,6 +16,7 @@
  */
 class D7TaxonomyTermDeriver extends DeriverBase implements ContainerDeriverInterface {
   use MigrationDeriverTrait;
+  use StringTranslationTrait;
 
   /**
    * The base plugin ID this derivative is for.
@@ -74,7 +76,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
         $bundle = $row->getSourceProperty('machine_name');
         $values = $base_plugin_definition;
 
-        $values['label'] = t('@label (@type)', [
+        $values['label'] = $this->t('@label (@type)', [
           '@label' => $values['label'],
           '@type' => $row->getSourceProperty('name'),
         ]);
diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
index 76c9635559d9..7710bae695f2 100644
--- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
+++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -284,7 +284,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
       $this->helper->buildOptionsForm($form, $form_state);
 
       // Show help text if not exposed to end users.
-      $form['value']['#description'] = t('Leave blank for all. Otherwise, the first selected term will be the default instead of "Any".');
+      $form['value']['#description'] = $this->t('Leave blank for all. Otherwise, the first selected term will be the default instead of "Any".');
     }
   }
 
diff --git a/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php b/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php
index 60ee25cbc3d9..875f47ffa4ca 100644
--- a/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php
+++ b/core/modules/telephone/src/Plugin/Field/FieldFormatter/TelephoneLinkFormatter.php
@@ -35,7 +35,7 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $elements['title'] = [
       '#type' => 'textfield',
-      '#title' => t('Title to replace basic numeric telephone number display'),
+      '#title' => $this->t('Title to replace basic numeric telephone number display'),
       '#default_value' => $this->getSetting('title'),
     ];
 
@@ -50,10 +50,10 @@ public function settingsSummary() {
     $settings = $this->getSettings();
 
     if (!empty($settings['title'])) {
-      $summary[] = t('Link using text: @title', ['@title' => $settings['title']]);
+      $summary[] = $this->t('Link using text: @title', ['@title' => $settings['title']]);
     }
     else {
-      $summary[] = t('Link using provided telephone number.');
+      $summary[] = $this->t('Link using provided telephone number.');
     }
 
     return $summary;
diff --git a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php
index 17fc9d5e42ac..8fea6f93f0cf 100644
--- a/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php
+++ b/core/modules/telephone/src/Plugin/Field/FieldType/TelephoneItem.php
@@ -6,6 +6,7 @@
 use Drupal\Core\Field\FieldItemBase;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\TypedData\DataDefinition;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Plugin implementation of the 'telephone' field type.
@@ -40,7 +41,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition)
    */
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('string')
-      ->setLabel(t('Telephone number'))
+      ->setLabel(new TranslatableMarkup('Telephone number'))
       ->setRequired(TRUE);
 
     return $properties;
@@ -66,7 +67,7 @@ public function getConstraints() {
       'value' => [
         'Length' => [
           'max' => $max_length,
-          'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
+          'maxMessage' => $this->t('%name: the telephone number may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
         ],
       ],
     ]);
diff --git a/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php
index 99db3c13fe94..8887d06b0a9e 100644
--- a/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php
+++ b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php
@@ -34,9 +34,9 @@ public static function defaultSettings() {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['placeholder'] = [
       '#type' => 'textfield',
-      '#title' => t('Placeholder'),
+      '#title' => $this->t('Placeholder'),
       '#default_value' => $this->getSetting('placeholder'),
-      '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
+      '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
     ];
     return $element;
   }
@@ -49,10 +49,10 @@ public function settingsSummary() {
 
     $placeholder = $this->getSetting('placeholder');
     if (!empty($placeholder)) {
-      $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
+      $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
     }
     else {
-      $summary[] = t('No placeholder');
+      $summary[] = $this->t('No placeholder');
     }
 
     return $summary;
diff --git a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php
index 35dc4f70da8e..de10c974688c 100644
--- a/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php
+++ b/core/modules/text/src/Plugin/Field/FieldFormatter/TextTrimmedFormatter.php
@@ -44,11 +44,11 @@ public static function defaultSettings() {
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $element['trim_length'] = [
-      '#title' => t('Trimmed limit'),
+      '#title' => $this->t('Trimmed limit'),
       '#type' => 'number',
-      '#field_suffix' => t('characters'),
+      '#field_suffix' => $this->t('characters'),
       '#default_value' => $this->getSetting('trim_length'),
-      '#description' => t('If the summary is not set, the trimmed %label field will end at the last full sentence before this character limit.', ['%label' => $this->fieldDefinition->getLabel()]),
+      '#description' => $this->t('If the summary is not set, the trimmed %label field will end at the last full sentence before this character limit.', ['%label' => $this->fieldDefinition->getLabel()]),
       '#min' => 1,
       '#required' => TRUE,
     ];
@@ -60,7 +60,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
    */
   public function settingsSummary() {
     $summary = [];
-    $summary[] = t('Trimmed limit: @trim_length characters', ['@trim_length' => $this->getSetting('trim_length')]);
+    $summary[] = $this->t('Trimmed limit: @trim_length characters', ['@trim_length' => $this->getSetting('trim_length')]);
     return $summary;
   }
 
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
index dcee58346d1a..47a23dcf77f9 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextItem.php
@@ -61,7 +61,7 @@ public function getConstraints() {
         'value' => [
           'Length' => [
             'max' => $max_length,
-            'maxMessage' => t('%name: the text may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
+            'maxMessage' => $this->t('%name: the text may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
           ],
         ],
       ]);
@@ -78,10 +78,10 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state
 
     $element['max_length'] = [
       '#type' => 'number',
-      '#title' => t('Maximum length'),
+      '#title' => $this->t('Maximum length'),
       '#default_value' => $this->getSetting('max_length'),
       '#required' => TRUE,
-      '#description' => t('The maximum length of the field in characters.'),
+      '#description' => $this->t('The maximum length of the field in characters.'),
       '#min' => 1,
       '#disabled' => $has_data,
     ];
diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
index 9c9a160e239a..9437c381fc10 100644
--- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
+++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php
@@ -5,6 +5,7 @@
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\TypedData\DataDefinition;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Plugin implementation of the 'text_with_summary' field type.
@@ -37,11 +38,11 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel
     $properties = parent::propertyDefinitions($field_definition);
 
     $properties['summary'] = DataDefinition::create('string')
-      ->setLabel(t('Summary'));
+      ->setLabel(new TranslatableMarkup('Summary'));
 
     $properties['summary_processed'] = DataDefinition::create('string')
-      ->setLabel(t('Processed summary'))
-      ->setDescription(t('The summary text with the text format applied.'))
+      ->setLabel(new TranslatableMarkup('Processed summary'))
+      ->setDescription(new TranslatableMarkup('The summary text with the text format applied.'))
       ->setComputed(TRUE)
       ->setClass('\Drupal\text\TextProcessed')
       ->setSetting('text source', 'summary');
@@ -91,15 +92,15 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
 
     $element['display_summary'] = [
       '#type' => 'checkbox',
-      '#title' => t('Summary input'),
+      '#title' => $this->t('Summary input'),
       '#default_value' => $settings['display_summary'],
-      '#description' => t('This allows authors to input an explicit summary, to be displayed instead of the automatically trimmed text when using the "Summary or trimmed" display type.'),
+      '#description' => $this->t('This allows authors to input an explicit summary, to be displayed instead of the automatically trimmed text when using the "Summary or trimmed" display type.'),
     ];
 
     $element['required_summary'] = [
       '#type' => 'checkbox',
-      '#title' => t('Require summary'),
-      '#description' => t('The summary will also be visible when marked as required.'),
+      '#title' => $this->t('Require summary'),
+      '#description' => $this->t('The summary will also be visible when marked as required.'),
       '#default_value' => $settings['required_summary'],
     ];
 
diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
index 999bfc46239b..60b51650c875 100644
--- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
+++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php
@@ -38,7 +38,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     $element = parent::settingsForm($form, $form_state);
     $element['summary_rows'] = [
       '#type' => 'number',
-      '#title' => t('Summary rows'),
+      '#title' => $this->t('Summary rows'),
       '#default_value' => $this->getSetting('summary_rows'),
       '#description' => $element['rows']['#description'],
       '#required' => TRUE,
@@ -46,7 +46,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
     ];
     $element['show_summary'] = [
       '#type' => 'checkbox',
-      '#title' => t('Always show the summary field'),
+      '#title' => $this->t('Always show the summary field'),
       '#default_value' => $this->getSetting('show_summary'),
     ];
     return $element;
@@ -58,9 +58,9 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
   public function settingsSummary() {
     $summary = parent::settingsSummary();
 
-    $summary[] = t('Number of summary rows: @rows', ['@rows' => $this->getSetting('summary_rows')]);
+    $summary[] = $this->t('Number of summary rows: @rows', ['@rows' => $this->getSetting('summary_rows')]);
     if ($this->getSetting('show_summary')) {
-      $summary[] = t('Summary field will always be visible');
+      $summary[] = $this->t('Summary field will always be visible');
     }
 
     return $summary;
@@ -78,7 +78,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
     $element['summary'] = [
       '#type' => $display_summary ? 'textarea' : 'value',
       '#default_value' => $items[$delta]->summary,
-      '#title' => t('Summary'),
+      '#title' => $this->t('Summary'),
       '#rows' => $this->getSetting('summary_rows'),
       '#description' => !$required ? $this->t('Leave blank to use trimmed value of full text as the summary.') : '',
       '#attributes' => ['class' => ['js-text-summary', 'text-summary']],
diff --git a/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php b/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php
index e496e1f9fa89..43dd5b30a6bd 100644
--- a/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php
+++ b/core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php
@@ -62,7 +62,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
     unset($roles[RoleInterface::AUTHENTICATED_ID]);
     $form['rid'] = [
       '#type' => 'radios',
-      '#title' => t('Role'),
+      '#title' => $this->t('Role'),
       '#options' => $roles,
       '#default_value' => $this->configuration['rid'],
       '#required' => TRUE,
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
index 4d9d0f23f5f7..3706e39eda2a 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php
@@ -95,7 +95,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
             else {
               // Allow translators to control the punctuation. Plugin
               // definitions get cached, so use TranslatableMarkup() instead of
-              // t() to avoid double escaping when $admin_label is rendered
+              // $this->t() to avoid double escaping when $admin_label is rendered
               // during requests that use the cached definition.
               $admin_label = new TranslatableMarkup('@view: @display', ['@view' => $view->label(), '@display' => $display->display['display_title']]);
             }
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php b/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php
index 8dd537cc083a..757b574189b4 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Drupal\views\ViewsData;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
@@ -16,6 +17,8 @@
  */
 class ViewsEntityRow implements ContainerDeriverInterface {
 
+  use StringTranslationTrait;
+
   /**
    * Stores all entity row plugin information.
    *
@@ -93,7 +96,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
           'id' => 'entity:' . $entity_type_id,
           'provider' => 'views',
           'title' => $entity_type->getLabel(),
-          'help' => t('Display the @label', ['@label' => $entity_type->getLabel()]),
+          'help' => $this->t('Display the @label', ['@label' => $entity_type->getLabel()]),
           'base' => [$entity_type->getDataTable() ?: $entity_type->getBaseTable()],
           'entity_type' => $entity_type_id,
           'display_types' => ['normal'],
diff --git a/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
index 0dcf62ee3d35..57ac710c246f 100644
--- a/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
+++ b/core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -13,6 +14,8 @@
  */
 class ViewsExposedFilterBlock implements ContainerDeriverInterface {
 
+  use StringTranslationTrait;
+
   /**
    * List of derivative definitions.
    *
@@ -85,7 +88,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
           // Add a block definition for the block.
           if ($display->usesExposedFormInBlock()) {
             $delta = $view->id() . '-' . $display->display['id'];
-            $desc = t('Exposed form: @view-@display_id', ['@view' => $view->id(), '@display_id' => $display->display['id']]);
+            $desc = $this->t('Exposed form: @view-@display_id', ['@view' => $view->id(), '@display_id' => $display->display['id']]);
             $this->derivatives[$delta] = [
               'admin_label' => $desc,
               'config_dependencies' => [
diff --git a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
index cf80704f6b3f..96cb20b3979d 100644
--- a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
+++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
@@ -10,6 +10,7 @@
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\Core\Render\RendererInterface;
 use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\Url;
 use Drupal\views\Render\ViewsRenderPipelineMarkup;
 use Drupal\views\Views;
@@ -321,7 +322,7 @@ public static function settingsFormValidate($element, FormStateInterface $form_s
       [$view, $display] = explode(':', $element['view_and_display']['#value']);
     }
     else {
-      $form_state->setError($element, t('The views entity selection mode requires a view.'));
+      $form_state->setError($element, new TranslatableMarkup('The views entity selection mode requires a view.'));
       return;
     }
 
diff --git a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
index 992e8e252f54..55df6484efdb 100644
--- a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
+++ b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php
@@ -16,7 +16,7 @@ trait BrokenHandlerTrait {
    * @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
    */
   public function adminLabel($short = FALSE) {
-    return t('Broken/missing handler');
+    return $this->t('Broken/missing handler');
   }
 
   /**
@@ -51,7 +51,7 @@ public function query($group_by = FALSE) {
    * @see \Drupal\views\Plugin\views\PluginBase::defineOptions()
    */
   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
-    $description_top = t('The handler for this item is broken or missing. The following details are available:');
+    $description_top = $this->t('The handler for this item is broken or missing. The following details are available:');
 
     foreach ($this->definition['original_configuration'] as $key => $value) {
       if (is_scalar($value)) {
@@ -59,7 +59,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
       }
     }
 
-    $description_bottom = t('Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.');
+    $description_bottom = $this->t('Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.');
 
     $form['description'] = [
       '#type' => 'container',
diff --git a/core/modules/views/src/Plugin/views/area/DisplayLink.php b/core/modules/views/src/Plugin/views/area/DisplayLink.php
index 02f2e7480d8a..c7c1968ba2c6 100644
--- a/core/modules/views/src/Plugin/views/area/DisplayLink.php
+++ b/core/modules/views/src/Plugin/views/area/DisplayLink.php
@@ -129,10 +129,10 @@ public function validate() {
     // recommend keeping the display options equal, we do not want to enforce
     // this.
     $unequal_options = [
-      'filters' => t('Filter criteria'),
-      'sorts' => t('Sort criteria'),
-      'pager' => t('Pager'),
-      'arguments' => t('Contextual filters'),
+      'filters' => $this->t('Filter criteria'),
+      'sorts' => $this->t('Sort criteria'),
+      'pager' => $this->t('Pager'),
+      'arguments' => $this->t('Contextual filters'),
     ];
     foreach (array_keys($unequal_options) as $option) {
       if ($this->hasEqualOptions($linked_display_id, $option)) {
diff --git a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
index 0b05e173af18..02533c7198b6 100644
--- a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
+++ b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
@@ -48,8 +48,8 @@ public function tokenForm(&$form, FormStateInterface $form_state) {
 
     // Get a list of the available fields and arguments for token replacement.
     $options = [];
-    $optgroup_arguments = (string) t('Arguments');
-    $optgroup_fields = (string) t('Fields');
+    $optgroup_arguments = (string) $this->t('Arguments');
+    $optgroup_fields = (string) $this->t('Fields');
     foreach ($this->view->display_handler->getHandlers('field') as $field => $handler) {
       $options[$optgroup_fields]["{{ $field }}"] = $handler->adminLabel();
     }
diff --git a/core/modules/views/src/Plugin/views/area/View.php b/core/modules/views/src/Plugin/views/area/View.php
index 0f2d5bc91e7b..6dae7802f705 100644
--- a/core/modules/views/src/Plugin/views/area/View.php
+++ b/core/modules/views/src/Plugin/views/area/View.php
@@ -118,7 +118,7 @@ public function render($empty = FALSE) {
       // Check if the view is part of the parent views of this view
       $search = "$view_name:$display_id";
       if (in_array($search, $this->view->parent_views)) {
-        \Drupal::messenger()->addError(t("Recursion detected in view @view display @display.", ['@view' => $view_name, '@display' => $display_id]));
+        \Drupal::messenger()->addError($this->t("Recursion detected in view @view display @display.", ['@view' => $view_name, '@display' => $display_id]));
       }
       else {
         if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
index c0e70e364b1c..716e795dc137 100644
--- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
+++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
@@ -380,8 +380,8 @@ protected function getTokenHelp() {
 
     foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
       /** @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase $handler */
-      $options[(string) t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
-      $options[(string) t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
+      $options[(string) $this->t('Arguments')]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
+      $options[(string) $this->t('Arguments')]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
     }
 
     // We have some options, so make a list.
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index c71538819f03..1d4c9d452de9 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -1731,7 +1731,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
         ];
 
         $options = [];
-        $optgroup_arguments = (string) t('Arguments');
+        $optgroup_arguments = (string) $this->t('Arguments');
         foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) {
           $options[$optgroup_arguments]["{{ arguments.$arg }}"] = $this->t('@argument title', ['@argument' => $handler->adminLabel()]);
           $options[$optgroup_arguments]["{{ raw_arguments.$arg }}"] = $this->t('@argument input', ['@argument' => $handler->adminLabel()]);
diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php
index ec542fc52d3d..817230cb33bd 100644
--- a/core/modules/views/src/Plugin/views/field/Boolean.php
+++ b/core/modules/views/src/Plugin/views/field/Boolean.php
@@ -49,15 +49,15 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
     parent::init($view, $display, $options);
 
     $default_formats = [
-      'yes-no' => [t('Yes'), $this->t('No')],
-      'true-false' => [t('True'), $this->t('False')],
-      'on-off' => [t('On'), $this->t('Off')],
-      'enabled-disabled' => [t('Enabled'), $this->t('Disabled')],
+      'yes-no' => [$this->t('Yes'), $this->t('No')],
+      'true-false' => [$this->t('True'), $this->t('False')],
+      'on-off' => [$this->t('On'), $this->t('Off')],
+      'enabled-disabled' => [$this->t('Enabled'), $this->t('Disabled')],
       'boolean' => [1, 0],
       'unicode-yes-no' => ['✔', '✖'],
     ];
     $output_formats = $this->definition['output formats'] ?? [];
-    $custom_format = ['custom' => [t('Custom')]];
+    $custom_format = ['custom' => [$this->t('Custom')]];
     $this->formats = array_merge($default_formats, $output_formats, $custom_format);
   }
 
diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
index 9768d0a0d1f8..47fac700cfd5 100644
--- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -14,6 +14,7 @@
 use Drupal\views\ResultRow;
 use Drupal\views\ViewExecutable;
 use Twig\Environment;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * @defgroup views_field_handlers Views field handler plugins
@@ -876,8 +877,8 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
 
       // Setup the tokens for fields.
       $previous = $this->getPreviousFieldLabels();
-      $optgroup_arguments = (string) t('Arguments');
-      $optgroup_fields = (string) t('Fields');
+      $optgroup_arguments = (string) $this->t('Arguments');
+      $optgroup_fields = (string) $this->t('Fields');
       foreach ($previous as $id => $label) {
         $options[$optgroup_fields]["{{ $id }}"] = substr(strrchr($label, ":"), 2);
       }
@@ -1819,7 +1820,7 @@ public static function trimText($alter, $value) {
       $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value));
 
       if (!empty($alter['ellipsis'])) {
-        $value .= t('…');
+        $value .= new TranslatableMarkup('…');
       }
     }
     if (!empty($alter['html'])) {
diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index 5fdeeb958b65..3a8d5de6b22b 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -72,7 +72,7 @@ public function getValueOptions() {
       }
     }
     else {
-      $this->valueOptions = [t('Yes'), $this->t('No')];
+      $this->valueOptions = [$this->t('Yes'), $this->t('No')];
     }
 
     return $this->valueOptions;
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php
index 2367981ad5a0..1e81e51e235a 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php
@@ -46,7 +46,7 @@ public function viewsForm(&$form, FormStateInterface $form_state) {
     foreach ($this->view->result as $row_index => $row) {
       $form[$this->options['id']][$row_index] = [
         '#type' => 'submit',
-        '#value' => t('Test Button'),
+        '#value' => $this->t('Test Button'),
         '#name' => 'test-button-' . $row_index,
         '#test_button' => TRUE,
         '#row_index' => $row_index,
diff --git a/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php b/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php
index ecb90a7f3f3e..aaaa78df88c3 100644
--- a/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php
+++ b/core/modules/views/tests/src/Kernel/Plugin/RelationshipJoinTestBase.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\views\Kernel\Plugin;
 
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\user\Entity\User;
 use Drupal\views\Views;
 
@@ -69,8 +70,8 @@ protected function schemaDefinition() {
   protected function viewsData() {
     $data = parent::viewsData();
     $data['views_test_data']['uid'] = [
-      'title' => t('UID'),
-      'help' => t('The test data UID'),
+      'title' => new TranslatableMarkup('UID'),
+      'help' => new TranslatableMarkup('The test data UID'),
       'relationship' => [
         'id' => 'standard',
         'base' => 'users_field_data',
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index 3960b29673d8..af39457f6dfb 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -160,6 +160,9 @@
     <!-- Setting severity to 0 to completely disable an error message in this sniff, without excluding the whole sniff -->
     <!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#changing-the-default-severity-levels -->
     <severity>0</severity>
+    <rule ref="DrupalPractice.Objects.GlobalFunction">
+       <include-pattern>*/Plugin/*</include-pattern>
+    </rule>
   </rule>
   <rule ref="DrupalPractice.Commenting.ExpectedException"/>
   <rule ref="DrupalPractice.General.ExceptionT"/>
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
index c1017acc3d2d..fe747c01fc92 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php
@@ -3,6 +3,7 @@
 namespace Drupal\KernelTests\Core\Plugin\Discovery;
 
 use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Tests that plugins are correctly discovered using annotated classes.
@@ -29,7 +30,7 @@ protected function setUp(): void {
         'label' => 'Banana',
         'color' => 'yellow',
         'uses' => [
-          'bread' => t('Banana bread'),
+          'bread' => new TranslatableMarkup('Banana bread'),
           'loaf' => [
             'singular' => '@count loaf',
             'plural' => '@count loaves',
diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php
index 1cacefefc9ca..48f987decceb 100644
--- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php
@@ -3,6 +3,7 @@
 namespace Drupal\KernelTests\Core\Plugin\Discovery;
 
 use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
 
 /**
  * Tests that plugins in a custom directory are correctly discovered using
@@ -43,7 +44,7 @@ protected function setUp(): void {
         'label' => 'Banana',
         'color' => 'yellow',
         'uses' => [
-          'bread' => t('Banana bread'),
+          'bread' => new TranslatableMarkup('Banana bread'),
           'loaf' => [
             'singular' => '@count loaf',
             'plural' => '@count loaves',
-- 
GitLab