I'm using yml format to translate my web app but I've one problem.
What I would like to do:
#exception.en.yml
exception.bad: 'Bad credentials'
What I know is possible to do:
#exception.en.yml
'Bad credentials': 'Bad credentials'
Is this the only method to translate the exception?
simply put in the translator and remember to add the trans
statement on the messagge error dump in the Twig template.
Here an xliff example:
messages.en.xlf
<trans-unit id="1">
<source>User account is disabled.</source>
<target>Account disabled or waiting for confirm</target>
</trans-unit>
<trans-unit id="2">
<source>Bad credentials</source>
<target>Wrong username or password</target>
</trans-unit>
and in the template
{# src/Acme/SecurityBundle/Resources/views/Security/login.html.twig #}
{% 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" />
<button type="submit">login</button>
</form>
Check this doc for exclude non active users
hope this help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With