Unverified Commit 81e8e68c authored by Dave Reid's avatar Dave Reid Committed by Dave Reid

Issue #3124372 by Dave Reid, Neslee Canil Pinto, ilgnerfagundes: Fixed...

Issue #3124372 by Dave Reid, Neslee Canil Pinto, ilgnerfagundes: Fixed XmlSitemapSettingsForm should use the provided t() method from the available StringTranslationTrait.
parent a2160720
......@@ -107,35 +107,35 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
}
$form['minimum_lifetime'] = [
'#type' => 'select',
'#title' => t('Minimum sitemap lifetime'),
'#options' => [0 => t('No minimum')] + $format_intervals,
'#description' => t('The minimum amount of time that will elapse before the sitemaps are regenerated. The sitemaps will also only be regenerated on cron if any links have been added, updated, or deleted.') . '<br />' . t('Recommended value: %value.', ['%value' => t('1 day')]),
'#title' => $this->t('Minimum sitemap lifetime'),
'#options' => [0 => $this->t('No minimum')] + $format_intervals,
'#description' => $this->t('The minimum amount of time that will elapse before the sitemaps are regenerated. The sitemaps will also only be regenerated on cron if any links have been added, updated, or deleted.<br />Recommended value: <em>1 day</em>.'),
'#default_value' => $config->get('minimum_lifetime'),
];
$form['xsl'] = [
'#type' => 'checkbox',
'#title' => t('Include a stylesheet in the sitemaps for humans.'),
'#description' => t('When enabled, this will add formatting and tables with sorting to make it easier to view the XML sitemap data instead of viewing raw XML output. Search engines will ignore this.'),
'#title' => $this->t('Include a stylesheet in the sitemaps for humans.'),
'#description' => $this->t('When enabled, this will add formatting and tables with sorting to make it easier to view the XML sitemap data instead of viewing raw XML output. Search engines will ignore this.'),
'#default_value' => $config->get('xsl'),
];
$form['prefetch_aliases'] = [
'#type' => 'checkbox',
'#title' => t('Prefetch URL aliases during sitemap generation.'),
'#description' => t('When enabled, this will fetch all URL aliases at once instead of one at a time during sitemap generation. For medium or large sites, it is recommended to disable this feature as it uses a lot of memory.'),
'#title' => $this->t('Prefetch URL aliases during sitemap generation.'),
'#description' => $this->t('When enabled, this will fetch all URL aliases at once instead of one at a time during sitemap generation. For medium or large sites, it is recommended to disable this feature as it uses a lot of memory.'),
'#default_value' => $config->get('prefetch_aliases'),
'#access' => FALSE,
];
$form['advanced'] = [
'#type' => 'details',
'#title' => t('Advanced settings'),
'#title' => $this->t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => !$this->state->get('xmlsitemap_developer_mode'),
'#weight' => 10,
];
$form['advanced']['gz'] = [
'#type' => 'checkbox',
'#title' => t('Generate additional compressed sitemaps using gzip.'),
'#title' => $this->t('Generate additional compressed sitemaps using gzip.'),
'#default_value' => $config->get('gz'),
'#disabled' => !function_exists('gzencode'),
];
......@@ -151,50 +151,50 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
];
$form['advanced']['chunk_size'] = [
'#type' => 'select',
'#title' => t('Number of links in each sitemap page'),
'#options' => ['auto' => t('Automatic (recommended)')] + array_combine($chunk_sizes, $chunk_sizes),
'#title' => $this->t('Number of links in each sitemap page'),
'#options' => ['auto' => $this->t('Automatic (recommended)')] + array_combine($chunk_sizes, $chunk_sizes),
'#default_value' => xmlsitemap_var('chunk_size'),
// @todo This description is not clear.
'#description' => t('If there are problems with rebuilding the sitemap, you may want to manually set this value. If you have more than @max links, an index with multiple sitemap pages will be generated. There is a maximum of @max sitemap pages.', ['@max' => XMLSITEMAP_MAX_SITEMAP_LINKS]),
'#description' => $this->t('If there are problems with rebuilding the sitemap, you may want to manually set this value. If you have more than @max links, an index with multiple sitemap pages will be generated. There is a maximum of @max sitemap pages.', ['@max' => XMLSITEMAP_MAX_SITEMAP_LINKS]),
];
$batch_limits = [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000];
$form['advanced']['batch_limit'] = [
'#type' => 'select',
'#title' => t('Maximum number of sitemap links to process at once'),
'#title' => $this->t('Maximum number of sitemap links to process at once'),
'#options' => array_combine($batch_limits, $batch_limits),
'#default_value' => xmlsitemap_var('batch_limit'),
'#description' => t('If you have problems running cron or rebuilding the sitemap, you may want to lower this value.'),
'#description' => $this->t('If you have problems running cron or rebuilding the sitemap, you may want to lower this value.'),
];
if (!xmlsitemap_check_directory()) {
$form_state->setErrorByName('path', t('The directory %directory does not exist or is not writable.', ['%directory' => xmlsitemap_get_directory()]));
$form_state->setErrorByName('path', $this->t('The directory %directory does not exist or is not writable.', ['%directory' => xmlsitemap_get_directory()]));
}
$form['advanced']['path'] = [
'#type' => 'textfield',
'#title' => t('Sitemap cache directory'),
'#title' => $this->t('Sitemap cache directory'),
'#default_value' => $config->get('path'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('Subdirectory where the sitemap data will be stored. This folder <strong>must not be shared</strong> with any other Drupal site or install using XML sitemap.'),
'#description' => $this->t('Subdirectory where the sitemap data will be stored. This folder <strong>must not be shared</strong> with any other Drupal site or install using XML sitemap.'),
'#field_prefix' => file_build_uri(''),
'#required' => TRUE,
];
$base_url_override = Settings::get('xmlsitemap_base_url', FALSE);
$form['advanced']['xmlsitemap_base_url'] = [
'#type' => 'textfield',
'#title' => t('Default base URL'),
'#title' => $this->t('Default base URL'),
'#default_value' => $base_url_override ? $base_url_override : $this->state->get('xmlsitemap_base_url'),
'#size' => 30,
'#description' => t('This is the default base URL used for sitemaps and sitemap links.'),
'#description' => $this->t('This is the default base URL used for sitemaps and sitemap links.'),
'#required' => TRUE,
'#disabled' => !empty($base_url_override),
];
$form['advanced']['lastmod_format'] = [
'#type' => 'select',
'#title' => t('Last modification date format'),
'#title' => $this->t('Last modification date format'),
'#options' => [
XMLSITEMAP_LASTMOD_SHORT => t('Short'),
XMLSITEMAP_LASTMOD_MEDIUM => t('Medium'),
XMLSITEMAP_LASTMOD_LONG => t('Long'),
XMLSITEMAP_LASTMOD_SHORT =>$this->t('Short'),
XMLSITEMAP_LASTMOD_MEDIUM => $this->t('Medium'),
XMLSITEMAP_LASTMOD_LONG => $this->t('Long'),
],
'#default_value' => $config->get('lastmod_format'),
];
......@@ -203,15 +203,15 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
}
$form['advanced']['xmlsitemap_developer_mode'] = [
'#type' => 'checkbox',
'#title' => t('Enable developer mode to expose additional settings.'),
'#title' => $this->t('Enable developer mode to expose additional settings.'),
'#default_value' => $this->state->get('xmlsitemap_developer_mode'),
];
$form['advanced']['disable_cron_regeneration'] = [
'#type' => 'checkbox',
'#title' => t('Disable cron generation of sitemap files.'),
'#title' => $this->t('Disable cron generation of sitemap files.'),
'#default_value' => $config->get('disable_cron_regeneration'),
'#description' => t('This can be disabled if other methods are being used to generate the sitemap files, like %drush_regenerate.', ['%drush_regenerate' => 'drush xmlsitemap-regenerate']),
'#description' => $this->t('This can be disabled if other methods are being used to generate the sitemap files, i.e. the <code>drush xmlsitemap:regenerate</code> command.'),
];
$form['xmlsitemap_settings'] = [
......@@ -254,14 +254,14 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
// Check that the chunk size will not create more than 1000 chunks.
$chunk_size = $form_state->getValue('chunk_size');
if ($chunk_size != 'auto' && $chunk_size != 50000 && (xmlsitemap_get_link_count() / $chunk_size) > 1000) {
$form_state->setErrorByName('chunk_size', t('The sitemap page link count of @size will create more than 1,000 sitemap pages. Please increase the link count.', ['@size' => $chunk_size]));
$form_state->setErrorByName('chunk_size', $this->t('The sitemap page link count of @size will create more than 1,000 sitemap pages. Please increase the link count.', ['@size' => $chunk_size]));
}
$base_url = $form_state->getValue('xmlsitemap_base_url');
$base_url = rtrim($base_url, '/');
$form_state->setValue('xmlsitemap_base_url', $base_url);
if ($base_url != '' && !UrlHelper::isValid($base_url, TRUE)) {
$form_state->setErrorByName('xmlsitemap_base_url', t('Invalid base URL.'));
$form_state->setErrorByName('xmlsitemap_base_url', $this->t('Invalid base URL.'));
}
parent::validateForm($form, $form_state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment