Symfony2 - How to translate "Bad credentials" login error message from FOSUserBundle ?

fosuserbundle, symfony

Solution

The problem is that error message has dot(.) at the end of the string.

You can correct this using the twig trim filter:

{{ error|trim('.')|trans({}, 'FOSUserBundle') }}

Problem

I'd like to customize the error message ('Bad credentials')if a there is a login error. I do it but doesn't work. This is the template login : ``` {% if error %} <div>{{ error.message|trans }}</div> {% endif %}<form action="{{ path('login_check') }}" method="post"> <label for="username">Username:</label> <input type="text" id="username" name="_username" value="{{ last_username }}" /> <label for="password">Password:</label> <input type="password" id="password" name="_password" /> <input type="hidden" name="_target_path" value="/account" /> <input type="submit" name="login" /> ``` the file config.yml I have this : ``` framework: #esi: ~ translator: { fallback: "%locale%" } ``` in parametre.yml I have this: ``` locale: en ``` I added the file in directory MyBundle/Resources/translations/messages.en.ymy: ``` security: login: username: "Username:" password: "Password:" submit: Login forgot_username: "Forgot username" forgot_password: "Forgot password" registration: register # Security "Bad credentials": "Your user name or password are incorrect." ``` but always I have the Bad credentials error message

Original source

Related problems