public static ConfigurableLanguage::createFromLangcode($langcode)
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()
File
- core/modules/language/src/Entity/ConfigurableLanguage.php, line 244
Class
- ConfigurableLanguage
- Defines the ConfigurableLanguage entity.
Namespace
Drupal\language\Entity
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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, )); } } |
Please login to continue.