我在 Symfony 2.7 应用程序中使用 Sonata Admin Bundle 和 Sonata User Bundle。我有一个物业管理页面。这是我的 services.yml 中的配置:
// ...
mybundle.admin.property:
class: MyBundle\Admin\PropertyAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: Property, label: Properties }
arguments:
- ~
- MyBundle\Entity\Property
- 'MyBundle:PropertyAdmin'
我在属性管理列表中添加了两个自定义操作按钮。我必须添加两个翻译字符串action_rooms
以及我从中复制action_stations
的两个按钮。他们工作正常。app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff
vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Resources/translations/SonataAdminBundle.en.xliff
问题是 datagrid 过滤器中的label_type_yes
和的翻译label_type_no
不起作用,尽管它们是在SonataAdminBundle.en.xliff
. 这是属性列表的屏幕截图。
我app/Resources/translations/MyBundle.en.xliff
用 的内容创建SonataAdminBundle.en.xliff
并添加setTranslationDomain
了services.yml
for mybundle.admin.property
,但没有成功。
calls:
- [setTranslationDomain, ['MyBundle']]
他们不在/admin/sonata/user/user/list
Sonata User Bundle 生成的用户列表中工作。我注意到在我创建app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff
.
我在 config.yml 和 parameters.yml 中启用了翻译器。
// config.yml
framework:
translator: { fallbacks: ["%locale%"] }
// parameters.yml
parameters:
// ..
locale: en