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
(cherry picked from commit 6bbfb05500
)
merge-requests/1766/merge
parent
efeb6f0ec2
commit
a4c98c94ee
|
@ -163,25 +163,25 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
|
|||
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 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
|
|||
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]']));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ class GotoAction extends ConfigurableActionBase implements ContainerFactoryPlugi
|
|||
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,
|
||||
];
|
||||
|
|
|
@ -106,11 +106,11 @@ class MessageAction extends ConfigurableActionBase implements ContainerFactoryPl
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\Core\Entity\Plugin\Derivative;
|
|||
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 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
* @see plugin_api
|
||||
*/
|
||||
class DefaultSelectionDeriver extends DeriverBase implements ContainerDeriverInterface {
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The entity type manager.
|
||||
|
@ -51,7 +53,7 @@ class DefaultSelectionDeriver extends DeriverBase implements ContainerDeriverInt
|
|||
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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -42,18 +42,18 @@ class DecimalFormatter extends NumericFormatterBase {
|
|||
|
||||
$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,
|
||||
];
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
|
|||
$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 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
|
|||
|
||||
$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;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
|
|||
*/
|
||||
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 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ abstract class NumericFormatterBase extends FormatterBase {
|
|||
|
||||
$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 @@ abstract class NumericFormatterBase extends FormatterBase {
|
|||
|
||||
$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;
|
||||
|
|
|
@ -6,6 +6,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
|
|||
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 @@ class DecimalItem extends NumericItemBase {
|
|||
*/
|
||||
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 @@ class DecimalItem extends NumericItemBase {
|
|||
|
||||
$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,
|
||||
];
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
|||
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 @@ class EmailItem extends FieldItemBase {
|
|||
'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,
|
||||
]),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -362,7 +362,7 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
|
|||
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 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
|
|||
];
|
||||
$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 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
|
|||
|
||||
$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 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf
|
|||
];
|
||||
$form['handler']['handler_submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Change handler'),
|
||||
'#value' => $this->t('Change handler'),
|
||||
'#limit_validation_errors' => [],
|
||||
'#attributes' => [
|
||||
'class' => ['js-hide'],
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType;
|
|||
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 @@ class IntegerItem extends NumericItemBase {
|
|||
*/
|
||||
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 @@ class IntegerItem extends NumericItemBase {
|
|||
'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,
|
||||
]),
|
||||
|
|
|
@ -31,29 +31,29 @@ abstract class NumericItemBase extends FieldItemBase {
|
|||
|
||||
$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 '€ '. 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 '€ '. 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 @@ abstract class NumericItemBase extends FieldItemBase {
|
|||
'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 @@ abstract class NumericItemBase extends FieldItemBase {
|
|||
'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,
|
||||
]),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -58,7 +58,7 @@ class StringItem extends StringItemBase {
|
|||
'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 @@ class StringItem extends StringItemBase {
|
|||
|
||||
$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,
|
||||
];
|
||||
|
|
|
@ -25,8 +25,6 @@ abstract class StringItemBase 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('Text value'))
|
||||
->setSetting('case_sensitive', $field_definition->getSetting('case_sensitive'))
|
||||
|
|
|
@ -35,7 +35,7 @@ class BooleanCheckboxWidget extends WidgetBase {
|
|||
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 @@ class BooleanCheckboxWidget extends WidgetBase {
|
|||
$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;
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ class EmailDefaultWidget extends WidgetBase {
|
|||
];
|
||||
$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 @@ class EmailDefaultWidget extends WidgetBase {
|
|||
|
||||
$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;
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
|
|||
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 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
|
|||
];
|
||||
$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 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
|
|||
$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 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
|
|||
*/
|
||||
protected function getMatchOperatorOptions() {
|
||||
return [
|
||||
'STARTS_WITH' => t('Starts with'),
|
||||
'CONTAINS' => t('Contains'),
|
||||
'STARTS_WITH' => $this->t('Starts with'),
|
||||
'CONTAINS' => $this->t('Contains'),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ class NumberWidget extends WidgetBase {
|
|||
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 @@ class NumberWidget extends WidgetBase {
|
|||
|
||||
$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;
|
||||
|
|
|
@ -64,7 +64,7 @@ class OptionsButtonsWidget extends OptionsWidgetBase {
|
|||
*/
|
||||
protected function getEmptyLabel() {
|
||||
if (!$this->required && !$this->multiple) {
|
||||
return t('N/A');
|
||||
return $this->t('N/A');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class OptionsSelectWidget extends OptionsWidgetBase {
|
|||
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 @@ class OptionsSelectWidget extends OptionsWidgetBase {
|
|||
// 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 -');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface;
|
|||
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 @@ abstract class OptionsWidgetBase extends WidgetBase {
|
|||
*/
|
||||
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.
|
||||
|
|
|
@ -35,16 +35,16 @@ class StringTextareaWidget extends WidgetBase {
|
|||
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 @@ class StringTextareaWidget extends WidgetBase {
|
|||
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;
|
||||
|
|
|
@ -35,16 +35,16 @@ class StringTextfieldWidget extends WidgetBase {
|
|||
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 @@ class StringTextfieldWidget 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')]);
|
||||
$placeholder = $this->getSetting('placeholder');
|
||||
if (!empty($placeholder)) {
|
||||
$summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
|
||||
$summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
|
||||
}
|
||||
|
||||
return $summary;
|
||||
|
|
|
@ -312,7 +312,7 @@ class CKEditor5 extends EditorBase implements ContainerFactoryPluginInterface {
|
|||
'warning' => [$css_warning],
|
||||
],
|
||||
'#status_headings' => [
|
||||
'warning' => t('Warning message'),
|
||||
'warning' => $this->t('Warning message'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use Drupal\Core\TypedData\DataDefinition;
|
|||
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 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
|
|||
*/
|
||||
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 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
|
|||
|
||||
$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 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
|
|||
];
|
||||
$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 @@ class CommentItem extends FieldItemBase implements CommentItemInterface {
|
|||
}
|
||||
$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()]),
|
||||
|
|
|
@ -29,22 +29,22 @@ class CommentWidget extends WidgetBase {
|
|||
|
||||
$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 @@ class CommentWidget extends WidgetBase {
|
|||
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
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\content_translation\Plugin\Derivative;
|
|||
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 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class ContentTranslationContextualLinks extends DeriverBase implements ContainerDeriverInterface {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The content translation manager.
|
||||
*
|
||||
|
@ -46,7 +49,7 @@ class ContentTranslationContextualLinks extends DeriverBase implements Container
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
|
|||
|
||||
$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 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase {
|
|||
$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;
|
||||
}
|
||||
|
|
|
@ -34,19 +34,19 @@ class DateTimeFieldItemList extends FieldItemList {
|
|||
'#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 @@ class DateTimeFieldItemList extends FieldItemList {
|
|||
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.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
|||
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 @@ class DateTimeItem extends FieldItemBase implements DateTimeItemInterface {
|
|||
*/
|
||||
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 @@ class DateTimeItem extends FieldItemBase implements DateTimeItemInterface {
|
|||
|
||||
$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,
|
||||
];
|
||||
|
|
|
@ -93,29 +93,33 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
|
||||
$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 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase {
|
|||
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;
|
||||
|
|
|
@ -34,7 +34,7 @@ class TRexEditor extends EditorBase {
|
|||
*/
|
||||
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,
|
||||
];
|
||||
|
|
|
@ -35,7 +35,7 @@ class UnicornEditor extends EditorBase {
|
|||
*/
|
||||
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,
|
||||
];
|
||||
|
|
|
@ -36,7 +36,7 @@ class TestFieldDefaultFormatter extends FormatterBase {
|
|||
*/
|
||||
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 @@ class TestFieldDefaultFormatter extends FormatterBase {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class TestFieldEmptySettingFormatter extends FormatterBase {
|
|||
*/
|
||||
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 @@ class TestFieldEmptySettingFormatter extends FormatterBase {
|
|||
$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;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class TestFieldMultipleFormatter extends FormatterBase {
|
|||
*/
|
||||
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 @@ class TestFieldMultipleFormatter extends FormatterBase {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
|
|||
*/
|
||||
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 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ class TestItem extends FieldItemBase {
|
|||
*/
|
||||
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 @@ class TestItem extends FieldItemBase {
|
|||
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 @@ class TestItem extends FieldItemBase {
|
|||
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 @@ class TestItem extends FieldItemBase {
|
|||
'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]),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\field_test\Plugin\Field\FieldType;
|
|||
|
||||
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' => [
|
||||
|
|
|
@ -40,8 +40,8 @@ class TestFieldWidget extends WidgetBase {
|
|||
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 @@ class TestFieldWidget extends WidgetBase {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ class TestFieldWidgetMultiple extends WidgetBase {
|
|||
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 @@ class TestFieldWidgetMultiple extends WidgetBase {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class TableFormatter extends DescriptionAwareFileFormatterBase {
|
|||
$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;
|
||||
|
|
|
@ -12,6 +12,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
|
|||
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 @@ class FileItem extends EntityReferenceItem {
|
|||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
|
||||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
|
||||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
|
||||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
|
||||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
$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 @@ class FileItem extends EntityReferenceItem {
|
|||
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 @@ class FileItem extends EntityReferenceItem {
|
|||
$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']]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Drupal\Core\Field\WidgetBase;
|
|||
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 @@ class FileWidget extends WidgetBase {
|
|||
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 @@ class FileWidget extends WidgetBase {
|
|||
*/
|
||||
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 @@ class FileWidget extends WidgetBase {
|
|||
// 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 @@ class FileWidget extends WidgetBase {
|
|||
// 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 @@ class FileWidget extends WidgetBase {
|
|||
'@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 @@ class FileWidget extends WidgetBase {
|
|||
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 @@ class FileWidget extends WidgetBase {
|
|||
$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 @@ class FileWidget extends WidgetBase {
|
|||
$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,
|
||||
|
|
|
@ -122,24 +122,24 @@ class ImageFormatter extends ImageFormatterBase {
|
|||
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,
|
||||
];
|
||||
|
||||
|
@ -182,15 +182,15 @@ class ImageFormatter extends ImageFormatterBase {
|
|||
// 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');
|
||||
|
|
|
@ -10,6 +10,7 @@ use Drupal\Core\File\Exception\FileException;
|
|||
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;
|
||||
|
@ -141,20 +142,20 @@ class ImageItem extends FileItem {
|
|||
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;
|
||||
}
|
||||
|
@ -173,15 +174,15 @@ class ImageItem extends FileItem {
|
|||
$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;
|
||||
}
|
||||
|
@ -199,14 +200,14 @@ class ImageItem extends FileItem {
|
|||
$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,
|
||||
|
@ -215,25 +216,25 @@ class ImageItem extends FileItem {
|
|||
];
|
||||
$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,
|
||||
|
@ -242,11 +243,11 @@ class ImageItem extends FileItem {
|
|||
];
|
||||
$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>',
|
||||
];
|
||||
|
||||
|
@ -256,16 +257,16 @@ class ImageItem extends FileItem {
|
|||
// 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' => [
|
||||
|
@ -275,14 +276,14 @@ class ImageItem extends FileItem {
|
|||
];
|
||||
$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' => [
|
||||
|
@ -294,7 +295,7 @@ class ImageItem extends FileItem {
|
|||
|
||||
// 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;
|
||||
}
|
||||
|
@ -388,9 +389,9 @@ class ImageItem extends FileItem {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +413,7 @@ class ImageItem extends FileItem {
|
|||
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.
|
||||
|
@ -423,8 +424,8 @@ class ImageItem extends FileItem {
|
|||
}
|
||||
$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' => [
|
||||
|
@ -435,15 +436,15 @@ class ImageItem extends FileItem {
|
|||
];
|
||||
$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,
|
||||
];
|
||||
|
|
|
@ -7,6 +7,7 @@ use Drupal\Core\Field\FieldItemListInterface;
|
|||
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 @@ class ImageWidget extends FileWidget {
|
|||
$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 @@ class ImageWidget extends FileWidget {
|
|||
// 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 @@ class ImageWidget extends FileWidget {
|
|||
|
||||
// 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 @@ class ImageWidget extends FileWidget {
|
|||
];
|
||||
$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'],
|
||||
|
|
|
@ -67,7 +67,7 @@ class ConvertImageEffect extends ConfigurableImageEffectBase {
|
|||
);
|
||||
$form['extension'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Convert to'),
|
||||
'#title' => $this->t('Convert to'),
|
||||
'#default_value' => $this->configuration['extension'],
|
||||
'#required' => TRUE,
|
||||
'#options' => $options,
|
||||
|
|
|
@ -59,21 +59,21 @@ class CropImageEffect extends ResizeImageEffect {
|
|||
$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;
|
||||
}
|
||||
|
|
|
@ -66,17 +66,17 @@ class ResizeImageEffect extends ConfigurableImageEffectBase {
|
|||
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,
|
||||
];
|
||||
|
|
|
@ -83,24 +83,24 @@ class RotateImageEffect extends ConfigurableImageEffectBase {
|
|||
$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;
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ class ScaleImageEffect extends ResizeImageEffect {
|
|||
$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;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class DummyAjaxFormatter extends FormatterBase {
|
|||
*/
|
||||
public function settingsSummary() {
|
||||
$summary = [];
|
||||
$summary[] = t('Renders nothing');
|
||||
$summary[] = $this->t('Renders nothing');
|
||||
return $summary;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class AjaxTestImageEffect extends ConfigurableImageEffectBase {
|
|||
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,
|
||||
];
|
||||
|
|
|
@ -122,9 +122,9 @@ class Language extends ConditionPluginBase implements ContainerFactoryPluginInte
|
|||
$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]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 @@ use Drupal\language\ConfigurableLanguageManagerInterface;
|
|||
*/
|
||||
class LanguageBlock extends DeriverBase {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -21,12 +24,12 @@ class LanguageBlock extends DeriverBase {
|
|||
$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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,21 +94,21 @@ class LinkFormatter extends FormatterBase {
|
|||
|
||||
$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 @@ class LinkFormatter extends FormatterBase {
|
|||
];
|
||||
$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 @@ class LinkFormatter extends FormatterBase {
|
|||
$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;
|
||||
|
|
|
@ -10,6 +10,7 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
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 @@ class LinkItem extends FieldItemBase implements LinkItemInterface {
|
|||
*/
|
||||
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 @@ class LinkItem extends FieldItemBase implements LinkItemInterface {
|
|||
|
||||
$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'),
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -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 @@ class LinkWidget extends WidgetBase {
|
|||
$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 @@ class LinkWidget extends WidgetBase {
|
|||
// @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 @@ class LinkWidget extends WidgetBase {
|
|||
*/
|
||||
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 @@ class LinkWidget extends WidgetBase {
|
|||
*/
|
||||
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']]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ use Symfony\Component\Mime\MimeTypes;
|
|||
* 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'],
|
||||
|
|
|
@ -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 @@ use Drupal\Component\Plugin\Derivative\DeriverBase;
|
|||
*/
|
||||
class OEmbedDeriver extends DeriverBase {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -20,8 +23,8 @@ class OEmbedDeriver extends DeriverBase {
|
|||
$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,
|
||||
|
|
|
@ -18,6 +18,7 @@ use Drupal\Core\Field\WidgetBase;
|
|||
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 @@ class MediaLibraryWidget extends WidgetBase implements TrustedCallbackInterface
|
|||
'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 @@ class MediaLibraryWidget extends WidgetBase implements TrustedCallbackInterface
|
|||
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;
|
||||
}
|
||||
|
@ -697,7 +698,7 @@ class MediaLibraryWidget extends WidgetBase implements TrustedCallbackInterface
|
|||
|
||||
// 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(),
|
||||
]);
|
||||
}
|
||||
|
@ -849,7 +850,7 @@ class MediaLibraryWidget extends WidgetBase implements TrustedCallbackInterface
|
|||
}, $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),
|
||||
]));
|
||||
|
@ -998,7 +999,7 @@ class MediaLibraryWidget extends WidgetBase implements TrustedCallbackInterface
|
|||
// 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']]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,31 +73,31 @@ class MenuLink extends DrupalSqlBase {
|
|||
*/
|
||||
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')) {
|
||||
|
|
|
@ -678,7 +678,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
|
|||
$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()) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class EmptySource extends SourcePluginBase {
|
|||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'id' => t('ID'),
|
||||
'id' => $this->t('ID'),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class SqlCountCache extends SqlBase {
|
|||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'id' => t('Id'),
|
||||
'id' => $this->t('Id'),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
|
|||
* {@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 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
|
|||
}
|
||||
$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 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
|
|||
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 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
|
|||
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.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ class UnpublishByKeywordNode extends ConfigurableActionBase {
|
|||
*/
|
||||
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;
|
||||
|
|
|
@ -584,14 +584,14 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
// 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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
|
||||
$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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
|
||||
$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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
|
||||
$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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
$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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
|
||||
$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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
$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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
// 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'] = [
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\node\Plugin\migrate;
|
|||
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 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class D6NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
|
||||
use MigrationDeriverTrait;
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The base plugin ID this derivative is for.
|
||||
|
@ -89,7 +91,7 @@ class D6NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
|
|||
$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,
|
||||
]);
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\node\Plugin\migrate;
|
|||
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 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class D7NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
|
||||
use MigrationDeriverTrait;
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The base plugin ID this derivative is for.
|
||||
|
@ -89,7 +91,7 @@ class D7NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
|
|||
$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'),
|
||||
]);
|
||||
|
|
|
@ -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'),
|
||||
];
|
||||
|
|
|
@ -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'),
|
||||
];
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\options\Plugin\Field\FieldType;
|
|||
|
||||
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 @@ class ListFloatItem extends ListItemBase {
|
|||
* {@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 @@ class ListFloatItem extends ListItemBase {
|
|||
*/
|
||||
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.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\options\Plugin\Field\FieldType;
|
|||
|
||||
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 @@ class ListIntegerItem extends ListItemBase {
|
|||
* {@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 @@ class ListIntegerItem extends ListItemBase {
|
|||
*/
|
||||
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.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use Drupal\Core\Field\FieldItemBase;
|
|||
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 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
|
||||
$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 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
|
||||
$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 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
$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 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
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.'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\options\Plugin\Field\FieldType;
|
|||
|
||||
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 @@ class ListStringItem extends ListItemBase {
|
|||
* {@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 @@ class ListStringItem extends ListItemBase {
|
|||
*/
|
||||
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.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class PathWidget extends WidgetBase {
|
|||
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'),
|
||||
|
|
|
@ -134,7 +134,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase {
|
|||
}
|
||||
|
||||
$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,
|
||||
|
@ -146,14 +146,14 @@ class ResponsiveImageFormatter extends ImageFormatterBase {
|
|||
];
|
||||
|
||||
$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,
|
||||
];
|
||||
|
||||
|
@ -168,11 +168,11 @@ class ResponsiveImageFormatter extends ImageFormatterBase {
|
|||
|
||||
$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')])) {
|
||||
|
@ -180,7 +180,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase {
|
|||
}
|
||||
}
|
||||
else {
|
||||
$summary[] = t('Select a responsive image style.');
|
||||
$summary[] = $this->t('Select a responsive image style.');
|
||||
}
|
||||
|
||||
return $summary;
|
||||
|
|
|
@ -91,16 +91,16 @@ class SearchExtraTypeSearch extends ConfigurableSearchPluginBase {
|
|||
// 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'],
|
||||
];
|
||||
|
|
|
@ -149,12 +149,12 @@ class GDToolkit extends ImageToolkitBase {
|
|||
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;
|
||||
}
|
||||
|
@ -376,14 +376,14 @@ class GDToolkit extends ImageToolkitBase {
|
|||
|
||||
$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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -8,12 +8,15 @@ use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
|
|||
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 @@ class MockBlockManager extends PluginManagerBase {
|
|||
// 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 @@ class MockBlockManager extends PluginManagerBase {
|
|||
// 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 @@ class MockBlockManager extends PluginManagerBase {
|
|||
// 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 @@ class MockBlockManager extends PluginManagerBase {
|
|||
// 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')),
|
||||
],
|
||||
]);
|
||||
|
||||
|
|
|
@ -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 @@ use Drupal\Component\Plugin\Derivative\DeriverInterface;
|
|||
*/
|
||||
class MockLayoutBlockDeriver implements DeriverInterface {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -41,7 +44,7 @@ class MockLayoutBlockDeriver implements DeriverInterface {
|
|||
// 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,
|
||||
];
|
||||
|
||||
|
|
|
@ -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 @@ use Drupal\Component\Plugin\Derivative\DeriverInterface;
|
|||
*/
|
||||
class MockMenuBlockDeriver implements DeriverInterface {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -36,14 +39,14 @@ class MockMenuBlockDeriver implements DeriverInterface {
|
|||
// 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,
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\taxonomy\Plugin\migrate;
|
|||
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 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class D7TaxonomyTermDeriver extends DeriverBase implements ContainerDeriverInterface {
|
||||
use MigrationDeriverTrait;
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The base plugin ID this derivative is for.
|
||||
|
@ -74,7 +76,7 @@ class D7TaxonomyTermDeriver extends DeriverBase implements ContainerDeriverInter
|
|||
$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'),
|
||||
]);
|
||||
|
|
|
@ -280,7 +280,7 @@ class TaxonomyIndexTid extends ManyToOne {
|
|||
$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".');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class TelephoneLinkFormatter extends FormatterBase {
|
|||
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 @@ class TelephoneLinkFormatter extends FormatterBase {
|
|||
$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;
|
||||
|
|
|
@ -6,6 +6,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
|
|||
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 @@ class TelephoneItem extends FieldItemBase {
|
|||
*/
|
||||
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 @@ class TelephoneItem extends FieldItemBase {
|
|||
'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]),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
|
|
@ -34,9 +34,9 @@ class TelephoneDefaultWidget extends WidgetBase {
|
|||
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 @@ class TelephoneDefaultWidget extends WidgetBase {
|
|||
|
||||
$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;
|
||||
|
|
|
@ -41,11 +41,11 @@ class TextTrimmedFormatter extends FormatterBase implements TrustedCallbackInter
|
|||
*/
|
||||
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,
|
||||
];
|
||||
|
@ -57,7 +57,7 @@ class TextTrimmedFormatter extends FormatterBase implements TrustedCallbackInter
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class TextItem extends TextItemBase {
|
|||
'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 @@ class TextItem extends TextItemBase {
|
|||
|
||||
$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,
|
||||
];
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\text\Plugin\Field\FieldType;
|
|||
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 @@ class TextWithSummaryItem extends TextItemBase {
|
|||
$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 @@ class TextWithSummaryItem extends TextItemBase {
|
|||
|
||||
$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'],
|
||||
];
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class TextareaWithSummaryWidget extends TextareaWidget {
|
|||
$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 @@ class TextareaWithSummaryWidget extends TextareaWidget {
|
|||
];
|
||||
$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 @@ class TextareaWithSummaryWidget extends TextareaWidget {
|
|||
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 @@ class TextareaWithSummaryWidget extends TextareaWidget {
|
|||
$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']],
|
||||
|
|
|
@ -62,7 +62,7 @@ abstract class ChangeUserRoleBase extends ConfigurableActionBase implements Cont
|
|||
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,
|
||||
|
|
|
@ -95,7 +95,7 @@ class ViewsBlock implements ContainerDeriverInterface {
|
|||
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']]);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\views\Plugin\Derivative;
|
|||
|
||||
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 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class ViewsEntityRow implements ContainerDeriverInterface {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* Stores all entity row plugin information.
|
||||
*
|
||||
|
@ -93,7 +96,7 @@ class ViewsEntityRow implements ContainerDeriverInterface {
|
|||
'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'],
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\views\Plugin\Derivative;
|
|||
|
||||
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 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
*/
|
||||
class ViewsExposedFilterBlock implements ContainerDeriverInterface {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* List of derivative definitions.
|
||||
*
|
||||
|
@ -85,7 +88,7 @@ class ViewsExposedFilterBlock implements ContainerDeriverInterface {
|
|||
// 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' => [
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue