diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php b/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php index ce058de..b0983de 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php @@ -8,6 +8,7 @@ namespace Drupal\locale; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Config\ConfigFactory; use Drupal\Core\DestructableInterface; use Drupal\Core\Language\Language; use Drupal\Core\Lock\LockBackendAbstract; @@ -32,6 +33,13 @@ class LocaleTranslation implements TranslatorInterface, DestructableInterface { protected $storage; /** + * The configuration factory. + * + * @var \Drupal\Core\Config\ConfigFactory + */ + protected $configFactory; + + /** * Cached translations * * @var array @@ -63,11 +71,14 @@ class LocaleTranslation implements TranslatorInterface, DestructableInterface { * The cache backend. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The config factory. */ - public function __construct(StringStorageInterface $storage, CacheBackendInterface $cache, LockBackendInterface $lock) { + public function __construct(StringStorageInterface $storage, CacheBackendInterface $cache, LockBackendInterface $lock, ConfigFactory $config_factory) { $this->storage = $storage; $this->cache = $cache; $this->lock = $lock; + $this->configFactory = $config_factory; } /** @@ -75,7 +86,8 @@ public function __construct(StringStorageInterface $storage, CacheBackendInterfa */ public function getStringTranslation($langcode, $string, $context) { // If the language is not suitable for locale module, just return. - if ($langcode == Language::LANGCODE_SYSTEM || ($langcode == 'en' && !config('locale.settings')->get('translate_english'))) { + $translate_english = $this->configFactory->get('locale.settings')->get('translate_english'); + if ($langcode == Language::LANGCODE_SYSTEM || ($langcode == 'en' && !$translate_english)) { return FALSE; } // Strings are cached by langcode, context and roles, using instances of the diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 00cf978..ded8a09 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -818,7 +818,7 @@ function locale_form_language_admin_edit_form_alter(&$form, &$form_state) { * Form submission handler for language_admin_edit_form(). */ function locale_form_language_admin_edit_form_alter_submit($form, $form_state) { - config('locale.settings')->set('translate_english', intval($form_state['values']['locale_translate_english']))->save(); + Drupal::config('locale.settings')->set('translate_english', intval($form_state['values']['locale_translate_english']))->save(); } /** @@ -828,7 +828,7 @@ function locale_form_language_admin_edit_form_alter_submit($form, $form_state) { * Returns TRUE if content should be translated to English, FALSE otherwise. */ function locale_translate_english() { - return config('locale.settings')->get('translate_english'); + return Drupal::config('locale.settings')->get('translate_english'); } /** diff --git a/core/modules/locale/locale.services.yml b/core/modules/locale/locale.services.yml index f632704..776cb3b 100644 --- a/core/modules/locale/locale.services.yml +++ b/core/modules/locale/locale.services.yml @@ -12,7 +12,7 @@ services: arguments: ['@database'] string_translator.locale.lookup: class: Drupal\locale\LocaleTranslation - arguments: ['@locale.storage', '@cache.cache', '@lock'] + arguments: ['@locale.storage', '@cache.cache', '@lock', '@config.factory'] tags: - { name: string_translator } - { name: needs_destruction }