[英]Translation label for Choice field are not working in Sonata Admin Datagrid filter
我在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'
我在属性管理列表中添加了两个自定义操作按钮。 我必须为app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff
这两个按钮添加两个翻译字符串action_rooms
和action_stations
,这些字符串是我从vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Resources/translations/SonataAdminBundle.en.xliff
。 他们工作正常。
问题是,尽管在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
为mybundle.admin.property
,但没有成功。
calls:
- [setTranslationDomain, ['MyBundle']]
它们在Sonata用户捆绑包生成的用户列表/admin/sonata/user/user/list
中也不起作用。 我注意到在创建app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff
之前,它app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff
。
我在config.yml和parameters.yml中启用了翻译器。
// config.yml
framework:
translator: { fallbacks: ["%locale%"] }
// parameters.yml
parameters:
// ..
locale: en
我通过添加/app/Resources/translations/messages.en.xliff
和以下内容来解决此问题:
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="filter.label_enabled">
<source>filter.label_enabled</source>
<target>Enabled</target>
</trans-unit>
<trans-unit id="label_type_yes">
<source>label_type_yes</source>
<target>Yes</target>
</trans-unit>
<trans-unit id="label_type_no">
<source>label_type_no</source>
<target>No</target>
</trans-unit>
</body>
</file>
</xliff>
与symfony文档中所说的一样 ,似乎覆盖了app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff
。
首先检查探查器所说的内容,在2.7中,您可以检查缺少的翻译。 只需检查缺少的翻译并将其放入app / Resources / translations / MyBundle.en.xliff
似乎这是最新Sonata中的错误,因为label_type_yes / label_type_no使用“邮件”域而不是SonataAdminBundle / SonataCoreBundle。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.