Php Symfony gedmo可翻译文件不工作
这是我的config.yml:Php Symfony gedmo可翻译文件不工作,php,symfony,translation,Php,Symfony,Translation,这是我的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: Gedm
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
stof_doctrine_extensions:
default_locale: "%locale%"
translation_fallback: false
orm:
default:
translatable: true
这是需要转换的实体的注释部分:
/**
* @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()
我总是使用英语(非翻译)值,即使我的语言环境不同
有人知道我做错了什么
还是我的问题中遗漏了信息/代码的关键部分
注:我正在使用symfony 2.8,您需要在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
stof_doctrine_extensions:
default_locale: "%locale%"
translation_fallback: false
orm:
default:
translatable: true