Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translation "Invalid credentials." error in FOSUserBundle symfony

Tags:

php

symfony

I have this part of code in login.html.twig page

I want to translate error message "Invalid credentials."

 {% if error %}
     <div style="color:red">
         {{ error.messageKey|trans(error.messageData, 'security') }}
     </div>
 {% endif %}

now, i'm trying to translat in messages.en.yml or in FOSUserBundle.en.yml and nothing happen. (using symfony3)

like image 753
Shay Altman Avatar asked Mar 26 '16 12:03

Shay Altman


2 Answers

After looking for a while, I found it can help

I looked for where the message came fromץץ and i found that this message "Invalid credentials." coming from this path.

vendor\symfony\symfony\src\Symfony\Component\Security\Core\Resources\translations\security.en.xlf

so i copeid the file security.en.xlf into app\Resources\translations and made some change to the part i wanted to translate

<trans-unit id="4">
    <source>Invalid credentials.</source>
    <target>Username/password doesn't match</target>
</trans-unit>
like image 163
Shay Altman Avatar answered Nov 16 '22 11:11

Shay Altman


Btw, in my case, I just uncomment the following line in config.yml :

framework:
    translator: { fallbacks: ['%locale%'] }

And my locale was set to "fr"

parameters:
    locale: fr
like image 1
F2000 Avatar answered Nov 16 '22 10:11

F2000