Reputation: 594
This is my 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
This is the annotation part of my entity that needs translation:
/**
* @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)
*/
This is the annotation part of the translation entity
/**
* @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")
*/
But when I do:
$category->getTitle()
I always the english (non-translated) value, even when my locale is different.
Someone has an idea what I'm doing wrong?
Or am I missing a crucial part of info/code in my question?
PS: I'm using symfony 2.8
Upvotes: 1
Views: 1435
Reputation: 5877
you need to activate it in your config.yml:
stof_doctrine_extensions:
default_locale: "%locale%"
translation_fallback: false
orm:
default:
translatable: true
Upvotes: 2