4
votes

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?

4
What is your accepted answer @dextervip ? - webDEVILopers

4 Answers

11
votes

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

2
votes

I had similar problem, solved it by setting default_locale.

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

0
votes

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 }
0
votes

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'
        ));
    }
}