public ContentEntityBase::getTranslationLanguages($include_default = TRUE)
Returns the languages the data is translated to.
Parameters
bool $include_default: (optional) Whether the default language should be included. Defaults to TRUE.
Return value
\Drupal\Core\Language\LanguageInterface[] An associative array of language objects, keyed by language codes.
Overrides TranslatableInterface::getTranslationLanguages
File
- core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 857
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\Entity
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 | public function getTranslationLanguages( $include_default = TRUE) { $translations = array_filter ( $this ->translations, function ( $translation ) { return $translation [ 'status' ]; }); unset( $translations [LanguageInterface::LANGCODE_DEFAULT]); if ( $include_default ) { $translations [ $this ->defaultLangcode] = TRUE; } // Now load language objects based upon translation langcodes. return array_intersect_key ( $this ->getLanguages(), $translations ); } |
Please login to continue.