reverted: --- b/core/modules/language/language.install +++ /dev/null @@ -1,26 +0,0 @@ -getModuleList()) as $module) { - $language_config_override->install('module', $module); - } - /** @var \Drupal\Core\Extension\ThemeHandler $theme_handler */ - $theme_handler = \Drupal::service('theme_handler'); - foreach ($theme_handler->listInfo() as $theme) { - if ($theme->status) { - $language_config_override->install('theme', $theme->name); - } - } - \Drupal::configFactory()->reset(); -} diff -u b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php --- b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php +++ b/core/modules/language/lib/Drupal/language/Config/LanguageConfigFactoryOverride.php @@ -7,6 +7,7 @@ namespace Drupal\language\Config; +use Drupal\Core\Config\ExtensionInstallStorage; use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\TypedConfigManagerInterface; @@ -102,7 +103,7 @@ */ public function getStorage($langcode) { if (!isset($this->storages[$langcode])) { - $this->storages[$langcode] = $this->baseStorage->createCollection('language.' . $langcode); + $this->storages[$langcode] = $this->baseStorage->createCollection($this->createConfigCollectionName($langcode)); } return $this->storages[$langcode]; } @@ -142,21 +143,13 @@ */ public function install($type, $name) { // Work out if this extension provides default language overrides. - $config_dir = drupal_get_path($type, $name) . '/config/install/language'; - if (is_dir($config_dir)) { - // List all the directories. - // \DirectoryIterator on Windows requires an absolute path. - $it = new \DirectoryIterator(realpath($config_dir)); - foreach ($it as $dir) { - if (!$dir->isDot() && $dir->isDir() ) { - $default_language_config = new FileStorage($dir->getPathname()); - $storage = $this->getStorage($dir->getFilename()); - foreach ($default_language_config->listAll() as $config_name) { - $data = $default_language_config->read($config_name); - $config = new LanguageConfigOverride($config_name, $storage, $this->typedConfigManager); - $config->setData($data)->save(); - } - } + foreach (\Drupal::languageManager()->getLanguages() as $language) { + $install_storage = new ExtensionInstallStorage($this->baseStorage, ExtensionInstallStorage::CONFIG_INSTALL_DIRECTORY, $this->createConfigCollectionName($language->getId())); + $storage = $this->getStorage($language->getId()); + foreach ($install_storage->listAll() as $config_name) { + $data = $install_storage->read($config_name); + $config = new LanguageConfigOverride($config_name, $storage, $this->typedConfigManager); + $config->setData($data)->save(); } } } @@ -173,2 +166,15 @@ + /** + * Creates a configuration collection name based on a langcode. + * + * @param $langcode + * The langcode. + * + * @return string + * The configuration collection name for a langcode. + */ + protected function createConfigCollectionName($langcode) { + return 'language.' . $langcode; + } + } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -32,9 +32,10 @@ class ExtensionInstallStorage extends InstallStorage { * The directory to scan in each extension to scan for files. Defaults to * 'config'. */ - public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY) { + public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = self::DEFAULT_COLLECTION) { $this->configStorage = $config_storage; $this->directory = $directory; + $this->collection = $collection; } /** only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -53,8 +53,9 @@ class InstallStorage extends FileStorage { * The directory to scan in each extension to scan for files. Defaults to * 'config'. */ - public function __construct($directory = self::CONFIG_INSTALL_DIRECTORY) { + public function __construct($directory = self::CONFIG_INSTALL_DIRECTORY, $collection = self::DEFAULT_COLLECTION) { $this->directory = $directory; + $this->collection = $collection; } /** @@ -198,7 +199,7 @@ public function getComponentNames($type, array $list) { * The configuration folder name for this component. */ protected function getComponentFolder($type, $name) { - return drupal_get_path($type, $name) . '/' . $this->directory; + return drupal_get_path($type, $name) . '/' . $this->getCollectionDirectory(); } /** only in patch2: unchanged: --- a/core/modules/config/lib/Drupal/config/Tests/ConfigLanguageOverrideTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLanguageOverrideTest.php @@ -32,6 +32,14 @@ public static function getInfo() { public function setUp() { parent::setUp(); + language_save(new Language(array( + 'name' => 'French', + 'id' => 'fr', + ))); + language_save(new Language(array( + 'name' => 'German', + 'id' => 'de', + ))); $this->installConfig(array('config_test')); } @@ -50,15 +58,6 @@ function testConfigLanguageOverride() { $raw = $config->getRawData(); $this->assertIdentical($raw['foo'], 'bar'); - language_save(new Language(array( - 'name' => 'French', - 'id' => 'fr', - ))); - language_save(new Language(array( - 'name' => 'German', - 'id' => 'de', - ))); - \Drupal::languageManager()->setConfigOverrideLanguage(language_load('fr')); $config = \Drupal::config('config_test.system'); $this->assertIdentical($config->get('foo'), 'fr bar');