[英]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.