Issue #2223435 by Sutharsan, Xano, tim.plunkett: Do not use t() in block plugins anymore
parent
02965ca732
commit
a120969efe
|
@ -170,7 +170,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
|
||||
$form['admin_label'] = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('Block description'),
|
||||
'#title' => $this->t('Block description'),
|
||||
'#markup' => $definition['admin_label'],
|
||||
);
|
||||
$form['label'] = array(
|
||||
|
@ -190,16 +190,16 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
// @see \Drupal\system\Form\PerformanceForm::buildForm()
|
||||
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
|
||||
$period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($period, $period));
|
||||
$period[0] = '<' . t('no caching') . '>';
|
||||
$period[\Drupal\Core\Cache\Cache::PERMANENT] = t('Forever');
|
||||
$period[0] = '<' . $this->t('no caching') . '>';
|
||||
$period[\Drupal\Core\Cache\Cache::PERMANENT] = $this->t('Forever');
|
||||
$form['cache'] = array(
|
||||
'#type' => 'details',
|
||||
'#title' => t('Cache settings'),
|
||||
'#title' => $this->t('Cache settings'),
|
||||
);
|
||||
$form['cache']['max_age'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Maximum age'),
|
||||
'#description' => t('The maximum time this block may be cached.'),
|
||||
'#title' => $this->t('Maximum age'),
|
||||
'#description' => $this->t('The maximum time this block may be cached.'),
|
||||
'#default_value' => $this->configuration['cache']['max_age'],
|
||||
'#options' => $period,
|
||||
);
|
||||
|
@ -210,8 +210,8 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
unset($contexts['theme']);
|
||||
$form['cache']['contexts'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Vary by context'),
|
||||
'#description' => t('The contexts this cached block must be varied by. <em>All</em> blocks are varied by language and theme.'),
|
||||
'#title' => $this->t('Vary by context'),
|
||||
'#description' => $this->t('The contexts this cached block must be varied by. <em>All</em> blocks are varied by language and theme.'),
|
||||
'#default_value' => $this->configuration['cache']['contexts'],
|
||||
'#options' => $contexts,
|
||||
'#states' => array(
|
||||
|
@ -231,7 +231,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginIn
|
|||
unset($form['cache']['contexts']['#options'][$context_id]);
|
||||
}
|
||||
$required_context_list = implode(', ', $context_labels);
|
||||
$form['cache']['contexts']['#description'] .= ' ' . t('This block is <em>always</em> varied by the following contexts: %required-context-list.', array('%required-context-list' => $required_context_list));
|
||||
$form['cache']['contexts']['#description'] .= ' ' . $this->t('This block is <em>always</em> varied by the following contexts: %required-context-list.', array('%required-context-list' => $required_context_list));
|
||||
}
|
||||
|
||||
// Add plugin-specific settings for this block type.
|
||||
|
|
|
@ -125,14 +125,14 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
}
|
||||
$form['feed'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Select the feed that should be displayed'),
|
||||
'#title' => $this->t('Select the feed that should be displayed'),
|
||||
'#default_value' => $this->configuration['feed'],
|
||||
'#options' => $options,
|
||||
);
|
||||
$range = range(2, 20);
|
||||
$form['block_count'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of news items in block'),
|
||||
'#title' => $this->t('Number of news items in block'),
|
||||
'#default_value' => $this->configuration['block_count'],
|
||||
'#options' => array_combine($range, $range),
|
||||
);
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestBlockInstantiation extends BlockBase {
|
|||
public function blockForm($form, FormStateInterface $form_state) {
|
||||
$form['display_message'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Display message'),
|
||||
'#title' => $this->t('Display message'),
|
||||
'#default_value' => $this->configuration['display_message'],
|
||||
);
|
||||
return $form;
|
||||
|
|
|
@ -117,12 +117,12 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
|
|||
$form['view_mode'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#title' => t('View mode'),
|
||||
'#description' => t('Output the block in this view mode.'),
|
||||
'#title' => $this->t('View mode'),
|
||||
'#description' => $this->t('Output the block in this view mode.'),
|
||||
'#default_value' => $this->configuration['view_mode'],
|
||||
'#access' => (count($options) > 1),
|
||||
);
|
||||
$form['title']['#description'] = t('The title of the block as shown to the user.');
|
||||
$form['title']['#description'] = $this->t('The title of the block as shown to the user.');
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter
|
|||
}
|
||||
else {
|
||||
return array(
|
||||
'#markup' => t('Block with uuid %uuid does not exist. <a href="!url">Add custom block</a>.', array(
|
||||
'#markup' => $this->t('Block with uuid %uuid does not exist. <a href="!url">Add custom block</a>.', array(
|
||||
'%uuid' => $uuid,
|
||||
'!url' => $this->urlGenerator->generate('block_content.add_page')
|
||||
)),
|
||||
|
|
|
@ -99,15 +99,15 @@ class BookNavigationBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
*/
|
||||
function blockForm($form, FormStateInterface $form_state) {
|
||||
$options = array(
|
||||
'all pages' => t('Show block on all pages'),
|
||||
'book pages' => t('Show block only on book pages'),
|
||||
'all pages' => $this->t('Show block on all pages'),
|
||||
'book pages' => $this->t('Show block only on book pages'),
|
||||
);
|
||||
$form['book_block_mode'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Book navigation block display'),
|
||||
'#title' => $this->t('Book navigation block display'),
|
||||
'#options' => $options,
|
||||
'#default_value' => $this->configuration['block_mode'],
|
||||
'#description' => t("If <em>Show block on all pages</em> is selected, the block will contain the automatically generated menus for all of the site's books. If <em>Show block only on book pages</em> is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The <em>Page specific visibility settings</em> or other visibility settings can be used in addition to selectively display this block."),
|
||||
'#description' => $this->t("If <em>Show block on all pages</em> is selected, the block will contain the automatically generated menus for all of the site's books. If <em>Show block only on book pages</em> is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The <em>Page specific visibility settings</em> or other visibility settings can be used in addition to selectively display this block."),
|
||||
);
|
||||
|
||||
return $form;
|
||||
|
|
|
@ -69,7 +69,7 @@ abstract class ForumBlockBase extends BlockBase {
|
|||
$range = range(2, 20);
|
||||
$form['block_count'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of topics'),
|
||||
'#title' => $this->t('Number of topics'),
|
||||
'#default_value' => $this->configuration['block_count'],
|
||||
'#options' => array_combine($range, $range),
|
||||
);
|
||||
|
|
|
@ -56,7 +56,7 @@ class SyndicateBlock extends BlockBase {
|
|||
|
||||
// @see ::isCacheable()
|
||||
$form['cache']['#disabled'] = TRUE;
|
||||
$form['cache']['#description'] = t('This block is never cacheable, it is not configurable.');
|
||||
$form['cache']['#description'] = $this->t('This block is never cacheable, it is not configurable.');
|
||||
$form['cache']['max_age']['#value'] = 0;
|
||||
|
||||
return $form;
|
||||
|
|
|
@ -59,15 +59,15 @@ class StatisticsPopularBlock extends BlockBase {
|
|||
protected function blockAccess(AccountInterface $account) {
|
||||
if ($account->hasPermission('access content')) {
|
||||
$daytop = $this->configuration['top_day_num'];
|
||||
if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, t("Today's:")))) {
|
||||
if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, $this->t("Today's:")))) {
|
||||
return FALSE;
|
||||
}
|
||||
$alltimetop = $this->configuration['top_all_num'];
|
||||
if (!$alltimetop || !($result = statistics_title_list('totalcount', $alltimetop)) || !($this->all_time_list = node_title_list($result, t('All time:')))) {
|
||||
if (!$alltimetop || !($result = statistics_title_list('totalcount', $alltimetop)) || !($this->all_time_list = node_title_list($result, $this->t('All time:')))) {
|
||||
return FALSE;
|
||||
}
|
||||
$lasttop = $this->configuration['top_last_num'];
|
||||
if (!$lasttop || !($result = statistics_title_list('timestamp', $lasttop)) || !($this->last_list = node_title_list($result, t('Last viewed:')))) {
|
||||
if (!$lasttop || !($result = statistics_title_list('timestamp', $lasttop)) || !($this->last_list = node_title_list($result, $this->t('Last viewed:')))) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -81,27 +81,27 @@ class StatisticsPopularBlock extends BlockBase {
|
|||
public function blockForm($form, FormStateInterface $form_state) {
|
||||
// Popular content block settings.
|
||||
$numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40);
|
||||
$numbers = array('0' => t('Disabled')) + array_combine($numbers, $numbers);
|
||||
$numbers = array('0' => $this->t('Disabled')) + array_combine($numbers, $numbers);
|
||||
$form['statistics_block_top_day_num'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t("Number of day's top views to display"),
|
||||
'#title' => $this->t("Number of day's top views to display"),
|
||||
'#default_value' => $this->configuration['top_day_num'],
|
||||
'#options' => $numbers,
|
||||
'#description' => t('How many content items to display in "day" list.'),
|
||||
'#description' => $this->t('How many content items to display in "day" list.'),
|
||||
);
|
||||
$form['statistics_block_top_all_num'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of all time views to display'),
|
||||
'#title' => $this->t('Number of all time views to display'),
|
||||
'#default_value' => $this->configuration['top_all_num'],
|
||||
'#options' => $numbers,
|
||||
'#description' => t('How many content items to display in "all time" list.'),
|
||||
'#description' => $this->t('How many content items to display in "all time" list.'),
|
||||
);
|
||||
$form['statistics_block_top_last_num'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of most recent views to display'),
|
||||
'#title' => $this->t('Number of most recent views to display'),
|
||||
'#default_value' => $this->configuration['top_last_num'],
|
||||
'#options' => $numbers,
|
||||
'#description' => t('How many content items to display in "recently viewed" list.'),
|
||||
'#description' => $this->t('How many content items to display in "recently viewed" list.'),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
$build['site_logo'] = array(
|
||||
'#theme' => 'image',
|
||||
'#uri' => $logo['url'],
|
||||
'#alt' => t('Home'),
|
||||
'#alt' => $this->t('Home'),
|
||||
'#access' => $this->configuration['use_site_logo'],
|
||||
);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class SystemMainBlock extends BlockBase implements MainContentBlockPluginInterfa
|
|||
|
||||
// The main content block is never cacheable, because it may be dynamic.
|
||||
$form['cache']['#disabled'] = TRUE;
|
||||
$form['cache']['#description'] = t('This block is never cacheable, it is not configurable.');
|
||||
$form['cache']['#description'] = $this->t('This block is never cacheable, it is not configurable.');
|
||||
$form['cache']['max_age']['#value'] = 0;
|
||||
|
||||
return $form;
|
||||
|
|
|
@ -83,7 +83,7 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa
|
|||
$defaults = $this->defaultConfiguration();
|
||||
$form['menu_levels'] = array(
|
||||
'#type' => 'details',
|
||||
'#title' => t('Menu levels'),
|
||||
'#title' => $this->t('Menu levels'),
|
||||
// Open if not set to defaults.
|
||||
'#open' => $defaults['level'] !== $config['level'] || $defaults['depth'] !== $config['depth'],
|
||||
'#process' => [[get_class(), 'processMenuLevelParents']],
|
||||
|
|
|
@ -25,7 +25,7 @@ class SystemPoweredByBlock extends BlockBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
return array('#markup' => '<span>' . t('Powered by <a href="@poweredby">Drupal</a>', array('@poweredby' => 'https://www.drupal.org')) . '</span>');
|
||||
return array('#markup' => '<span>' . $this->t('Powered by <a href="@poweredby">Drupal</a>', array('@poweredby' => 'https://www.drupal.org')) . '</span>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@ class SystemPoweredByBlock extends BlockBase {
|
|||
// contents can never change.
|
||||
$form['cache']['#disabled'] = TRUE;
|
||||
$form['cache']['max_age']['#value'] = Cache::PERMANENT;
|
||||
$form['cache']['#description'] = t('This block is always cached forever, it is not configurable.');
|
||||
$form['cache']['#description'] = $this->t('This block is always cached forever, it is not configurable.');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -91,16 +91,16 @@ class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterfac
|
|||
// Build action links.
|
||||
$items = array();
|
||||
if (\Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
|
||||
$items['create_account'] = \Drupal::l(t('Create new account'), new Url('user.register', array(), array(
|
||||
$items['create_account'] = \Drupal::l($this->t('Create new account'), new Url('user.register', array(), array(
|
||||
'attributes' => array(
|
||||
'title' => t('Create a new user account.'),
|
||||
'title' => $this->t('Create a new user account.'),
|
||||
'class' => array('create-account-link'),
|
||||
),
|
||||
)));
|
||||
}
|
||||
$items['request_password'] = \Drupal::l(t('Reset your password'), new Url('user.pass', array(), array(
|
||||
$items['request_password'] = \Drupal::l($this->t('Reset your password'), new Url('user.pass', array(), array(
|
||||
'attributes' => array(
|
||||
'title' => t('Send password reset instructions via e-mail.'),
|
||||
'title' => $this->t('Send password reset instructions via e-mail.'),
|
||||
'class' => array('request-password-link'),
|
||||
),
|
||||
)));
|
||||
|
|
Loading…
Reference in New Issue