public EntityRepositoryInterface::getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array())
Gets the entity translation to be used in the given context.
This will check whether a translation for the desired language is available and if not, it will fall back to the most appropriate translation based on the provided context.
\Drupal\Core\Entity\EntityInterface $entity: The entity whose translation will be returned.
string $langcode: (optional) The language of the current context. Defaults to the current content language.
array $context: (optional) An associative array of arbitrary data that can be useful to determine the proper fallback sequence.
\Drupal\Core\Entity\EntityInterface An entity object for the translated data.
\Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates()
public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array());
© 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!EntityRepositoryInterface.php/function/EntityRepositoryInterface::getTranslationFromContext/8.1.x