- Issue created by @tedbow
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Blocked on π Allow Experience Builder fields to support Asymmetric and Symmetric translations Needs review .
- Status changed to Postponed
5 months ago 4:17pm 20 June 2024 - πΊπΈUnited States tedbow Ithaca, NY, USA
Ok I think figure out why this happens.
\Drupal\Core\Entity\ContentEntityBase::get()
calls\Drupal\Core\Entity\ContentEntityBase::getTranslatedField
-
getTranslatedField has
if (!$default && !$definition->isTranslatable()) { if (!isset($this->fields[$name][LanguageInterface::LANGCODE_DEFAULT])) { $this->fields[$name][LanguageInterface::LANGCODE_DEFAULT] = $this->getTranslatedField($name, LanguageInterface::LANGCODE_DEFAULT); } $this->fields[$name][$langcode] = &$this->fields[$name][LanguageInterface::LANGCODE_DEFAULT]; } else {
So in the case the XB field is not translated it do a recursive call to
getTranslatedField()
but his time usingLanguageInterface::LANGCODE_DEFAULT
- In the recursive call to
getTranslatedField()
then this is called
$field = \Drupal::service('plugin.manager.field.field_type')->createFieldItemList($this->getTranslation($langcode), $name, $value);
So
$this->getTranslation($langcode)
means the field item list will be created with the default,LanguageInterface::LANGCODE_DEFAULT
translation, even though the entity that had the original call to\Drupal\Core\Entity\ContentEntityBase::get()
in step above could have been the translation of another language.
I am not sure why this happens but it seems very intentional. Will investigate further.
- πΊπΈUnited States tedbow Ithaca, NY, USA
Ok, this change was made in #2513094: ContentEntityBase::getTranslatedField and ContentEntityBase::__clone break field reference to parent entity β
$field = \Drupal::service('plugin.manager.field.field_type')->createFieldItemList($this, $name, $value);
was changed to
$field = \Drupal::service('plugin.manager.field.field_type')->createFieldItemList($this->getTranslation($langcode), $name, $value);
I will read up that issue. But presumably there was a good reason to need the translation instead of the original entity object.
- πΊπΈUnited States tedbow Ithaca, NY, USA
I think I have found a solution in π Allow Experience Builder fields to support Asymmetric and Symmetric translations Needs review . If that solution does not work we can re-open this
- Status changed to Closed: outdated
5 months ago 12:06pm 24 June 2024