public static function ConfigurableLanguage::createFromLangcode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/language/src/Entity/ConfigurableLanguage.php \Drupal\language\Entity\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()
10 calls to ConfigurableLanguage::createFromLangcode()
- ContextualDynamicContextTest::testDifferentPermissions in core/
modules/ contextual/ src/ Tests/ ContextualDynamicContextTest.php - Tests contextual links with different permissions.
- 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.
- LanguageConfigurationTest::testLanguageConfiguration in core/
modules/ language/ src/ Tests/ LanguageConfigurationTest.php - Functional tests for adding, editing and deleting languages.
- LanguageFallbackTest::setUp in core/
modules/ language/ src/ Tests/ LanguageFallbackTest.php - Performs setup tasks before each individual test method is run.
File
- core/
modules/ language/ src/ Entity/ ConfigurableLanguage.php, line 249 - Contains \Drupal\language\Entity\ConfigurableLanguage.
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(array(
'id' => $langcode,
'label' => $langcode,
));
}
else {
// A known predefined language, details will be filled in properly.
return static::create(array(
'id' => $langcode,
'label' => $standard_languages[$langcode][0],
'direction' => isset($standard_languages[$langcode][2]) ? $standard_languages[$langcode][2] : static::DIRECTION_LTR,
));
}
}