function ConfigurableLanguage::createFromLangcode
Creates a configurable language object from a langcode.
Parameters
string $langcode: The language code to use to create the object.
Return value
$this
See also
\Drupal\Core\Language\LanguageManager::getStandardLanguageList()
2 calls to ConfigurableLanguage::createFromLangcode()
- ImportForm::submitForm in core/
modules/ locale/ src/ Form/ ImportForm.php - Form submission handler.
- install_download_additional_translations_operations in core/
includes/ install.core.inc - Prepares the system for import and downloads additional translations.
File
-
core/
modules/ language/ src/ Entity/ ConfigurableLanguage.php, line 280
Class
- ConfigurableLanguage
- Defines the ConfigurableLanguage entity.
Namespace
Drupal\language\EntityCode
public static function createFromLangcode($langcode) {
$standard_languages = LanguageManager::getStandardLanguageList();
if (!isset($standard_languages[$langcode])) {
// Drupal does not know about this language, so we set its values with the
// best guess. The user will be able to edit afterwards.
return static::create([
'id' => $langcode,
'label' => $langcode,
]);
}
else {
// A known predefined language, details will be filled in properly.
return static::create([
'id' => $langcode,
'label' => $standard_languages[$langcode][0],
'direction' => $standard_languages[$langcode][2] ?? static::DIRECTION_LTR,
]);
}
}