-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Steps to reproduce
- Create a Contentful Space with 2 locales: English (default) and Italian;
- Create an Entry Model "Blog Post" with a Body field of type Rich Text;
- Create a "Blog Post" Entry with an Image in the Body field, the same image for the English and Italian Body fields;
- The Image Asset has both title and description filled in both languages;
- Try to render the Blog Post Entry in the not default language (Italian)
Expected Result
The title of the image present in the Body of the Blog Post should be in Italian
Actual Result
The title of the image present in the Body of the Blog Post is in English
Considerations
Take a look to this issue patched on contentful/rich-text.php repository. You can patch this module like this:
diff --git a/src/Mapper/Entry.php b/src/Mapper/Entry.php
index d539fe4..9018a7e 100644
--- a/src/Mapper/Entry.php
+++ b/src/Mapper/Entry.php
@@ -98,7 +98,8 @@ class Entry extends BaseTaggedMapper
$fields[$name][$locale] = $this->formatValue(
$field->getType(),
$value,
- $field->getItemsType()
+ $field->getItemsType(),
+ $locale
);
}
}
@@ -146,7 +147,7 @@ class Entry extends BaseTaggedMapper
*
* @return mixed
*/
- private function formatValue(string $type, $value, string $itemsType = null)
+ private function formatValue(string $type, $value, string $itemsType = null, string $locale = null)
{
// Certain fields are already built as objects (Location, Link, DateTimeImmutable)
// if the entry has already been built partially.
@@ -161,8 +162,8 @@ class Entry extends BaseTaggedMapper
switch ($type) {
case 'Array':
- return array_map(function ($value) use ($itemsType) {
- return $this->formatValue((string) $itemsType, $value);
+ return array_map(function ($value) use ($itemsType, $locale) {
+ return $this->formatValue((string) $itemsType, $value, $locale);
}, $value);
case 'Date':
return new DateTimeImmutable($value, new \DateTimeZone('UTC'));
@@ -171,7 +172,7 @@ class Entry extends BaseTaggedMapper
case 'Location':
return new Location($value['lat'], $value['lon']);
case 'RichText':
- return $this->richTextParser->parse($value);
+ return $this->richTextParser->parseLocalized($value, $locale);
default:
return $value;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels