Example #1
0
 /**
  * Lists locale translation filters that can be applied.
  */
 protected function translateFilters()
 {
     $filters = array();
     // Get all languages, except English.
     $this->languageManager->reset();
     $languages = language_list();
     $language_options = array();
     foreach ($languages as $langcode => $language) {
         if ($langcode != 'en' || locale_translate_english()) {
             $language_options[$langcode] = $language->name;
         }
     }
     // Pick the current interface language code for the filter.
     $default_langcode = $this->languageManager->getCurrentLanguage()->id;
     if (!isset($language_options[$default_langcode])) {
         $available_langcodes = array_keys($language_options);
         $default_langcode = array_shift($available_langcodes);
     }
     $filters['string'] = array('title' => $this->t('String contains'), 'description' => $this->t('Leave blank to show all strings. The search is case sensitive.'), 'default' => '');
     $filters['langcode'] = array('title' => $this->t('Translation language'), 'options' => $language_options, 'default' => $default_langcode);
     $filters['translation'] = array('title' => $this->t('Search in'), 'options' => array('all' => $this->t('Both translated and untranslated strings'), 'translated' => $this->t('Only translated strings'), 'untranslated' => $this->t('Only untranslated strings')), 'default' => 'all');
     $filters['customized'] = array('title' => $this->t('Translation type'), 'options' => array('all' => $this->t('All'), LOCALE_NOT_CUSTOMIZED => $this->t('Non-customized translation'), LOCALE_CUSTOMIZED => $this->t('Customized translation')), 'states' => array('visible' => array(':input[name=translation]' => array('value' => 'translated'))), 'default' => 'all');
     return $filters;
 }