4

I am setting up FOSUserBundle dev-master with Symfony 2.3 RC1 but translation is not working well. It comes by default with trans_default_domain in the templates

In the login template. It doesn't with trans_default_domain

{% trans_default_domain "FOSUserBundle" %}
<label class="control-label" for="username">{{ 'security.login.username'|trans }}</label>

but using trans({}, 'FOSUserBundle') It works

<label class="control-label" for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>

What's wrong with trans_default_domain? need any extra config?

dextervip
  • 4,999
  • 16
  • 65
  • 93

4 Answers4

11

Try to enable the symfony translation component. By default it is commented out:

# app/config/config.yml
framework:
    translator: { fallback: en }

http://symfony.com/doc/current/book/translation.html#configuration

Aris
  • 4,643
  • 1
  • 41
  • 38
2

I had similar problem, solved it by setting default_locale.

http://symfony.com/doc/2.7/translation/locale.html

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
iLoveUnicorns
  • 590
  • 4
  • 8
0

i'm not sure, but maybe this helps:

in config.yml under services :

services:
    twig.extension.intl: 
        class: Twig_Extensions_Extension_Intl 
        tags: 
                - { name: twig.extension }
parisssss
  • 803
  • 16
  • 36
0

I haven't had much luck with trans_default_domain. Instead, I pass the translation_domain value directly via the form options:

class MyLoginType extends AbstractType
{
    ...

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'translation_domain'  => 'FOSUserBundle'
        ));
    }
}