簡體   English   中英

選擇字段的翻譯標簽在Sonata Admin Datagrid過濾器中不起作用

[英]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_roomsaction_stations ,這些字符串是我從vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Resources/translations/SonataAdminBundle.en.xliff 他們工作正常。

問題是,盡管在SonataAdminBundle.en.xliff中定義了datagrid過濾器中的label_type_yeslabel_type_no轉換SonataAdminBundle.en.xliff 這是屬性列表的屏幕截圖。

在此處輸入圖片說明

我創建app/Resources/translations/MyBundle.en.xliff與內容SonataAdminBundle.en.xliff和我說setTranslationDomainservices.ymlmybundle.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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM