Closed bettinz closed 4 years ago
Hello, I'm doing something like that: Entity\Category
Entity\Category
private $id;
Entity\CategoryTranslation
private $name;
$category = new Category; $category->translate('en')->setName('nameEn'); $category->translate('es')->setName('nameEs'); $category->mergeNewTranslations(); $this->entityManager->persist($category); $category->mergeNewTranslations(); $this->entityManager->flush(); $alreadyCreatedCategory = $this->entityManager->getRepository('App\Entity\CategoryTranslation')->findOneBy([ 'name' => 'nameEn', 'locale' => 'en', ]); $category2 = $alreadyCreatedCategory->getTranslatable(); $category2->translate('it')->setName('nameIt'); $this->entityManager->persist($category2); $category2->mergeNewTranslations(); $this->entityManager->flush();
I was hoping that the new translation will be added to the category but it doesn't work. Instead, it replace the name without updating the locale. Am I doing something wrong? Thanks
Hi, I had the same problem and I added this $category2->translate('it', false)->setName('nameIt');
$category2->translate('it', false)->setName('nameIt');
By doing this the translate method does not use the fallback.
THANK YOU @tpatartmajeur 🙏
Hello, I'm doing something like that:
Entity\Category
Entity\CategoryTranslation
I was hoping that the new translation will be added to the category but it doesn't work. Instead, it replace the name without updating the locale. Am I doing something wrong? Thanks