You are here

public function ConfigNamesMapper::getLangcodeFromConfig in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config_translation/src/ConfigNamesMapper.php \Drupal\config_translation\ConfigNamesMapper::getLangcodeFromConfig()
  2. 10 core/modules/config_translation/src/ConfigNamesMapper.php \Drupal\config_translation\ConfigNamesMapper::getLangcodeFromConfig()

Returns the language code of a configuration object given its name.

Parameters

string $config_name: The name of the configuration object.

Return value

string The language code of the configuration object.

Overrides ConfigMapperInterface::getLangcodeFromConfig

File

core/modules/config_translation/src/ConfigNamesMapper.php, line 413

Class

ConfigNamesMapper
Configuration mapper base implementation.

Namespace

Drupal\config_translation

Code

public function getLangcodeFromConfig($config_name) {

  // Default to English if no language code was provided in the file.
  // Although it is a best practice to include a language code, if the
  // developer did not think about a multilingual use case, we fall back
  // on assuming the file is English.
  return $this->configFactory
    ->get($config_name)
    ->get('langcode') ?: 'en';
}