class LocaleConfigSubscriber

Locale Config helper

$config is always a DrupalConfig object.

Hierarchy

Expanded class hierarchy of LocaleConfigSubscriber

1 file declares its use of LocaleConfigSubscriber
locale.module in drupal/core/modules/locale/locale.module
Enables the translation of the user interface to languages other than English.

File

drupal/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php, line 20
Definition of Drupal\locale\LocaleConfigSubscriber.

Namespace

Drupal\locale
View source
class LocaleConfigSubscriber implements EventSubscriberInterface {

  /**
   * Override configuration values with localized data.
   *
   * @param Drupal\Core\Config\ConfigEvent $event
   *   The Event to process.
   */
  public function configLoad(ConfigEvent $event) {
    $config = $event
      ->getConfig();
    $language = language(LANGUAGE_TYPE_INTERFACE);
    $locale_name = $this
      ->getLocaleConfigName($config
      ->getName(), $language);
    if ($override = $config
      ->getStorage()
      ->read($locale_name)) {
      $config
        ->setOverride($override);
    }
  }

  /**
   * Get configuration name for this language.
   *
   * It will be the same name with a prefix depending on language code:
   * locale.config.LANGCODE.NAME
   */
  public function getLocaleConfigName($name, $language) {
    return 'locale.config.' . $language->langcode . '.' . $name;
  }

  /**
   * Implements EventSubscriberInterface::getSubscribedEvents().
   */
  static function getSubscribedEvents() {
    $events['config.load'][] = array(
      'configLoad',
      20,
    );
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LocaleConfigSubscriber::configLoad public function Override configuration values with localized data.
LocaleConfigSubscriber::getLocaleConfigName public function Get configuration name for this language.
LocaleConfigSubscriber::getSubscribedEvents static function Implements EventSubscriberInterface::getSubscribedEvents(). Overrides EventSubscriberInterface::getSubscribedEvents