/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $mappings = language_get_browser_drupal_langcode_mappings(); if (array_key_exists($this->browserLangcode, $mappings)) { unset($mappings[$this->browserLangcode]); language_set_browser_drupal_langcode_mappings($mappings); } $form_state['redirect_route']['route_name'] = 'language.negotiation_browser'; }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $mappings = language_get_browser_drupal_langcode_mappings(); if (array_key_exists($this->browserLangcode, $mappings)) { unset($mappings[$this->browserLangcode]); language_set_browser_drupal_langcode_mappings($mappings); } $form_state->setRedirect('language.negotiation_browser'); }
/** * Returns a list of language codes supported by CKEditor. * * @return array * An associative array keyed by language codes. */ public function getLangcodes() { // Cache the file system based language list calculation because this would // be expensive to calculate all the time. The cache is cleared on core // upgrades which is the only situation the CKEditor file listing should // change. $langcode_cache = \Drupal::cache()->get('ckeditor.langcodes'); if (!empty($langcode_cache)) { $langcodes = $langcode_cache->data; } if (empty($langcodes)) { $langcodes = array(); // Collect languages included with CKEditor based on file listing. $ckeditor_languages = new \GlobIterator(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js'); foreach ($ckeditor_languages as $language_file) { $langcode = $language_file->getBasename('.js'); $langcodes[$langcode] = $langcode; } \Drupal::cache()->set('ckeditor.langcodes', $langcodes); } // Get language mapping if available to map to Drupal language codes. // This is configurable in the user interface and not expensive to get, so // we don't include it in the cached language list. $language_mappings = $this->moduleHandler->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : array(); foreach ($langcodes as $langcode) { // If this language code is available in a Drupal mapping, use that to // compute a possibility for matching from the Drupal langcode to the // CKEditor langcode. // e.g. CKEditor uses the langcode 'no' for Norwegian, Drupal uses 'nb'. // This would then remove the 'no' => 'no' mapping and replace it with // 'nb' => 'no'. Now Drupal knows which CKEditor translation to load. if (isset($language_mappings[$langcode]) && !isset($langcodes[$language_mappings[$langcode]])) { $langcodes[$language_mappings[$langcode]] = $langcode; unset($langcodes[$langcode]); } } return $langcodes; }