diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index ac975d1..d0b6b4c 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -315,7 +315,9 @@ protected function getTranslatedField($property_name, $langcode) { $value = $this->values[$property_name][$default_langcode]; } } - $this->fields[$property_name][$langcode] = \Drupal::typedData()->getPropertyInstance($this, $property_name, $value); + $field = \Drupal::typedData()->getPropertyInstance($this, $property_name, $value); + $field->setLangcode($langcode); + $this->fields[$property_name][$langcode] = $field; } } return $this->fields[$property_name][$langcode]; diff --git a/core/lib/Drupal/Core/Entity/Field/Field.php b/core/lib/Drupal/Core/Entity/Field/Field.php index 7cf493c..63ec28f 100644 --- a/core/lib/Drupal/Core/Entity/Field/Field.php +++ b/core/lib/Drupal/Core/Entity/Field/Field.php @@ -11,6 +11,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Core\TypedData\ItemList; +use Drupal\Core\Language\Language; /** * Represents an entity field; that is, a list of field item objects. @@ -36,6 +37,8 @@ class Field extends ItemList implements FieldInterface { */ protected $list = array(); + protected $langcode = Language::LANGCODE_DEFAULT; + /** * Overrides TypedData::__construct(). */ @@ -48,6 +51,14 @@ public function __construct(array $definition, $name = NULL, TypedDataInterface $this->list[0] = $this->createItem(0); } + public function setLangcode($langcode) { + $this->langcode = $langcode; + } + + public function getLangcode() { + return $this->langcode; + } + /** * {@inheritdoc} */ diff --git a/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php index c021c57..a8388e7 100644 --- a/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php @@ -36,6 +36,10 @@ public function __construct(array $definition, $name = NULL, TypedDataInterface } } + public function getLangcode() { + return $this->parent->getLangcode(); + } + /** * {@inheritdoc} */