Sonataadminbundle: Translations in sidebar fail since 3.22.0

Created on 13 Sep 2017  路  4Comments  路  Source: sonata-project/SonataAdminBundle

Environment

Sonata 3.22.0 (after upgrading from 3.20.1)

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.22.0                                   3.23.0                                The missing Symfony Admin Generator
sonata-project/block-bundle              3.3.2                                    3.3.2                                 Symfony SonataBlockBundle
sonata-project/cache                     1.0.7                                    1.0.7                                 Cache library
sonata-project/core-bundle               3.4.0                                    3.4.0                                 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.2.1                                    2.2.1                                 Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2                                    1.0.2                                 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.1.6                                    3.1.6                                 Symfony Sonata / Integrate Doctrine ORM into the SonataA...
sonata-project/easy-extends-bundle       2.2.0                                    2.2.0                                 Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.7.1                                    1.7.1                                 Lightweight Exporter library
sonata-project/google-authenticator      1.1.0                                    2.0.0                                 Library to integrate Google Authenticator into a PHP pro...
sonata-project/user-bundle               dev-add_support_for_fos_user2 fb0c8db8f6 dev-add_support_for_fos_user2 99be909 Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v3.1.0  v3.1.0 Symfony MonologBundle
symfony/phpunit-bridge     v3.3.8  v3.3.9 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.5.0  v1.5.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.5.0  v1.5.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.5.0  v1.5.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.5.0  v1.5.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.5.0  v1.5.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.5.0  v1.5.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.0  v3.0.0 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.3  v3.0.4 Symfony SwiftmailerBundle
symfony/symfony            v3.2.13 v3.3.9 The Symfony PHP framework

Subject

Commit c303dbece3ba3c935de7ae7c8d0f22b7ee30913f has broken the admin name translations in the sidebar.

Steps to reproduce

Add an admin panel by registering it like so:

    app.admin.some_admin:
        class: AppBundle\Admin\SomeAdmin
        arguments: [~, AppBundle\EntitySomeEntity, ~]
        tags:
            - {
                  name: sonata.admin,
                  manager_type: orm,
                  group: menu.my_group,
                  label: admin.menu.someadmin,
                  label_catalogue: 'SonataAdmin',
                  label_translator_strategy: sonata.admin.label.strategy.underscore
              }

The AppBundle\Admin\SomeAdmin class has a translation domain set up in the code:

namespace AppBundle\Admin;

class SomeAdmin extends AbstractSortableAdmin
{

    protected $translationDomain = 'SonataSomeAdmin';

   // ...

}

Translation files are in place for the SonataAdmin domain and SonataSomeAdmin domain:

# SonataAdmin.en.yml
menu.my_group: My menu group

# SonataSomeAdmin.en.yml
admin.menu.someadmin: My admin panel

Expected results

The admin panel shows up in the sidebar in the group "My menu group" with the label "My admin panel". It also shows up in the default dashboard block on the Sonata home page, next to the sidebar. Finally, it also shows up under the '+' icon on the top right side of the screen.

Actual results

It shows up fully translated on both the block on Sonata's home screen and under the '+' menu on the top right. In the sidebar, the group names get translated, but the admin panel's label isn't (Shows up as admin.menu.someadmin)

It looks for the translation in the messages domain.

schermafbeelding 2017-09-13 om 10 51 29

bug

All 4 comments

I've been digging around, and what fixes it for me right now is changing label_catalogue in sonata_menu.html.twig on line 28 to translation_domain. Not sure whether it's the actual fix for the issue, or just a workaround for a bug that was introduced by the aforementioned commit.

Can you please upgrade to 3.23.0, the issue should be fixed

Hi @OskarStark, sorry, I was under the impression 3.23.0 wasn't released yet. I've upgraded and it seems to be working as expected again!

Thanks for your feedback!

Was this page helpful?
0 / 5 - 0 ratings