我有一个已使用翻译的教义实体可翻译学说的扩展:
<?php
namespace Myapp\ProductBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
/**
* @ORM\Table(name="product_property")
* @ORM\Entity()
* @Gedmo\TranslationEntity()
*/
class Property implements Translatable
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Gedmo\Translatable
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(
* targetEntity="PropertyTranslation",
* mappedBy="object",
* cascade={"persist", "remove"}
* )
*/
private $translations;
/**
* @Gedmo\Locale
* Used locale to override Translation listener`s locale
* this is not a mapped field of entity metadata, just a simple property
*/
private $locale;
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
public function getTranslations()
{
return $this->translations;
}
public function addTranslation(PropertyTranslation $t)
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
}
}
现在,我想以我的翻译中可用的每种语言呈现一个带有“名称”属性输入字段的表单。
怎样做最好呢?
看来以下捆绑包能够完全满足我的要求:https://github.com/a2lix/TranslationFormBundle
![enter image description here](https://i.stack.imgur.com/jZQMv.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)