Commit ed3bc9bf authored by xjm's avatar xjm

Issue #2565981 by joelpittet, alexpott, Gábor Hojtsy, tstoeckler: Remove...

Issue #2565981 by joelpittet, alexpott, Gábor Hojtsy, tstoeckler: Remove $this->t() and SafeMarkup::format() in SelectLanguageForm
parent 5a46f6ae
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Installer\Form; namespace Drupal\Core\Installer\Form;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\UserAgent; use Drupal\Component\Utility\UserAgent;
use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
...@@ -16,6 +15,9 @@ ...@@ -16,6 +15,9 @@
/** /**
* Provides the language selection form. * Provides the language selection form.
*
* Note that hardcoded text provided by this form is not translated. This is
* because translations are downloaded as a result of submitting this form.
*/ */
class SelectLanguageForm extends FormBase { class SelectLanguageForm extends FormBase {
...@@ -40,7 +42,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ ...@@ -40,7 +42,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_
$select_options = array(); $select_options = array();
$browser_options = array(); $browser_options = array();
$form['#title'] = $this->t('Choose language'); $form['#title'] = 'Choose language';
// Build a select list with language names in native language for the user // Build a select list with language names in native language for the user
// to choose from. And build a list of available languages for the browser // to choose from. And build a list of available languages for the browser
...@@ -62,18 +64,18 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ ...@@ -62,18 +64,18 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_
$browser_langcode = UserAgent::getBestMatchingLangcode($request->server->get('HTTP_ACCEPT_LANGUAGE'), $browser_options); $browser_langcode = UserAgent::getBestMatchingLangcode($request->server->get('HTTP_ACCEPT_LANGUAGE'), $browser_options);
$form['langcode'] = array( $form['langcode'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => $this->t('Choose language'), '#title' => 'Choose language',
'#title_display' => 'invisible', '#title_display' => 'invisible',
'#options' => $select_options, '#options' => $select_options,
// Use the browser detected language as default or English if nothing found. // Use the browser detected language as default or English if nothing found.
'#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en', '#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en',
); );
$link_to_english = install_full_redirect_url(array('parameters' => array('langcode' => 'en')));
$form['help'] = array( $form['help'] = array(
'#type' => 'item', '#type' => 'item',
'#markup' => SafeMarkup::format('<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>. // #markup is XSS admin filtered which ensures unsafe protocols will be
If you do not want this, select <a href="!english">English</a>.</p>', array( // removed from the url.
'!english' => install_full_redirect_url(array('parameters' => array('langcode' => 'en'))), '#markup' => '<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>. If you do not want this, select <a href="' . $link_to_english . '">English</a>.</p>',
)),
'#states' => array( '#states' => array(
'invisible' => array( 'invisible' => array(
'select[name="langcode"]' => array('value' => 'en'), 'select[name="langcode"]' => array('value' => 'en'),
...@@ -83,7 +85,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ ...@@ -83,7 +85,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_
$form['actions'] = array('#type' => 'actions'); $form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array( $form['actions']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->t('Save and continue'), '#value' => 'Save and continue',
'#button_type' => 'primary', '#button_type' => 'primary',
); );
return $form; return $form;
......
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