【发布时间】:2018-02-22 17:15:13
【问题描述】:
这是我的 config.yml:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
gedmo_translatable:
type: annotation
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity/MappedSuperclass"
alias: GedmoTranslatable
is_bundle: false
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
product_category_filter:
class: AppBundle\Bundle\CoreBundle\Doctrine\Filter\CategoryFilter
enabled: false
这是我需要翻译的实体的注释部分:
/**
* @Gedmo\TranslationEntity(class="AppBundle\Bundle\CoreBundle\Entity\Translation\ProductCategory")
* @ORM\Entity(repositoryClass="AppBundle\Bundle\CoreBundle\Entity\Repository\ProductCategoryRepository")
* @ORM\Table(name="product_categories")
* @Serializer\ExclusionPolicy("none")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
这是翻译实体的注解部分
/**
* @ORM\Table(name="product_category_translations", indexes={
* @ORM\Index(name="product_category_translation_idx", columns={"locale", "object_class", "field", "foreign_key"})
* })
* @ORM\Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository")
*/
但是当我这样做时:
$category->getTitle()
我总是使用英语(非翻译)值,即使我的语言环境不同。
有人知道我做错了什么?
或者我是否在我的问题中遗漏了信息/代码的关键部分?
PS:我使用的是 symfony 2.8
【问题讨论】:
标签: php symfony translation