nucleos / NucleosUserAdminBundle

👤 Adminstration of users and groups in symfony
https://docs.nucleos.rocks/projects/user-admin-bundle/
MIT License
4 stars 4 forks source link

[Translation] Wrong Sonata label_translator_strategy #412

Closed Hanmac closed 2 years ago

Hanmac commented 2 years ago

Environment

Packages

$ composer show --latest
# Put the result here.
composer/package-versions-deprecated     1.11.99.4 1.11.99.4 Composer plugin that provides efficient querying for installed package versions (no runtime IO)
doctrine/annotations                     1.13.2    1.13.2    Docblock Annotations Parser
doctrine/cache                           2.1.1     2.1.1     PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such ...
doctrine/collections                     1.6.8     1.6.8     PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                          3.2.0     3.2.0     PHP Doctrine Common project is a library that provides additional functionality that other Doctrine pro...
doctrine/dbal                            3.2.0     3.2.0     Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and...
doctrine/deprecations                    v0.5.3    v0.5.3    A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all d...
doctrine/doctrine-bundle                 2.5.1     2.5.1     Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle      3.2.1     3.2.1     Symfony DoctrineMigrationsBundle
doctrine/event-manager                   1.1.1     1.1.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doct...
doctrine/inflector                       2.0.4     2.0.4     PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lo...
doctrine/instantiator                    1.4.0     1.4.0     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                           1.2.1     1.2.1     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                      3.3.2     3.3.2     PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer...
doctrine/orm                             2.10.2    2.10.2    Object-Relational-Mapper for PHP
doctrine/persistence                     2.2.3     2.2.3     The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doc...
doctrine/sql-formatter                   1.1.2     1.1.2     a PHP SQL highlighting library
egulias/email-validator                  3.1.2     3.1.2     A library for validating emails against several RFCs
friendsofphp/proxy-manager-lts           v1.0.5    v1.0.5    Adding support for a wider range of PHP versions to ocramius/proxy-manager
friendsofsymfony/rest-bundle             3.1.1     3.1.1     This Bundle provides various tools to rapidly develop RESTful API's with Symfony
jms/metadata                             2.6.1     2.6.1     Class/method/property metadata management in PHP
jms/serializer                           3.16.0    3.16.0    Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
knplabs/knp-menu                         v3.3.0    v3.3.0    An object oriented menu library
knplabs/knp-menu-bundle                  v3.2.0    v3.2.0    This bundle provides an integration of the KnpMenu library
laminas/laminas-code                     4.4.3     4.4.3     Extensions to the PHP Reflection API, static code scanning, and code generation
league/csv                               9.7.4     9.7.4     CSV data manipulation made easy in PHP
moneyphp/money                           v3.3.1    v3.3.1    PHP implementation of Fowler's Money pattern
monolog/monolog                          1.26.1    2.3.5     Sends your logs to files, sockets, inboxes, databases and various web services
nikic/php-parser                         v4.13.1   v4.13.1   A PHP parser written in PHP
nucleos/user-admin-bundle                2.1.1     2.1.1     Adminstration of users and groups in symfony
nucleos/user-bundle                      1.12.0    1.12.0    Lightweight user management for symfony
oneup/uploader-bundle                    3.1.3     3.1.3     This Symfony bundle provides a server implementation for handling single and multiple file uploads usin...
phpdocumentor/reflection-common          2.2.0     2.2.0     Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock        5.3.0     5.3.0     With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve ...
phpdocumentor/type-resolver              1.5.1     1.5.1     A PSR-5 based resolver of Class names, Types and Structural Element Names
phpstan/phpdoc-parser                    1.2.0     1.2.0     PHPDoc parser with support for nullable, intersection and generic types
psr/cache                                1.0.1     1.0.1     Common interface for caching libraries
psr/container                            1.1.2     2.0.2     Common Container Interface (PHP FIG PSR-11)
psr/log                                  1.1.4     1.1.4     Common interface for logging libraries
sensio/framework-extra-bundle            v6.2.1    v6.2.1    This bundle provides a way to configure your controllers with annotations
sonata-project/admin-bundle              4.4.0     4.4.0     The missing Symfony Admin Generator
sonata-project/block-bundle              4.8.0     4.8.0     Symfony SonataBlockBundle
sonata-project/cache                     2.2.0     2.2.0     Cache library
sonata-project/doctrine-extensions       1.15.0    1.15.0    Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 4.2.1     4.2.1     Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  2.9.1     2.9.1     Lightweight Exporter library
sonata-project/form-extensions           1.12.3    1.12.3    Symfony form extensions
sonata-project/twig-extensions           1.9.0     1.9.0     Sonata twig extensions
symfony/asset                            v4.4.27   v5.4.0    Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image...
symfony/cache                            v4.4.35   v5.4.0    Provides an extended PSR-6, PSR-16 (and tags) implementation
symfony/cache-contracts                  v2.5.0    v2.5.0    Generic abstractions related to caching
symfony/config                           v4.4.34   v5.4.0    Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/console                          v4.4.34   v5.4.0    Eases the creation of beautiful and testable command line interfaces
symfony/debug                            v4.4.31   v4.4.31   Provides tools to ease debugging PHP code
symfony/dependency-injection             v4.4.34   v5.4.0    Allows you to standardize and centralize the way objects are constructed in your application
symfony/deprecation-contracts            v2.5.0    v2.5.0    A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge                  v4.4.34   v5.4.0    Provides integration for Doctrine with various Symfony components
symfony/dotenv                           v4.4.33   v5.4.0    Registers environment variables from a .env file
symfony/error-handler                    v4.4.34   v5.4.0    Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher                 v4.4.34   v5.4.0    Provides tools that allow your application components to communicate with each other by dispatching eve...
symfony/event-dispatcher-contracts       v1.1.11   v2.5.0    Generic abstractions related to dispatching event
symfony/expression-language              v4.4.34   v5.4.0    Provides an engine that can compile and evaluate expressions
symfony/filesystem                       v4.4.27   v5.4.0    Provides basic utilities for the filesystem
symfony/finder                           v4.4.30   v5.4.0    Finds files and directories via an intuitive fluent interface
symfony/flex                             v1.17.6   v1.17.6   Composer plugin for Symfony
symfony/form                             v4.4.34   v5.4.0    Allows to easily create, process and reuse HTML forms
symfony/framework-bundle                 v4.4.34   v5.4.0    Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/http-client-contracts            v2.5.0    v2.5.0    Generic abstractions related to HTTP clients
symfony/http-foundation                  v4.4.34   v5.4.0    Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                      v4.4.35   v5.4.0    Provides a structured process for converting a Request into a Response
symfony/inflector                        v4.4.34   v5.4.0    Converts words between their singular and plural forms (English only)
Package symfony/inflector is abandoned, you should avoid using it. Use use `EnglishInflector` from the String component instead instead.
symfony/intl                             v4.4.34   v5.4.0    Provides a PHP replacement layer for the C intl extension that includes additional data from the ICU li...
symfony/mailer                           v4.4.27   v5.4.0    Helps sending emails
symfony/maker-bundle                     v1.36.3   v1.36.3   Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can for...
symfony/mime                             v4.4.34   v5.4.0    Allows manipulating MIME messages
symfony/monolog-bridge                   v4.4.27   v5.4.0    Provides integration for Monolog with various Symfony components
symfony/monolog-bundle                   v3.7.1    v3.7.1    Symfony MonologBundle
symfony/options-resolver                 v4.4.30   v5.4.0    Provides an improved replacement for the array_replace PHP function
symfony/polyfill-intl-grapheme           v1.23.1   v1.23.1   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu                v1.23.0   v1.23.0   Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn                v1.23.0   v1.23.0   Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer         v1.23.0   v1.23.0   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring                v1.23.1   v1.23.1   Symfony polyfill for the Mbstring extension
symfony/polyfill-php72                   v1.23.0   v1.23.0   Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73                   v1.23.0   v1.23.0   Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80                   v1.23.1   v1.23.1   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81                   v1.23.0   v1.23.0   Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/property-access                  v4.4.30   v5.4.0    Provides functions to read and write from/to an object or array using a simple string notation
symfony/property-info                    v4.4.31   v5.4.0    Extracts information about PHP class' properties using metadata of popular sources
symfony/proxy-manager-bridge             v4.4.34   v5.4.0    Provides integration for ProxyManager with various Symfony components
symfony/routing                          v4.4.34   v5.4.0    Maps an HTTP request to a set of configuration variables
symfony/security-acl                     v3.2.0    v3.2.0    Symfony Security Component - ACL (Access Control List)
symfony/security-bundle                  v4.4.34   v5.4.0    Provides a tight integration of the Security component into the Symfony full-stack framework
symfony/security-core                    v4.4.34   v5.4.0    Symfony Security Component - Core Library
symfony/security-csrf                    v4.4.27   v5.4.0    Symfony Security Component - CSRF Library
symfony/security-guard                   v4.4.27   v5.4.0    Symfony Security Component - Guard
symfony/security-http                    v4.4.34   v5.4.0    Symfony Security Component - HTTP Integration
symfony/serializer                       v4.4.35   v5.4.0    Handles serializing and deserializing data structures, including object graphs, into array structures o...
symfony/service-contracts                v2.5.0    v2.5.0    Generic abstractions related to writing services
symfony/stopwatch                        v4.4.27   v5.4.0    Provides a way to profile code
symfony/string                           v5.4.0    v5.4.0    Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme cluster...
symfony/templating                       v4.4.30   v5.4.0    Provides all the tools needed to build any kind of template system
symfony/translation                      v4.4.34   v5.4.0    Provides tools to internationalize your application
symfony/translation-contracts            v2.5.0    v2.5.0    Generic abstractions related to translation
symfony/twig-bridge                      v4.4.34   v5.4.0    Provides integration for Twig with various Symfony components
symfony/twig-bundle                      v4.4.30   v5.4.0    Provides a tight integration of Twig into the Symfony full-stack framework
symfony/validator                        v4.4.35   v5.4.0    Provides tools to validate values
symfony/var-dumper                       v4.4.34   v5.4.0    Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter                     v4.4.34   v5.4.0    Allows exporting any serializable PHP data structure to plain PHP code
symfony/web-profiler-bundle              v4.4.31   v5.4.0    Provides a development tool that gives detailed information about the execution of any request
symfony/yaml                             v4.4.34   v5.4.0    Loads and dumps YAML files
twig/extra-bundle                        v3.3.4    v3.3.4    A Symfony bundle for extra Twig extensions
twig/intl-extra                          v3.3.4    v3.3.4    A Twig extension for Intl
twig/string-extra                        v3.3.4    v3.3.4    A Twig extension for Symfony String
twig/twig                                v3.3.4    v3.3.4    Twig, the flexible, fast, and secure template language for PHP
webmozart/assert                         1.10.0    1.10.0    Assertions to validate method input/output with nice error messages.
willdurand/jsonp-callback-validator      v1.1.0    v1.1.0    JSONP callback validator.
willdurand/negotiation                   3.0.0     3.0.0     Content Negotiation tools for PHP provided as a standalone library.

PHP version

$ php -v
# Put the result here.
PHP 7.4.21 (cli) (built: Jul  1 2021 19:26:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

Subject

Steps to reproduce

open Admin User Form

Expected results

Actual results

Nucleos UserAdmin Bundle uses this Stategy:

'label_translator_strategy' => 'sonata.admin.label.strategy.underscore',

But this causes the label form.group_general to be transformed into form.group_form_group_general and this causes the shipped Translations to fail.

Possible Solutions is:

core23 commented 2 years ago

The label change was introduced with sonata admin v4. The change was introduced 5 years(!) ago: https://github.com/sonata-project/SonataAdminBundle/pull/4028/files#diff-8d1178f0f37fbd2ac6511e658b40b274507b08416352e5d09da99826512c588fR74

IMHO we should keep the label strategy and change the label inside the translation files. Keep in mind that the stable release supports sonata admin v3 and v4.

E.g this line should be changed to general and the corresponding label would be show.group_general: https://github.com/nucleos/NucleosUserAdminBundle/blob/e2503629d63860cf7f60e7a276f17a4da838a153/src/Admin/Model/UserAdmin.php#L139

Hanmac commented 2 years ago

E.g this line should be changed to general and the corresponding label would be show.group_general:

https://github.com/nucleos/NucleosUserAdminBundle/blob/e2503629d63860cf7f60e7a276f17a4da838a153/src/Admin/Model/UserAdmin.php#L139

yeah i think this should be the preferred solution. So the Translations doesn't need to be touched