function ConfigNamesMapper::getLangcodeFromConfig

Same name 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()
  3. 11.x core/modules/config_translation/src/ConfigNamesMapper.php \Drupal\config_translation\ConfigNamesMapper::getLangcodeFromConfig()

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';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.