protected TranslateFormBase::translateFilters()
Lists locale translation filters that can be applied.
File
- core/modules/locale/src/Form/TranslateFormBase.php, line 154
Class
- TranslateFormBase
- Defines the locale user interface translation form base.
Namespace
Drupal\locale\Form
Code
protected function translateFilters() {
$filters = array();
// Get all languages, except English.
$this->languageManager->reset();
$languages = $this->languageManager->getLanguages();
$language_options = array();
foreach ($languages as $langcode => $language) {
if (locale_is_translatable($langcode)) {
$language_options[$langcode] = $language->getName();
}
}
// Pick the current interface language code for the filter.
$default_langcode = $this->languageManager->getCurrentLanguage()->getId();
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;
}
Please login to continue.