symfony/symfony — Issue #2780: Translation authentication errors
Author: tvlooy
Created: 2011-12-03 10:53:06+00:00
State: open

The form validators are nicely integrated with the translator. The only thing you have to do is set your language and the messages are automatically translated.

With the authentication system, this is not the case. A possible, simple, solution would be to add authMsg.xx.xliff files to Symfony/Bundle/FrameworkBundle/Resources/translations/ that contain translations for AuthenticationExceptions. Then you could translate the error like this:

{% if error %}

{{ error.message|trans({}, 'authMsg') }}

{% endif %}

This is how you should display the error according to the handbook http://symfony.com/doc/current/book/security.html

Below is an example authMsg.nl.xliff:

The presented password is invalid.
Het gegeven wachtwoord is ongeldig.

Bad credentials
Foutieve gegevens

User account is disabled.
Gebruiker is uitgeschakeld.

The presented password cannot be empty.
Wachtwoord kan niet leeg zijn.

The credentials were changed from another session.
Gebruiker werd via een andere sessie gewijzigd.

User credentials have expired.
De sessie is verlopen.