diff --git a/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php b/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php index 4fd5657..cedb28c 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/ImportForm.php @@ -7,6 +7,7 @@ namespace Drupal\locale\Form; +use Drupal\file\FileInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Language\Language; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; @@ -17,6 +18,7 @@ * Form constructor for the translation import screen. */ class ImportForm extends FormBase implements ContainerInjectionInterface { + /** * Module Handler Service. * @@ -35,7 +37,7 @@ public static function create(ContainerInterface $container) { /** * Constructs an ImportForm. * - * @param $module_handler \Drupal\Core\Extension\ModuleHandlerInterface + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */ public function __construct(ModuleHandlerInterface $module_handler) { $this->moduleHandler = $module_handler; @@ -51,12 +53,10 @@ public function getFormID() { /** * Form constructor for the translation import screen. * - * @return - * A form array representing the currently disabled modules. - * * @ingroup forms */ public function buildForm(array $form, array &$form_state) { + \Drupal::languageManager()->reset(); $languages = language_list(); // Initialize a language list to the ones available, including English if we @@ -146,7 +146,7 @@ public function buildForm(array $form, array &$form_state) { */ public function submitForm(array &$form, array &$form_state) { // Ensure we have the file uploaded. - if ($file = file_save_upload('file', $form['file']['#upload_validators'], 'translations://', 0)) { + if ($file = file_save_upload('file', $form_state, $form['file']['#upload_validators'], 'translations://', 0)) { // Add language, if not yet supported. $language = language_load($form_state['values']['langcode']); @@ -155,7 +155,7 @@ public function submitForm(array &$form, array &$form_state) { 'id' => $form_state['values']['langcode'] )); $language = language_save($language); - drupal_set_message($this->t('The language %language has been created and can now be used.', array('%language' => $language->name))); + drupal_set_message(t('The language %language has been created.', array('%language' => t($language->name)))); } $options = array( 'langcode' => $form_state['values']['langcode'], @@ -168,12 +168,13 @@ public function submitForm(array &$form, array &$form_state) { batch_set($batch); } else { - form_set_error('file', $this->t('File to import not found.')); + $this->setFormError('file', $form_state, $this->t('File to import not found.')); $form_state['rebuild'] = TRUE; return; } - $form_state['redirect'] = 'admin/config/regional/translate'; + $form_state['redirect_route']['route_name'] = 'locale.translate_page'; return; } + } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 7f6d25e..d822f10 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -61,7 +61,7 @@ function testStandalonePoFile() { )); \Drupal::config('locale.settings'); // The import should automatically create the corresponding language. - $this->assertRaw(t('The language %language has been created and can now be used.', array('%language' => 'French')), 'The language has been automatically created.'); + $this->assertRaw(t('The language %language has been created.', array('%language' => 'French')), 'The language has been automatically created.'); // The import should have created 8 strings. $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 8, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');