protected LocaleConfigManager::processTranslatableData($name, array $active, array $translatable, $langcode)
Process the translatable data array with a given language.
If the given language is translatable, will return the translated copy which will only contain strings that had translations. If the given language is English and is not translatable, will return a simplified array of the English source strings only.
Parameters
string $name: The configuration name.
array $active: The active configuration data.
array|\Drupal\Core\StringTranslation\TranslatableMarkup[] $translatable: The translatable array structure. A nested array matching the exact structure under of the default configuration for $name with only the elements that are translatable wrapped into a TranslatableMarkup.
string $langcode: The language code to process the array with.
Return value
array Processed translatable data array. Will only contain translations different from source strings or in case of untranslatable English, the source strings themselves.
See also
self::getTranslatableData()
File
- core/modules/locale/src/LocaleConfigManager.php, line 217
Class
- LocaleConfigManager
- Manages configuration supported in part by interface translation.
Namespace
Drupal\locale
Code
protected function processTranslatableData($name, array $active, array $translatable, $langcode) { $translated = array(); foreach ($translatable as $key => $item) { if (!isset($active[$key])) { continue; } if (is_array($item)) { // Only add this key if there was a translated value underneath. $value = $this->processTranslatableData($name, $active[$key], $item, $langcode); if (!empty($value)) { $translated[$key] = $value; } } else { if (locale_is_translatable($langcode)) { $value = $this->translateString($name, $langcode, $item->getUntranslatedString(), $item->getOption('context')); } else { $value = $item->getUntranslatedString(); } if (!empty($value)) { $translated[$key] = $value; } } } return $translated; }
Please login to continue.