Symfony FOSUserBundle Translations aren't showing
Asked Answered
H

2

5

I enabled the Translator service in my config.yml, cleared cache and installed assets using the command line interface.

My login page still says "security.login.submit". I am using a custom template, which is located in: app/Resources/FOSUserBundle/views/Security/login.html.twig and contains (copied from the FOS provided template):

{{ 'security.login.submit'|trans }}

My config.yml:

framework:
    translator:      { fallback: "%locale%" }
    default_locale:  "%locale%"

parameters.yml:

parameters:
    locale: en
Honorific answered 11/1, 2014 at 23:17 Comment(0)
H
10

Is this your own copy of the login.html.twig?

If so have you included the trans_default_domain..

{% trans_default_domain 'FOSUserBundle' %}

If not the translator will be looking for translations in the default "messages" file.

Hogfish answered 11/1, 2014 at 23:23 Comment(3)
headdesk Thanks, that was it :) I'll accept in a few minutes.Honorific
It is also true that {% trans_default_domain 'FOSUserBundle' %} must be inside {% block fos_user_content %}, as determined by what happens when it is not.Spearhead
I'm not sure to be honest. I think it just applies to all translations in the template that it is set in (so any blocks but not require's) but I may be wrong. Even then I think the domain can be changed by using {{ 'security.login.submit'|trans({}, 'CUSTOM_DOMAIN | messages | validation | etc }}.Hogfish
C
1

My problem was that the cache was not cleared. To clear your cache:

rm -rf ./var/cache/*
Collector answered 12/5, 2019 at 6:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.