diff --git a/src/UserTypeForm.php b/src/UserTypeForm.php
index eb3a9c2..fb71c33 100644
--- a/src/UserTypeForm.php
+++ b/src/UserTypeForm.php
@@ -6,11 +6,13 @@ use Drupal\Core\Entity\BundleEntityFormBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\language\Entity\ContentLanguageSettings;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Form handler for user type forms.
*/
class UserTypeForm extends BundleEntityFormBase {
+ use StringTranslationTrait;
/**
* {@inheritdoc}
@@ -22,10 +24,10 @@ class UserTypeForm extends BundleEntityFormBase {
$form['#title'] = ($this->operation == 'add') ? $this->t('Add account type') : $this->t('Edit %label account type', ['%label' => $this->entity->label()]);
$form['label'] = [
- '#title' => t('Name'),
+ '#title' => $this->t('Name'),
'#type' => 'textfield',
'#default_value' => $type->label(),
- '#description' => t('The human-readable name of this account type.'),
+ '#description' => $this->t('The human-readable name of this account type.'),
'#required' => TRUE,
'#size' => 30,
];
@@ -39,22 +41,22 @@ class UserTypeForm extends BundleEntityFormBase {
'exists' => ['Drupal\user_bundle\Entity\UserType', 'load'],
'source' => ['label'],
],
- '#description' => t('A unique machine-readable name for this account type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %user-add page, in which underscores will be converted into hyphens.', [
- '%user-add' => t('Add user'),
+ '#description' => $this->t('A unique machine-readable name for this account type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %user-add page, in which underscores will be converted into hyphens.', [
+ '%user-add' => $this->t('Add user'),
]),
];
$form['description'] = [
- '#title' => t('Description'),
+ '#title' => $this->t('Description'),
'#type' => 'textarea',
'#default_value' => $type->getDescription(),
- '#description' => t('This text will be displayed under this account type on the Add new user page.'),
+ '#description' => $this->t('This text will be displayed under this account type on the Add new user page.'),
];
if ($this->moduleHandler->moduleExists('language')) {
$form['language'] = [
'#type' => 'details',
- '#title' => t('Language settings'),
+ '#title' => $this->t('Language settings'),
];
$language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('user', $type->id());
@@ -76,8 +78,8 @@ class UserTypeForm extends BundleEntityFormBase {
*/
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
- $actions['submit']['#value'] = t('Save account type');
- $actions['delete']['#value'] = t('Delete account type');
+ $actions['submit']['#value'] = $this->t('Save account type');
+ $actions['delete']['#value'] = $this->t('Delete account type');
return $actions;
}
diff --git a/src/UserTypeListBuilder.php b/src/UserTypeListBuilder.php
index d34c5a5..f71fef0 100644
--- a/src/UserTypeListBuilder.php
+++ b/src/UserTypeListBuilder.php
@@ -5,6 +5,7 @@ namespace Drupal\user_bundle;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Url;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Defines a class to build a listing of user type entities.
@@ -12,14 +13,15 @@ use Drupal\Core\Entity\EntityInterface;
* @see \Drupal\user_bundle\Entity\UserType
*/
class UserTypeListBuilder extends ConfigEntityListBuilder {
+ use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function buildHeader() {
- $header['title'] = t('Name');
+ $header['title'] = $this->t('Name');
$header['description'] = [
- 'data' => t('Description'),
+ 'data' => $this->t('Description'),
'class' => [RESPONSIVE_PRIORITY_MEDIUM],
];
return $header + parent::buildHeader();