diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 167c4d3..5056328 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -25,7 +25,9 @@ use Drupal\language\ConfigurableLanguageInterface; use Drupal\Component\Utility\Crypt; use Drupal\locale\Locale; +use Drupal\locale\LocaleEvent; use Drupal\locale\LocaleEvents; +use Symfony\Component\EventDispatcher\Event; /** * Regular expression pattern used to localize JavaScript strings. @@ -1054,11 +1056,9 @@ function _locale_refresh_translations($langcodes, $lids = array()) { array_map('_locale_invalidate_js', $langcodes); } } - // Clear locale cache. - Cache::invalidateTags(array('locale')); // Throw locale.save_translation event. - \Drupal::service('event_dispatcher')->dispatch(LocaleEvents::SAVE_TRANSLATION); + \Drupal::service('event_dispatcher')->dispatch(LocaleEvents::SAVE_TRANSLATION, new LocaleEvent($langcodes, $lids)); } /** diff --git a/core/modules/locale/src/EventSubscriber/LocaleTranslationCacheTag.php b/core/modules/locale/src/EventSubscriber/LocaleTranslationCacheTag.php index 52a16c6..e7a8057 100644 --- a/core/modules/locale/src/EventSubscriber/LocaleTranslationCacheTag.php +++ b/core/modules/locale/src/EventSubscriber/LocaleTranslationCacheTag.php @@ -12,7 +12,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * A subscriber invalidating the 'rendered' cache tag when translating a string. + * A subscriber invalidating cache tags when translating a string. */ class LocaleTranslationCacheTag implements EventSubscriberInterface { @@ -34,10 +34,10 @@ public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidato } /** - * Invalidate the 'rendered' cache tag whenever a string is translated. + * Invalidate cache tags whenever a string is translated. */ public function saveTranslation() { - $this->cacheTagsInvalidator->invalidateTags(['rendered']); + $this->cacheTagsInvalidator->invalidateTags(['rendered', 'locale']); } /** diff --git a/core/modules/locale/src/LocaleEvent.php b/core/modules/locale/src/LocaleEvent.php new file mode 100644 index 0000000..6292985 --- /dev/null +++ b/core/modules/locale/src/LocaleEvent.php @@ -0,0 +1,62 @@ +langCodes = $langCodes; + $this->lids = $lids; + } + + /** + * The language codes. + * + * @return array $langCodes + */ + public function getLangCodes() { + return $this->langCodes; + } + + /** + * The string identifiers. + * + * @return array $lids + */ + public function getLids() { + return $this->lids; + } + +}