这是我的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
答案 0 :(得分:1)
您需要在config.yml中激活它:
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:@"Choose From" preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// Cancel button tappped.
[self dismissViewControllerAnimated:YES completion:^{
}];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:@"Gallery" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
UIImagePickerController *imgpicker = [[UIImagePickerController alloc] init];
imgpicker.allowsEditing = YES;
imgpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imgpicker.delegate=(id)self;
[self presentViewController:imgpicker animated:YES completion:nil];
}]];