protected function TranslateFormBase::translateFilters in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/locale/src/Form/TranslateFormBase.php \Drupal\locale\Form\TranslateFormBase::translateFilters()
Lists locale translation filters that can be applied.
3 calls to TranslateFormBase::translateFilters()
- TranslateFilterForm::buildForm in core/
modules/ locale/ src/ Form/ TranslateFilterForm.php - Form constructor.
- TranslateFilterForm::submitForm in core/
modules/ locale/ src/ Form/ TranslateFilterForm.php - Form submission handler.
- TranslateFormBase::translateFilterValues in core/
modules/ locale/ src/ Form/ TranslateFormBase.php - Builds an array out of search criteria specified in request variables.
File
- core/
modules/ locale/ src/ Form/ TranslateFormBase.php, line 159 - Contains \Drupal\locale\Form\TranslateFormBase.
Class
- TranslateFormBase
- Defines the locale user interface translation form base.
Namespace
Drupal\locale\FormCode
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;
}