public function ContentEntityBase::getTranslationLanguages
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\EntityCode
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); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!ContentEntityBase.php/function/ContentEntityBase::getTranslationLanguages/8.1.x