Commit 81e675a5 authored by alexpott's avatar alexpott

Issue #2341313 by dawehner: Convert all t() calls to $this->t() in views.

parent c303b2ce
......@@ -48,7 +48,7 @@ protected function defineOptions() {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['display_as_link'] = array(
'#title' => t('Display as link'),
'#title' => $this->t('Display as link'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['display_as_link']),
);
......
......@@ -55,12 +55,12 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['view_mode'] = array(
'#type' => 'select',
'#title' => t('Display type'),
'#title' => $this->t('Display type'),
'#options' => array(
'fulltext' => t('Full text'),
'teaser' => t('Title plus teaser'),
'title' => t('Title only'),
'default' => t('Use default RSS settings'),
'fulltext' => $this->t('Full text'),
'teaser' => $this->t('Title plus teaser'),
'title' => $this->t('Title only'),
'default' => $this->t('Use default RSS settings'),
),
'#default_value' => $this->options['view_mode'],
);
......
......@@ -62,7 +62,7 @@ function title() {
$title = $this->database->query('SELECT name FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', array(':uid' => $this->argument))->fetchField();
}
if (empty($title)) {
return t('No user');
return $this->t('No user');
}
return String::checkPlain($title);
......@@ -108,7 +108,7 @@ public function query($group_by = FALSE) {
* {@inheritdoc}
*/
public function getSortName() {
return t('Numerical', array(), array('context' => 'Sort order'));
return $this->t('Numerical', array(), array('context' => 'Sort order'));
}
}
......@@ -63,13 +63,13 @@ protected function defineOptions() {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['link_to_comment'] = array(
'#title' => t('Link this field to its comment'),
'#description' => t("Enable to override this field's links."),
'#title' => $this->t('Link this field to its comment'),
'#description' => $this->t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => $this->options['link_to_comment'],
);
$form['link_to_entity'] = array(
'#title' => t('Link field to the entity if there is no comment'),
'#title' => $this->t('Link field to the entity if there is no comment'),
'#type' => 'checkbox',
'#default_value' => $this->options['link_to_entity'],
);
......
......@@ -36,9 +36,9 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Show teaser-style link'),
'#title' => $this->t('Show teaser-style link'),
'#default_value' => $this->options['teaser'],
'#description' => t('Show the comment link in the form used on standard entity teasers, rather than the full entity form.'),
'#description' => $this->t('Show the comment link in the form used on standard entity teasers, rather than the full entity form.'),
);
parent::buildOptionsForm($form, $form_state);
......
......@@ -73,7 +73,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
'#default_value' => $this->options['text'],
);
$form['link_to_entity'] = array(
'#title' => t('Link field to the entity if there is no comment'),
'#title' => $this->t('Link field to the entity if there is no comment'),
'#type' => 'checkbox',
'#default_value' => $this->options['link_to_entity'],
);
......@@ -102,7 +102,7 @@ public function render(ResultRow $values) {
* Returns a string for the link text.
*/
protected function renderLink($data, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('View');
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('View');
/** @var \Drupal\comment\CommentInterface $comment */
$comment = $data;
$cid = $comment->id();
......
......@@ -47,7 +47,7 @@ protected function renderLink($data, ResultRow $values) {
return;
}
$text = !empty($this->options['text']) ? $this->options['text'] : t('Approve');
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Approve');
$comment = $this->get_entity($values);
$this->options['alter']['make_link'] = TRUE;
......
......@@ -39,7 +39,7 @@ public function access(AccountInterface $account) {
* Returns a string for the link text.
*/
protected function renderLink($data, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('Delete');
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete');
$comment = $this->getEntity($values);
$this->options['alter']['make_link'] = TRUE;
......
......@@ -31,8 +31,8 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['destination'] = array(
'#type' => 'checkbox',
'#title' => t('Use destination'),
'#description' => t('Add destination to the link'),
'#title' => $this->t('Use destination'),
'#description' => $this->t('Add destination to the link'),
'#default_value' => $this->options['destination'],
);
}
......@@ -56,7 +56,7 @@ protected function renderLink($data, ResultRow $values) {
return;
}
$text = !empty($this->options['text']) ? $this->options['text'] : t('Edit');
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit');
unset($this->options['alter']['fragment']);
if (!empty($this->options['destination'])) {
......
......@@ -39,7 +39,7 @@ public function access(AccountInterface $account) {
* Returns a string for the link text.
*/
protected function renderLink($data, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('Reply');
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Reply');
$comment = $this->getEntity($values);
$this->options['alter']['make_link'] = TRUE;
......
......@@ -28,11 +28,11 @@ public function render(ResultRow $values) {
switch ($value) {
case CommentItemInterface::HIDDEN:
default:
return t('Hidden');
return $this->t('Hidden');
case CommentItemInterface::CLOSED:
return t('Closed');
return $this->t('Closed');
case CommentItemInterface::OPEN:
return t('Open');
return $this->t('Open');
}
}
......
......@@ -85,8 +85,8 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['link_to_comment'] = array(
'#title' => t('Link this field to new comments'),
'#description' => t("Enable to override this field's links."),
'#title' => $this->t('Link this field to new comments'),
'#description' => $this->t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => $this->options['link_to_comment'],
);
......
......@@ -42,7 +42,7 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['link_to_user'] = array(
'#title' => t("Link this field to its user or an author's homepage"),
'#title' => $this->t("Link this field to its user or an author's homepage"),
'#type' => 'checkbox',
'#default_value' => $this->options['link_to_user'],
);
......
......@@ -21,9 +21,9 @@ class NodeComment extends InOperator {
public function getValueOptions() {
$this->value_options = array(
CommentItemInterface::HIDDEN => t('Hidden'),
CommentItemInterface::CLOSED => t('Closed'),
CommentItemInterface::OPEN => t('Open'),
CommentItemInterface::HIDDEN => $this->t('Hidden'),
CommentItemInterface::CLOSED => $this->t('Closed'),
CommentItemInterface::OPEN => $this->t('Open'),
);
}
......
......@@ -41,7 +41,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['view_mode'] = array(
'#type' => 'select',
'#title' => t('Display type'),
'#title' => $this->t('Display type'),
'#options' => $this->options_form_summary_options(),
'#default_value' => $this->options['view_mode'],
);
......@@ -74,8 +74,8 @@ function options_form_summary_options() {
foreach ($view_modes as $mode => $settings) {
$options[$mode] = $settings['label'];
}
$options['title'] = t('Title only');
$options['default'] = t('Use site default RSS settings');
$options['title'] = $this->t('Title only');
$options['default'] = $this->t('Use site default RSS settings');
return $options;
}
......
......@@ -69,8 +69,8 @@ class Comment extends WizardPluginBase {
*/
protected function rowStyleOptions() {
$options = array();
$options['comment'] = t('comments');
$options['fields'] = t('fields');
$options['comment'] = $this->t('comments');
$options['fields'] = $this->t('fields');
return $options;
}
......@@ -87,11 +87,11 @@ protected function buildFormStyle(array &$form, FormStateInterface $form_state,
case 'comment':
$style_form['row_options']['links'] = array(
'#type' => 'select',
'#title' => t('Should links be displayed below each comment'),
'#title' => $this->t('Should links be displayed below each comment'),
'#title_display' => 'invisible',
'#options' => array(
1 => t('with links (allow users to reply to the comment, etc.)'),
0 => t('without links'),
1 => $this->t('with links (allow users to reply to the comment, etc.)'),
0 => $this->t('without links'),
),
'#default_value' => 1,
);
......
......@@ -87,9 +87,9 @@ public static function create(ContainerInterface $container, array $configuratio
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['text']['#title'] = t('Link label');
$form['text']['#title'] = $this->t('Link label');
$form['text']['#required'] = TRUE;
$form['text']['#default_value'] = empty($this->options['text']) ? t('contact') : $this->options['text'];
$form['text']['#default_value'] = empty($this->options['text']) ? $this->t('contact') : $this->options['text'];
}
/**
......@@ -119,7 +119,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "user/{$entity->id()}/contact";
$title = t('Contact %user', array('%user' => $entity->name->value));
$title = $this->t('Contact %user', array('%user' => $entity->name->value));
$this->options['alter']['attributes'] = array('title' => $title);
if (!empty($this->options['text'])) {
......
......@@ -36,7 +36,7 @@ protected function defineOptions() {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['text'] = array(
'#type' => 'textfield',
'#title' => t('Text to display'),
'#title' => $this->t('Text to display'),
'#default_value' => $this->options['text'],
);
parent::buildOptionsForm($form, $form_state);
......@@ -62,7 +62,7 @@ public function render(ResultRow $values) {
*/
protected function renderLink(EntityInterface $entity, ResultRow $values) {
if (content_translation_translate_access($entity)->isAllowed()) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('Translate');
$text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Translate');
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $entity->getSystemPath('drupal:content-translation-overview');
......
......@@ -44,18 +44,18 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));
$form['fields'] = array(
'#type' => 'checkboxes',
'#title' => t('Fields'),
'#description' => t('Fields to be included as contextual links.'),
'#title' => $this->t('Fields'),
'#description' => $this->t('Fields to be included as contextual links.'),
'#options' => $field_options,
'#default_value' => $this->options['fields'],
);
$form['destination'] = array(
'#type' => 'select',
'#title' => t('Include destination'),
'#description' => t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
'#title' => $this->t('Include destination'),
'#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
'#options' => array(
'0' => t('No'),
'1' => t('Yes'),
'0' => $this->t('No'),
'1' => $this->t('Yes'),
),
'#default_value' => $this->options['destination'],
);
......
......@@ -51,7 +51,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['replace_variables'] = array(
'#title' => t('Replace variables'),
'#title' => $this->t('Replace variables'),
'#type' => 'checkbox',
'#default_value' => $this->options['replace_variables'],
);
......
......@@ -165,14 +165,14 @@ public function validate() {
// Verify that search fields are set up.
$style = $this->getOption('style');
if (!isset($style['options']['search_fields'])) {
$errors[] = t('Display "@display" needs a selected search fields to work properly. See the settings for the Entity Reference list format.', array('@display' => $this->display['display_title']));
$errors[] = $this->t('Display "@display" needs a selected search fields to work properly. See the settings for the Entity Reference list format.', array('@display' => $this->display['display_title']));
}
else {
// Verify that the search fields used actually exist.
$fields = array_keys($this->handlers['field']);
foreach ($style['options']['search_fields'] as $field_alias => $enabled) {
if ($enabled && !in_array($field_alias, $fields)) {
$errors[] = t('Display "@display" uses field %field as search field, but the field is no longer present. See the settings for the Entity Reference list format.', array('@display' => $this->display['display_title'], '%field' => $field_alias));
$errors[] = $this->t('Display "@display" uses field %field as search field, but the field is no longer present. See the settings for the Entity Reference list format.', array('@display' => $this->display['display_title'], '%field' => $field_alias));
}
}
}
......
......@@ -43,7 +43,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
// Expand the description of the 'Inline field' checkboxes.
$form['inline']['#description'] .= '<br />' . t("<strong>Note:</strong> In 'Entity Reference' displays, all fields will be displayed inline unless an explicit selection of inline fields is made here." );
$form['inline']['#description'] .= '<br />' . $this->t("<strong>Note:</strong> In 'Entity Reference' displays, all fields will be displayed inline unless an explicit selection of inline fields is made here." );
}
/**
......
......@@ -61,11 +61,11 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$options = $this->displayHandler->getFieldLabels(TRUE);
$form['search_fields'] = array(
'#type' => 'checkboxes',
'#title' => t('Search fields'),
'#title' => $this->t('Search fields'),
'#options' => $options,
'#required' => TRUE,
'#default_value' => $this->options['search_fields'],
'#description' => t('Select the field(s) that will be searched when using the autocomplete widget.'),
'#description' => $this->t('Select the field(s) that will be searched when using the autocomplete widget.'),
'#weight' => -3,
);
}
......
......@@ -55,7 +55,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['summary']['human'] = array(
'#title' => t('Display list value as human readable'),
'#title' => $this->t('Display list value as human readable'),
'#type' => 'checkbox',
'#default_value' => $this->options['summary']['human'],
'#states' => array(
......
......@@ -56,7 +56,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['summary']['human'] = array(
'#title' => t('Display list value as human readable'),
'#title' => $this->t('Display list value as human readable'),
'#type' => 'checkbox',
'#default_value' => $this->options['summary']['human'],
'#states' => array(
......
......@@ -459,16 +459,16 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
else {
$form['click_sort_column'] = array(
'#type' => 'select',
'#title' => t('Column used for click sorting'),
'#title' => $this->t('Column used for click sorting'),
'#options' => array_combine($column_names, $column_names),
'#default_value' => $this->options['click_sort_column'],
'#description' => t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
'#description' => $this->t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
);
}
$form['type'] = array(
'#type' => 'select',
'#title' => t('Formatter'),
'#title' => $this->t('Formatter'),
'#options' => $formatters,
'#default_value' => $this->options['type'],
'#ajax' => array(
......@@ -479,16 +479,16 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
);
$form['field_api_classes'] = array(
'#title' => t('Use field template'),
'#title' => $this->t('Use field template'),
'#type' => 'checkbox',
'#default_value' => $this->options['field_api_classes'],
'#description' => t('If checked, field api classes will be added by field templates. This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'),
'#description' => $this->t('If checked, field api classes will be added by field templates. This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'),
'#fieldset' => 'style_settings',
'#weight' => 20,
);
if ($this->multiple) {
$form['field_api_classes']['#description'] .= ' ' . t('Checking this option will cause the group Display Type and Separator values to be ignored.');
$form['field_api_classes']['#description'] .= ' ' . $this->t('Checking this option will cause the group Display Type and Separator values to be ignored.');
}
// Get the currently selected formatter.
......@@ -523,21 +523,21 @@ function multiple_options_form(&$form, FormStateInterface $form_state) {
$form['multiple_field_settings'] = array(
'#type' => 'details',
'#title' => t('Multiple field settings'),
'#title' => $this->t('Multiple field settings'),
'#weight' => 5,
);
$form['group_rows'] = array(
'#title' => t('Display all values in the same row'),
'#title' => $this->t('Display all values in the same row'),
'#type' => 'checkbox',
'#default_value' => $this->options['group_rows'],
'#description' => t('If checked, multiple values for this field will be shown in the same row. If not checked, each value in this field will create a new row. If using group by, please make sure to group by "Entity ID" for this setting to have any effect.'),
'#description' => $this->t('If checked, multiple values for this field will be shown in the same row. If not checked, each value in this field will create a new row. If using group by, please make sure to group by "Entity ID" for this setting to have any effect.'),
'#fieldset' => 'multiple_field_settings',
);
// Make the string translatable by keeping it as a whole rather than
// translating prefix and suffix separately.
list($prefix, $suffix) = explode('@count', t('Display @count value(s)'));
list($prefix, $suffix) = explode('@count', $this->t('Display @count value(s)'));
if ($field->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
$type = 'textfield';
......@@ -552,11 +552,11 @@ function multiple_options_form(&$form, FormStateInterface $form_state) {
}
$form['multi_type'] = array(
'#type' => 'radios',
'#title' => t('Display type'),
'#title' => $this->t('Display type'),
'#options' => array(
'ul' => t('Unordered list'),
'ol' => t('Ordered list'),
'separator' => t('Simple separator'),
'ul' => $this->t('Unordered list'),
'ol' => $this->t('Ordered list'),
'separator' => $this->t('Simple separator'),
),
'#states' => array(
'visible' => array(
......@@ -569,7 +569,7 @@ function multiple_options_form(&$form, FormStateInterface $form_state) {
$form['separator'] = array(
'#type' => 'textfield',
'#title' => t('Separator'),
'#title' => $this->t('Separator'),
'#default_value' => $this->options['separator'],
'#states' => array(
'visible' => array(
......@@ -596,7 +596,7 @@ function multiple_options_form(&$form, FormStateInterface $form_state) {
'#fieldset' => 'multiple_field_settings',
);
list($prefix, $suffix) = explode('@count', t('starting from @count'));
list($prefix, $suffix) = explode('@count', $this->t('starting from @count'));
$form['delta_offset'] = array(
'#type' => 'textfield',
'#size' => 5,
......@@ -608,11 +608,11 @@ function multiple_options_form(&$form, FormStateInterface $form_state) {
':input[name="options[group_rows]"]' => array('checked' => TRUE),
),
),
'#description' => t('(first item is 0)'),
'#description' => $this->t('(first item is 0)'),
'#fieldset' => 'multiple_field_settings',
);
$form['delta_reversed'] = array(
'#title' => t('Reversed'),
'#title' => $this->t('Reversed'),
'#type' => 'checkbox',
'#default_value' => $this->options['delta_reversed'],
'#suffix' => $suffix,
......@@ -621,11 +621,11 @@ function multiple_options_form(&$form, FormStateInterface $form_state) {
':input[name="options[group_rows]"]' => array('checked' => TRUE),
),
),
'#description' => t('(start from last values)'),
'#description' => $this->t('(start from last values)'),
'#fieldset' => 'multiple_field_settings',
);
$form['delta_first_last'] = array(
'#title' => t('First and last only'),
'#title' => $this->t('First and last only'),
'#type' => 'checkbox',
'#default_value' => $this->options['delta_first_last'],
'#suffix' => '</div>',
......@@ -648,14 +648,14 @@ public function buildGroupByForm(&$form, FormStateInterface $form_state) {
$field_columns = array_keys($this->getFieldDefinition()->getColumns());
$group_columns = array(
'entity_id' => t('Entity ID'),
'entity_id' => $this->t('Entity ID'),
) + array_map('ucfirst', array_combine($field_columns, $field_columns));
$form['group_column'] = array(
'#type' => 'select',
'#title' => t('Group column'),
'#title' => $this->t('Group column'),
'#default_value' => $this->options['group_column'],
'#description' => t('Select the column of this field to apply the grouping function selected above.'),
'#description' => $this->t('Select the column of this field to apply the grouping function selected above.'),
'#options' => $group_columns,
);
......@@ -667,9 +667,9 @@ public function buildGroupByForm(&$form, FormStateInterface $form_state) {
// Add on defined fields, noting that they're prefixed with the field name.
$form['group_columns'] = array(
'#type' => 'checkboxes',
'#title' => t('Group columns (additional)'),
'#title' => $this->t('Group columns (additional)'),
'#default_value' => $this->options['group_columns'],
'#description' => t('Select any additional columns of this field to include in the query and to group on.'),
'#description' => $this->t('Select any additional columns of this field to include in the query and to group on.'),
'#options' => $options + $group_columns,
);
}
......@@ -889,7 +889,7 @@ function render_item($count, $item) {
protected function documentSelfTokens(&$tokens) {
$field = $this->getFieldDefinition();
foreach ($field->getColumns() as $id => $column) {
$tokens['[' . $this->options['id'] . '-' . $id . ']'] = t('Raw @column', array('@column' => $id));
$tokens['[' . $this->options['id'] . '-' . $id . ']'] = $this->t('Raw @column', array('@column' => $id));
}
}
......
......@@ -36,8 +36,8 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['extension_detect_tar'] = array(
'#type' => 'checkbox',
'#title' => t('Detect if tar is part of the extension'),
'#description' => t("See if the previous extension is '.tar' and if so, add that, so we see 'tar.gz' or 'tar.bz2' instead of just 'gz'."),
'#title' => $this->t('Detect if tar is part of the extension'),
'#description' => $this->t("See if the previous extension is '.tar' and if so, add that, so we see 'tar.gz' or 'tar.bz2' instead of just 'gz'."),
'#default_value' => $this->options['extension_detect_tar'],
);
}
......
......@@ -44,8 +44,8 @@ protected function defineOptions() {
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['link_to_file'] = array(
'#title' => t('Link this field to download the file'),
'#description' => t("Enable to override this field's links."),
'#title' => $this->t('Link this field to download the file'),
'#description' => $this->t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_file']),
);