1

我在 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.xliffvendor/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并添加setTranslationDomainservices.ymlfor mybundle.admin.property,但没有成功。

    calls:
        - [setTranslationDomain, ['MyBundle']]

他们不在/admin/sonata/user/user/listSonata User Bundle 生成的用户列表中工作。我注意到在我创建app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff.

在此处输入图像描述

我在 config.yml 和 parameters.yml 中启用了翻译器。

// config.yml
framework:
    translator:      { fallbacks: ["%locale%"] }

// parameters.yml
parameters:
    // ..
    locale: en
4

3 回答 3

1

我通过添加/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>

app/Resource/SonataAdminBundle/translations/SonataAdminBundle.en.xliff 与 symfony 文档中所说的不同,它似乎是压倒一切的。

于 2015-06-23T16:09:59.397 回答
0

首先检查分析器所说的内容,在 2.7 中,您可以检查丢失的翻译。只需检查缺少哪些翻译并将其放入 app/Resources/translations/MyBundle.en.xliff

于 2015-06-21T19:48:20.233 回答
0

似乎这是最新奏鸣曲中的错误,因为 label_type_yes/label_type_no 使用“消息”域而不是 SonataAdminBundle/SonataCoreBundle。

于 2015-07-16T18:26:07.400 回答