/** * Update a content translation. * * @param Content $content A content entity * @param array $translation array('content' => 'foo', 'title' => 'foo') * @param string $locale A string with a locale value as 'en' or 'fr' * @param bool $reset A boolean in case of you whant to reset the values of the translation */ private function updateTranslation(Content $content, $translation, $locale = 'en', $reset = false) { if (isset($translation['title'])) { $content->setTitle($reset ? null : $translation['title']); } if (isset($translation['content'])) { $content->setContent($reset ? null : $translation['content']); } $content->setTranslatableLocale($locale); $content->setModified(); $this->manager->persist($content); $this->manager->flush(); }