braincrafted / bootstrap-bundle

BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 by providing templates, Twig extensions, services and commands.
http://bootstrap.braincrafted.com
MIT License
399 stars 184 forks source link

Fix translator issues (warnings about missing translations) #435

Closed derpue closed 7 years ago

derpue commented 8 years ago

Sometimes you don't need translation, maybe you just pulled the menu-items dynamically out of the database. The Debug-Toolbar shows missing-translation errors for that entries. Also for developing single-language apps this helps to keep the warnings away. The easy way of just globally disabling the translation component won't work, as most of the time external bundles (as FOSUserBundle for example) rely on that translation service.

This PR provides the ability to disable the translation for each item individually for Menus, Forms and page-wise for Flash Messages.

Disabling Translation for Menu Items repects the documented way: http://symfony.com/doc/current/bundles/KnpMenuBundle/i18n.html

Disabling Translation for Forms is just adding 'translation_domain' => false to the form fields option

$builder->add('enabled', CheckboxType::class, array(
    'label' => 'The Label', 
    'required' => false, 
    'attr' => array('align_with_widget' => true),
    'translation_domain' => false
));

Disabling Translation for Flash Messages is just adding a parameter to the include: {% include 'BraincraftedBootstrapBundle::flash.html.twig' with { 'close': true, 'translation_domain': false } %}

florianeckerstorfer commented 8 years ago

Could you check the failing tests?

derpue commented 8 years ago

https://github.com/braincrafted/bootstrap-bundle/pull/436 should fix the failing tests.

They even failed with the unmodified develop branch under symfony 2.8

florianeckerstorfer commented 8 years ago

Got it, I restarted the tests.