Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set alias default translation strategy #3572

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function applyDefaults(ContainerBuilder $container, $serviceId, array $at
'menu_factory' => 'knp_menu.factory',
'route_builder' => 'sonata.admin.route.path_info'.
(($manager_type == 'doctrine_phpcr') ? '_slashes' : ''),
'label_translator_strategy' => 'sonata.admin.label.strategy.native',
'label_translator_strategy' => 'sonata.admin.label.strategy.default',
);

$definition->addMethodCall('setManagerType', array($manager_type));
Expand Down
3 changes: 2 additions & 1 deletion Resources/config/core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
<argument />
</service>

<!-- Services used to format the label, default is sonata.admin.label.strategy.noop -->
<!-- Services used to format the label, default is sonata.admin.label.strategy.native -->
<service id="sonata.admin.label.strategy.default" alias="sonata.admin.label.strategy.native" />
<service id="sonata.admin.label.strategy.bc" class="Sonata\AdminBundle\Translator\BCLabelTranslatorStrategy" />
<service id="sonata.admin.label.strategy.native" class="Sonata\AdminBundle\Translator\NativeLabelTranslatorStrategy" />
<service id="sonata.admin.label.strategy.noop" class="Sonata\AdminBundle\Translator\NoopLabelTranslatorStrategy" />
Expand Down
10 changes: 10 additions & 0 deletions Resources/doc/reference/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ apps based on the field name. It is reasonable to start with the ``native`` stra
and then, when the application needs to be translated using generic keys, the
configuration can be switched to ``underscore``.

You can replace default strategy in ``config.yml``:

.. configuration-block::

.. code-block:: yaml

services:
sonata.admin.label.strategy.default:
alias: sonata.admin.label.strategy.underscore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a warning that was mentioned by @greg0ire


The strategy can be quickly configured when the Admin class is registered in
the Container:

Expand Down