Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -12,7 +12,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
|
|||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\Core\Config\TypedConfigManagerInterface;
|
||||
use Drupal\Core\StringTranslation\TranslationWrapper;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\Core\TypedData\TraversableTypedDataInterface;
|
||||
use Drupal\Core\TypedData\TypedDataInterface;
|
||||
use Drupal\language\ConfigurableLanguageManagerInterface;
|
||||
|
@ -122,13 +122,14 @@ class LocaleConfigManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets array of translation wrappers for translatable configuration.
|
||||
* Gets array of translated strings for Locale translatable configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* Configuration object name.
|
||||
*
|
||||
* @return array
|
||||
* Array of translatable elements of the default configuration in $name.
|
||||
* Array of Locale translatable elements of the default configuration in
|
||||
* $name.
|
||||
*/
|
||||
public function getTranslatableDefaultConfig($name) {
|
||||
if ($this->isSupported($name)) {
|
||||
|
@ -150,11 +151,11 @@ class LocaleConfigManager {
|
|||
* @param \Drupal\Core\TypedData\TypedDataInterface $element
|
||||
* Typed configuration element.
|
||||
*
|
||||
* @return array|\Drupal\Core\StringTranslation\TranslationWrapper
|
||||
* @return array|\Drupal\Core\StringTranslation\TranslatableMarkup
|
||||
* A nested array matching the exact structure under $element with only the
|
||||
* elements that are translatable wrapped into a TranslationWrapper. If the
|
||||
* elements that are translatable wrapped into a TranslatableMarkup. If the
|
||||
* provided $element is not traversable, the return value is a single
|
||||
* TranslationWrapper.
|
||||
* TranslatableMarkup.
|
||||
*/
|
||||
protected function getTranslatableData(TypedDataInterface $element) {
|
||||
$translatable = array();
|
||||
|
@ -167,13 +168,16 @@ class LocaleConfigManager {
|
|||
}
|
||||
}
|
||||
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'])) {
|
||||
if (!empty($definition['translatable']) && $value !== '' && $value !== NULL) {
|
||||
$options = array();
|
||||
if (isset($definition['translation context'])) {
|
||||
$options['context'] = $definition['translation context'];
|
||||
}
|
||||
return new TranslationWrapper($element->getValue(), array(), $options);
|
||||
return new TranslatableMarkup($value, array(), $options);
|
||||
}
|
||||
}
|
||||
return $translatable;
|
||||
|
@ -191,10 +195,10 @@ class LocaleConfigManager {
|
|||
* The configuration name.
|
||||
* @param array $active
|
||||
* The active configuration data.
|
||||
* @param array|\Drupal\Core\StringTranslation\TranslationWrapper[] $translatable
|
||||
* @param 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 TranslationWrapper.
|
||||
* elements that are translatable wrapped into a TranslatableMarkup.
|
||||
* @see self::getTranslatableData().
|
||||
* @param string $langcode
|
||||
* The language code to process the array with.
|
||||
|
@ -559,33 +563,27 @@ class LocaleConfigManager {
|
|||
|
||||
foreach ($langcodes as $langcode) {
|
||||
$processed = $this->processTranslatableData($name, $active, $translatable, $langcode);
|
||||
// If the language code is not the same as the active storage
|
||||
// language, we should update the configuration override.
|
||||
if ($langcode != $active_langcode) {
|
||||
// If the language code is not the same as the active storage
|
||||
// language, we should update a configuration override.
|
||||
$override = $this->languageManager->getLanguageConfigOverride($langcode, $name);
|
||||
// Filter out locale managed configuration keys so that translations
|
||||
// removed from Locale will be reflected in the config override.
|
||||
$data = $this->filterOverride($override->get(), $translatable);
|
||||
if (!empty($processed)) {
|
||||
// Update translation data in configuration override.
|
||||
$this->saveTranslationOverride($name, $langcode, $processed);
|
||||
// Merge in the Locale managed translations with existing data.
|
||||
$data = NestedArray::mergeDeepArray(array($data, $processed), TRUE);
|
||||
}
|
||||
if (empty($data) && !$override->isNew()) {
|
||||
// The configuration override contains Locale overrides that no
|
||||
// longer exist.
|
||||
$this->deleteTranslationOverride($name, $langcode);
|
||||
$count++;
|
||||
}
|
||||
else {
|
||||
$override = $this->languageManager->getLanguageConfigOverride($langcode, $name);
|
||||
if (!$override->isNew()) {
|
||||
$data = $this->filterOverride($override->get(), $translatable);
|
||||
if (empty($data)) {
|
||||
// Delete language override if there is no data left at all.
|
||||
// This means all prior translations in the override were locale
|
||||
// managed.
|
||||
$this->deleteTranslationOverride($name, $langcode);
|
||||
$count++;
|
||||
}
|
||||
else {
|
||||
// If there were translatable elements besides locale managed
|
||||
// items, save with only those, and remove the ones managed
|
||||
// by locale only.
|
||||
$this->saveTranslationOverride($name, $langcode, $data);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
elseif (!empty($data)) {
|
||||
// Update translation data in configuration override.
|
||||
$this->saveTranslationOverride($name, $langcode, $data);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
elseif (locale_is_translatable($langcode)) {
|
||||
|
|
Reference in a new issue