You are here

public function LocaleConfigManager::getDefaultConfigLangcode in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/src/LocaleConfigManager.php \Drupal\locale\LocaleConfigManager::getDefaultConfigLangcode()
  2. 9 core/modules/locale/src/LocaleConfigManager.php \Drupal\locale\LocaleConfigManager::getDefaultConfigLangcode()

Returns the original language code for this shipped configuration.

Parameters

string $name: The configuration name.

Return value

null|string Language code of the default configuration for $name. If the default configuration data for $name did not contain a language code, it is assumed to be English. The return value is NULL if no such default configuration exists.

File

core/modules/locale/src/LocaleConfigManager.php, line 484

Class

LocaleConfigManager
Manages configuration supported in part by interface translation.

Namespace

Drupal\locale

Code

public function getDefaultConfigLangcode($name) {

  // Config entities that do not have the 'default_config_hash' cannot be
  // shipped configuration regardless of whether there is a name match.
  // configurable_language entities are a special case since they can be
  // translated regardless of whether they are shipped if they in the standard
  // language list.
  $config_entity_type = $this->configManager
    ->getEntityTypeIdByName($name);
  if (!$config_entity_type || $config_entity_type === 'configurable_language' || !empty($this->configFactory
    ->get($name)
    ->get('_core.default_config_hash'))) {
    $shipped = $this->defaultConfigStorage
      ->read($name);
    if (!empty($shipped)) {
      return !empty($shipped['langcode']) ? $shipped['langcode'] : 'en';
    }
  }
  return NULL;
}