Loading core/modules/locale/locale.bulk.inc +9 −7 Original line number Diff line number Diff line Loading @@ -6,12 +6,11 @@ */ use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Url; use Drupal\Core\File\Exception\FileException; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url; use Drupal\file\FileInterface; use Drupal\locale\Gettext; use Drupal\locale\Locale; /** * Prepare a batch to import all translations. Loading Loading @@ -328,7 +327,8 @@ function locale_translate_batch_refresh(&$context) { } elseif ($name = array_shift($context['sandbox']['refresh']['names'])) { // Refresh all languages for one object at a time. $count = Locale::config()->updateConfigTranslations([$name], $context['sandbox']['refresh']['languages']); $count = \Drupal::service('locale.config_manager') ->updateConfigTranslations([$name], $context['sandbox']['refresh']['languages']); $context['results']['stats']['config'] += $count; // Inherit finished information from the "parent" string lookup step so // visual display of status will make sense. Loading @@ -344,7 +344,8 @@ function locale_translate_batch_refresh(&$context) { // Clear cache and force refresh of JavaScript translations. _locale_refresh_translations($context['sandbox']['refresh']['languages'], $next); // Check whether we need to refresh configuration objects. if ($names = Locale::config()->getStringNames($next)) { if ($names = \Drupal::service('locale.config_manager') ->getStringNames($next)) { $context['sandbox']['refresh']['names_finished'] = $context['finished']; $context['sandbox']['refresh']['names'] = $names; } Loading Loading @@ -547,7 +548,7 @@ function locale_translate_delete_translation_files(array $projects = [], array $ */ function locale_config_batch_update_components(array $options, array $langcodes = [], array $components = [], bool $update_default_config_langcodes = FALSE) { $langcodes = $langcodes ? $langcodes : array_keys(\Drupal::languageManager()->getLanguages()); if ($langcodes && $names = Locale::config()->getComponentNames($components)) { if ($langcodes && $names = \Drupal::service('locale.config_manager')->getComponentNames($components)) { // If the component list is empty we need to ensure that all configuration // in the default collection is using the site's default langcode. return locale_config_batch_build($names, $langcodes, $options, $update_default_config_langcodes); Loading Loading @@ -612,7 +613,7 @@ function locale_config_batch_build(array $names, array $langcodes, array $option * The batch context. */ function locale_config_batch_set_config_langcodes(&$context) { Locale::config()->updateDefaultConfigLangcodes(); \Drupal::service('locale.config_manager')->updateDefaultConfigLangcodes(); $context['finished'] = 1; $context['message'] = t('Updated default configuration to %langcode', ['%langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId()]); } Loading @@ -635,7 +636,8 @@ function locale_config_batch_refresh_name(array $names, array $langcodes, &$cont if (!isset($context['results']['stats']['config'])) { $context['results']['stats']['config'] = 0; } $context['results']['stats']['config'] += Locale::config()->updateConfigTranslations($names, $langcodes); $context['results']['stats']['config'] += \Drupal::service('locale.config_manager') ->updateConfigTranslations($names, $langcodes); foreach ($names as $name) { $context['results']['names'][] = $name; } Loading core/modules/locale/locale.module +5 −5 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\language\ConfigurableLanguageInterface; use Drupal\Component\Utility\Crypt; use Drupal\locale\Locale; use Drupal\locale\LocaleEvent; use Drupal\locale\LocaleEvents; Loading Loading @@ -238,7 +237,7 @@ function locale_configurable_language_delete(ConfigurableLanguageInterface $lang locale_translate_delete_translation_files([], [$language->id()]); // Remove translated configuration objects. Locale::config()->deleteLanguageTranslations($language->id()); \Drupal::service('locale.config_manager')->deleteLanguageTranslations($language->id()); // Changing the language settings impacts the interface: _locale_invalidate_js($language->id()); Loading Loading @@ -367,7 +366,7 @@ function locale_cron() { * Updates default configuration when new modules or themes are installed. */ function locale_system_set_config_langcodes() { Locale::config()->updateDefaultConfigLangcodes(); \Drupal::service('locale.config_manager')->updateDefaultConfigLangcodes(); } /** Loading Loading @@ -1053,8 +1052,9 @@ function _locale_refresh_translations($langcodes, $lids = []) { * List of string identifiers that have been updated / created. */ function _locale_refresh_configuration(array $langcodes, array $lids) { if ($lids && $langcodes && $names = Locale::config()->getStringNames($lids)) { Locale::config()->updateConfigTranslations($names, $langcodes); $locale_config_manager = \Drupal::service('locale.config_manager'); if ($lids && $langcodes && $names = $locale_config_manager->getStringNames($lids)) { $locale_config_manager->updateConfigTranslations($names, $langcodes); } } Loading core/modules/locale/src/Locale.phpdeleted 100644 → 0 +0 −24 Original line number Diff line number Diff line <?php namespace Drupal\locale; /** * Static service container wrapper for locale. */ class Locale { /** * Returns the locale configuration manager service. * * Use the locale config manager service for creating locale-wrapped typed * configuration objects. * * @see \Drupal\Core\TypedData\TypedDataManager::create() * * @return \Drupal\locale\LocaleConfigManager */ public static function config() { return \Drupal::service('locale.config_manager'); } } core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php +2 −3 Original line number Diff line number Diff line Loading @@ -4,9 +4,8 @@ namespace Drupal\Tests\locale\Functional; use Drupal\locale\Locale; use Drupal\Tests\BrowserTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\BrowserTestBase; /** * Tests translation update's effects on configuration translations. Loading Loading @@ -233,7 +232,7 @@ public function testLocaleRemovalAndConfigOverrideDelete() { $string = $locale_storage->findString(['source' => 'Locale can translate']); \Drupal::service('locale.storage')->delete($string); // Force a rebuild of config translations. $count = Locale::config()->updateConfigTranslations(['locale_test_translate.settings'], ['af']); $count = \Drupal::service('locale.config_manager')->updateConfigTranslations(['locale_test_translate.settings'], ['af']); $this->assertEquals(1, $count, 'Correct count of updated translations'); $override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings'); Loading core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -4,11 +4,10 @@ namespace Drupal\Tests\locale\Kernel; use Drupal\KernelTests\KernelTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\locale\Locale; use Drupal\locale\StringInterface; use Drupal\locale\TranslationString; use Drupal\KernelTests\KernelTestBase; /** * Tests that shipped configuration translations are updated correctly. Loading Loading @@ -69,8 +68,9 @@ protected function setUp(): void { // @see locale_system_update() locale_system_set_config_langcodes(); $langcodes = array_keys(\Drupal::languageManager()->getLanguages()); $names = Locale::config()->getComponentNames(); Locale::config()->updateConfigTranslations($names, $langcodes); $locale_config_manager = \Drupal::service('locale.config_manager'); $names = $locale_config_manager->getComponentNames(); $locale_config_manager->updateConfigTranslations($names, $langcodes); $this->configFactory = $this->container->get('config.factory'); $this->stringStorage = $this->container->get('locale.storage'); Loading Loading
core/modules/locale/locale.bulk.inc +9 −7 Original line number Diff line number Diff line Loading @@ -6,12 +6,11 @@ */ use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Url; use Drupal\Core\File\Exception\FileException; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url; use Drupal\file\FileInterface; use Drupal\locale\Gettext; use Drupal\locale\Locale; /** * Prepare a batch to import all translations. Loading Loading @@ -328,7 +327,8 @@ function locale_translate_batch_refresh(&$context) { } elseif ($name = array_shift($context['sandbox']['refresh']['names'])) { // Refresh all languages for one object at a time. $count = Locale::config()->updateConfigTranslations([$name], $context['sandbox']['refresh']['languages']); $count = \Drupal::service('locale.config_manager') ->updateConfigTranslations([$name], $context['sandbox']['refresh']['languages']); $context['results']['stats']['config'] += $count; // Inherit finished information from the "parent" string lookup step so // visual display of status will make sense. Loading @@ -344,7 +344,8 @@ function locale_translate_batch_refresh(&$context) { // Clear cache and force refresh of JavaScript translations. _locale_refresh_translations($context['sandbox']['refresh']['languages'], $next); // Check whether we need to refresh configuration objects. if ($names = Locale::config()->getStringNames($next)) { if ($names = \Drupal::service('locale.config_manager') ->getStringNames($next)) { $context['sandbox']['refresh']['names_finished'] = $context['finished']; $context['sandbox']['refresh']['names'] = $names; } Loading Loading @@ -547,7 +548,7 @@ function locale_translate_delete_translation_files(array $projects = [], array $ */ function locale_config_batch_update_components(array $options, array $langcodes = [], array $components = [], bool $update_default_config_langcodes = FALSE) { $langcodes = $langcodes ? $langcodes : array_keys(\Drupal::languageManager()->getLanguages()); if ($langcodes && $names = Locale::config()->getComponentNames($components)) { if ($langcodes && $names = \Drupal::service('locale.config_manager')->getComponentNames($components)) { // If the component list is empty we need to ensure that all configuration // in the default collection is using the site's default langcode. return locale_config_batch_build($names, $langcodes, $options, $update_default_config_langcodes); Loading Loading @@ -612,7 +613,7 @@ function locale_config_batch_build(array $names, array $langcodes, array $option * The batch context. */ function locale_config_batch_set_config_langcodes(&$context) { Locale::config()->updateDefaultConfigLangcodes(); \Drupal::service('locale.config_manager')->updateDefaultConfigLangcodes(); $context['finished'] = 1; $context['message'] = t('Updated default configuration to %langcode', ['%langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId()]); } Loading @@ -635,7 +636,8 @@ function locale_config_batch_refresh_name(array $names, array $langcodes, &$cont if (!isset($context['results']['stats']['config'])) { $context['results']['stats']['config'] = 0; } $context['results']['stats']['config'] += Locale::config()->updateConfigTranslations($names, $langcodes); $context['results']['stats']['config'] += \Drupal::service('locale.config_manager') ->updateConfigTranslations($names, $langcodes); foreach ($names as $name) { $context['results']['names'][] = $name; } Loading
core/modules/locale/locale.module +5 −5 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\language\ConfigurableLanguageInterface; use Drupal\Component\Utility\Crypt; use Drupal\locale\Locale; use Drupal\locale\LocaleEvent; use Drupal\locale\LocaleEvents; Loading Loading @@ -238,7 +237,7 @@ function locale_configurable_language_delete(ConfigurableLanguageInterface $lang locale_translate_delete_translation_files([], [$language->id()]); // Remove translated configuration objects. Locale::config()->deleteLanguageTranslations($language->id()); \Drupal::service('locale.config_manager')->deleteLanguageTranslations($language->id()); // Changing the language settings impacts the interface: _locale_invalidate_js($language->id()); Loading Loading @@ -367,7 +366,7 @@ function locale_cron() { * Updates default configuration when new modules or themes are installed. */ function locale_system_set_config_langcodes() { Locale::config()->updateDefaultConfigLangcodes(); \Drupal::service('locale.config_manager')->updateDefaultConfigLangcodes(); } /** Loading Loading @@ -1053,8 +1052,9 @@ function _locale_refresh_translations($langcodes, $lids = []) { * List of string identifiers that have been updated / created. */ function _locale_refresh_configuration(array $langcodes, array $lids) { if ($lids && $langcodes && $names = Locale::config()->getStringNames($lids)) { Locale::config()->updateConfigTranslations($names, $langcodes); $locale_config_manager = \Drupal::service('locale.config_manager'); if ($lids && $langcodes && $names = $locale_config_manager->getStringNames($lids)) { $locale_config_manager->updateConfigTranslations($names, $langcodes); } } Loading
core/modules/locale/src/Locale.phpdeleted 100644 → 0 +0 −24 Original line number Diff line number Diff line <?php namespace Drupal\locale; /** * Static service container wrapper for locale. */ class Locale { /** * Returns the locale configuration manager service. * * Use the locale config manager service for creating locale-wrapped typed * configuration objects. * * @see \Drupal\Core\TypedData\TypedDataManager::create() * * @return \Drupal\locale\LocaleConfigManager */ public static function config() { return \Drupal::service('locale.config_manager'); } }
core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php +2 −3 Original line number Diff line number Diff line Loading @@ -4,9 +4,8 @@ namespace Drupal\Tests\locale\Functional; use Drupal\locale\Locale; use Drupal\Tests\BrowserTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\BrowserTestBase; /** * Tests translation update's effects on configuration translations. Loading Loading @@ -233,7 +232,7 @@ public function testLocaleRemovalAndConfigOverrideDelete() { $string = $locale_storage->findString(['source' => 'Locale can translate']); \Drupal::service('locale.storage')->delete($string); // Force a rebuild of config translations. $count = Locale::config()->updateConfigTranslations(['locale_test_translate.settings'], ['af']); $count = \Drupal::service('locale.config_manager')->updateConfigTranslations(['locale_test_translate.settings'], ['af']); $this->assertEquals(1, $count, 'Correct count of updated translations'); $override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'locale_test_translate.settings'); Loading
core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -4,11 +4,10 @@ namespace Drupal\Tests\locale\Kernel; use Drupal\KernelTests\KernelTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\locale\Locale; use Drupal\locale\StringInterface; use Drupal\locale\TranslationString; use Drupal\KernelTests\KernelTestBase; /** * Tests that shipped configuration translations are updated correctly. Loading Loading @@ -69,8 +68,9 @@ protected function setUp(): void { // @see locale_system_update() locale_system_set_config_langcodes(); $langcodes = array_keys(\Drupal::languageManager()->getLanguages()); $names = Locale::config()->getComponentNames(); Locale::config()->updateConfigTranslations($names, $langcodes); $locale_config_manager = \Drupal::service('locale.config_manager'); $names = $locale_config_manager->getComponentNames(); $locale_config_manager->updateConfigTranslations($names, $langcodes); $this->configFactory = $this->container->get('config.factory'); $this->stringStorage = $this->container->get('locale.storage'); Loading