protected ContentTranslationHandler::addTranslatabilityClue(&$element)
Adds a clue about the form element translatability.
If the given element does not have a #title attribute, the function is recursively applied to child elements.
Parameters
array $element: A form element array.
File
- core/modules/content_translation/src/ContentTranslationHandler.php, line 536
Class
- ContentTranslationHandler
- Base class for content translation handlers.
Namespace
Drupal\content_translation
Code
protected function addTranslatabilityClue(&$element) { static $suffix, $fapi_title_elements; // Elements which can have a #title attribute according to FAPI Reference. if (!isset($suffix)) { $suffix = ' <span class="translation-entity-all-languages">(' . t('all languages') . ')</span>'; $fapi_title_elements = array_flip(array('checkbox', 'checkboxes', 'date', 'details', 'fieldset', 'file', 'item', 'password', 'password_confirm', 'radio', 'radios', 'select', 'text_format', 'textarea', 'textfield', 'weight')); } // Update #title attribute for all elements that are allowed to have a // #title attribute according to the Form API Reference. The reason for this // check is because some elements have a #title attribute even though it is // not rendered; for instance, field containers. if (isset($element['#type']) && isset($fapi_title_elements[$element['#type']]) && isset($element['#title'])) { $element['#title'] .= $suffix; } // If the current element does not have a (valid) title, try child elements. elseif ($children = Element::children($element)) { foreach ($children as $delta) { $this->addTranslatabilityClue($element[$delta], $suffix); } } // If there are no children, fall back to the current #title attribute if it // exists. elseif (isset($element['#title'])) { $element['#title'] .= $suffix; } }
Please login to continue.