Unverified Commit 9f26d495 authored by Ankitha Shetty's avatar Ankitha Shetty Committed by Hussain Abbas
Browse files

Issue #3166024 by ankithashetty, hussainweb: Avoid t() calls, instead use...

Issue #3166024 by ankithashetty, hussainweb: Avoid t() calls, instead use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
parent 76975784
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -128,10 +128,10 @@ class DrupalOrgUsernameItem extends FieldItemBase {

    $elements['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,
    ];
+8 −8
Original line number Diff line number Diff line
@@ -38,22 +38,22 @@ class DrupalOrgUsernameWidget extends WidgetBase {

    $elements['size'] = [
      '#type' => 'number',
      '#title' => t('Size of textfield'),
      '#title' => $this->t('Size of textfield'),
      '#default_value' => $this->getSetting('size'),
      '#required' => TRUE,
      '#min' => 1,
    ];
    $elements['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.'),
    ];
    $elements['prefix'] = [
      '#type' => 'textfield',
      '#title' => t('Prefix'),
      '#title' => $this->t('Prefix'),
      '#default_value' => $this->getSetting('prefix'),
      '#description' => t('Text that will be shown before the input field.'),
      '#description' => $this->t('Text that will be shown before the input field.'),
    ];

    return $elements;
@@ -65,12 +65,12 @@ class DrupalOrgUsernameWidget extends WidgetBase {
  public function settingsSummary() {
    $summary = [];

    $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
    $summary[] = $this->t('Textfield size: @size', ['@size' => $this->getSetting('size')]);
    if (!empty($this->getSetting('placeholder'))) {
      $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $this->getSetting('placeholder')]);
      $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $this->getSetting('placeholder')]);
    }
    if (!empty($this->getSetting('prefix'))) {
      $summary[] = t('Prefix: @prefix', ['@prefix' => $this->getSetting('prefix')]);
      $summary[] = $this->t('Prefix: @prefix', ['@prefix' => $this->getSetting('prefix')]);
    }

    return $summary;