Esempio n. 1
0
 /**
  * Updates the locale strings when a configuration override is saved/deleted.
  *
  * @param \Drupal\language\Config\LanguageConfigOverrideCrudEvent $event
  *   The language configuration event.
  */
 public function onOverrideChange(LanguageConfigOverrideCrudEvent $event)
 {
     // Only attempt to feed back configuration override changes to locale if
     // the update itself was not initiated by locale data changes.
     if (!drupal_installation_attempted() && !$this->localeConfigManager->isUpdatingTranslationsFromLocale()) {
         $translation_config = $event->getLanguageConfigOverride();
         $langcode = $translation_config->getLangcode();
         $reference_config = $this->configFactory->getEditable($translation_config->getName())->get();
         $this->updateLocaleStorage($translation_config, $langcode, $reference_config);
     }
 }
 /**
  * Updates the translation strings of shipped configuration.
  *
  * @param \Drupal\language\Config\LanguageConfigOverrideCrudEvent $event
  *   The language configuration event.
  * @param $callable
  *   A callable to apply to each translatable string of the configuration.
  */
 protected function updateTranslationStrings(LanguageConfigOverrideCrudEvent $event, $callable)
 {
     $translation_config = $event->getLanguageConfigOverride();
     $name = $translation_config->getName();
     // Only do anything if the configuration was shipped.
     if ($this->stringStorage->getLocations(['type' => 'configuration', 'name' => $name])) {
         $source_config = $this->configFactory->getEditable($name);
         $schema = $this->localeConfigManager->get($name)->getTypedConfig();
         $this->traverseSchema($schema, $source_config, $translation_config, $callable);
     }
 }