1. Go to this page and download the library: Download umanit/translation-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
umanit / translation-bundle example snippets
new Umanit\TranslationBundle\UmanitTranslationBundle(),
namespace App\Entity\Content;
use Doctrine\ORM\Mapping as ORM;
use Umanit\TranslationBundle\Doctrine\Model\TranslatableInterface;
use Umanit\TranslationBundle\Doctrine\Model\TranslatableTrait;
/**
* HomePage
*
* @ORM\Table(name="page")
*/
class Page implements TranslatableInterface
{
use TranslatableTrait;
}
namespace App\Entity\Content;
use Doctrine\ORM\Mapping as ORM;
use Umanit\TranslationBundle\Doctrine\Model\TranslatableInterface;
use Umanit\TranslationBundle\Doctrine\Model\TranslatableTrait;
use Umanit\TranslationBundle\Doctrine\Attribute\SharedAmongstTranslations;
#[ORM\Table(name: "page")]
class Page implements TranslatableInterface
{
use TranslatableTrait;
#[ORM\ManyToOne(targetEntity: "Application\Sonata\MediaBundle\Entity\Media", cascade: {"persist"})]
#[ORM\JoinColumn(name: "video_id", referencedColumnName: "id")]
#[SharedAmongstTranslations]
protected Application\Sonata\MediaBundle\Entity\Media $video;
}
namespace App\Entity\Content;
use Doctrine\ORM\Mapping as ORM;
use Umanit\TranslationBundle\Doctrine\Model\TranslatableInterface;
use Umanit\TranslationBundle\Doctrine\Model\TranslatableTrait;
use Umanit\TranslationBundle\Doctrine\Attribute\EmptyOnTranslate;
#[ORM\Table(name: "page")]
class Page implements TranslatableInterface
{
use TranslatableTrait;
// ...
#[ORM\ManyToOne(targetEntity: "Application\Sonata\MediaBundle\Entity\Media", cascade: {"persist"})]
#[ORM\JoinColumn(name: "image_id", referencedColumnName: "id")]
#[EmptyOnTranslate]
protected Application\Sonata\MediaBundle\Entity\Media $image;
}