protected LocaleConfigManager::getTranslatableData(TypedDataInterface $element)
Gets translatable configuration data for a typed configuration element.
Parameters
\Drupal\Core\TypedData\TypedDataInterface $element: Typed configuration element.
Return value
array|\Drupal\Core\StringTranslation\TranslatableMarkup A nested array matching the exact structure under $element with only the elements that are translatable wrapped into a TranslatableMarkup. If the provided $element is not traversable, the return value is a single TranslatableMarkup.
File
- core/modules/locale/src/LocaleConfigManager.php, line 165
Class
- LocaleConfigManager
- Manages configuration supported in part by interface translation.
Namespace
Drupal\locale
Code
protected function getTranslatableData(TypedDataInterface $element) { $translatable = array(); if ($element instanceof TraversableTypedDataInterface) { foreach ($element as $key => $property) { $value = $this->getTranslatableData($property); if (!empty($value)) { $translatable[$key] = $value; } } } else { // Something is only translatable by Locale if there is a string in the // first place. $value = $element->getValue(); $definition = $element->getDataDefinition(); if (!empty($definition['translatable']) && $value !== '' && $value !== NULL) { $options = array(); if (isset($definition['translation context'])) { $options['context'] = $definition['translation context']; } return new TranslatableMarkup($value, array(), $options); } } return $translatable; }
Please login to continue.