如果出現登錄錯誤,我想自定義錯誤消息('Bad credentials')。 我這樣做,但不工作。 這是模板登錄:Symfony2 - 如何翻譯來自FOSUserBundle的「Bad credentials」登錄錯誤消息?
{% 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" />
文件config.yml我有這樣的:
framework:
#esi: ~
translator: { fallback: "%locale%" }
在parametre.yml我有這樣的:
locale: en
我添加了文件目錄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."
但始終我有Bad憑證錯誤消息
可能重複(http://stackoverflow.com/questions/9201849/customize-authentication-login-symfony2 - 消息) – qooplmao