diff --git a/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php b/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php index f888b98..f8c0baf 100644 --- a/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php +++ b/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php @@ -1,4 +1,5 @@ moduleHandler->loadInclude('locale', 'inc', 'locale.compare'); + $this->moduleHandler()->loadInclude('locale', 'inc', 'locale.compare'); // Check translation status of all translatable project in all languages. // First we clear the cached list of projects. Although not strictly - // nescessary, this is helpfull in case the project list is out of sync. + // nescessary, this is helpful in case the project list is out of sync. locale_translation_flush_projects(); locale_translation_check_projects(); @@ -42,11 +39,14 @@ public function checkTranslation() { return batch_process('admin/reports/translations'); } - return $this->redirect($this->urlGenerator->generateFromPath('admin/reports/translations', array('absolute' => TRUE))); + return $this->redirect($this->urlGenerator()->generateFromPath('admin/reports/translations', array('absolute' => TRUE))); } /** * Shows the string search screen. + * + * @return array + * The render array for the string search screen. */ public function translatePage() { return array( @@ -54,4 +54,5 @@ public function translatePage() { 'form' => drupal_get_form(TranslateEditForm::create($this->container)), ); } + } diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php index 37cefe6..45e81c2 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php @@ -14,6 +14,7 @@ * Defines a translation edit form. */ class TranslateEditForm extends TranslateFormBase { + /** * {@inheritdoc} */ diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php index caaba77..c6a36f2 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php @@ -83,29 +83,22 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { + public function submitForm(array &$form, array &$form_state) { + $filters = $this->translateFilters(); + foreach ($filters as $name => $filter) { + if (isset($form_state['values'][$name])) { + $_SESSION['locale_translate_filter'][$name] = $form_state['values'][$name]; + } + } + $form_state['redirect'] = 'admin/config/regional/translate'; } /** * {@inheritdoc} */ - public function submitForm(array &$form, array &$form_state) { - $op = $form_state['values']['op']; + public function resetForm(array &$form, array &$form_state) { $filters = $this->translateFilters(); - switch ($op) { - case $this->t('Filter'): - foreach ($filters as $name => $filter) { - if (isset($form_state['values'][$name])) { - $_SESSION['locale_translate_filter'][$name] = $form_state['values'][$name]; - } - } - break; - - case $this->t('Reset'): - $_SESSION['locale_translate_filter'] = array(); - break; - } - + $_SESSION['locale_translate_filter'] = array(); $form_state['redirect'] = 'admin/config/regional/translate'; } diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php index 6753f82..95d9ca7 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php @@ -8,6 +8,8 @@ namespace Drupal\locale\Form; use Drupal\Core\Form\FormBase; +use Drupal\Core\Language\Language; +use Drupal\Core\Language\LanguageManager; use Drupal\locale\StringStorageInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -33,21 +35,34 @@ */ protected $state; + /** + * The language manager. + * + * @var \Drupal\Core\Language\LanguageManager + */ + protected $LanguageManager; + /* * Filter values. Shared between objects that inherite this class. * - * @var array | null + * @var array|null */ public static $filter_values = NULL; /** * Constructs a new TranslationFormBase object. * - * The translation manager service. + * @param \Drupal\locale\StringStorageInterface $locale_storage + * The locale storage. + * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * The state service. + * @param \Drupal\Core\Language\LanguageManager $language_manager + * The language manager. */ - public function __construct(StringStorageInterface $locale_storage, KeyValueStore $state) { + public function __construct(StringStorageInterface $locale_storage, KeyValueStore $state, LanguageManager $language_manager) { $this->localeStorage = $locale_storage; $this->state = $state; + $this->languageManager = $language_manager; } /** @@ -56,14 +71,18 @@ public function __construct(StringStorageInterface $locale_storage, KeyValueStor public static function create(ContainerInterface $container) { return new static( $container->get('locale.storage'), - $container->get('keyvalue')->get('state') + $container->get('state'), + $container->get('language_manager') ); } /** * Builds a string search query and returns an array of string objects. * - * @return array + * @param bool $reset + * If the list of values should be reset. + * + * @return array $filter_values * Array of \Drupal\locale\TranslationString objects. */ protected function translateFilterLoadStrings() { @@ -152,7 +171,7 @@ protected function translateFilters() { } // Pick the current interface language code for the filter. - $default_langcode = language(Language::TYPE_INTERFACE)->id; + $default_langcode = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id; if (!isset($language_options[$default_langcode])) { $available_langcodes = array_keys($language_options); $default_langcode = array_shift($available_langcodes);