그래서 저는 Symfony2 Book의 보안 장을 읽었습니다. 모든 것을 이해하지만 로그인 오류가 있으면 오류 메시지를 사용자 정의하고 싶습니다.인증 사용자 정의 - 로그인 Symfony2 메시지
어떤 파일로 변경할 수 있습니까?
if (error.message=="Bad credentials")
echo "Los datos son erróneos :)"
if (error.message==The presented password is invalid")
echo "La combinación username/password no es correcta :)"
당신이 날하시기 바랍니다 도움이 될 :이 일을 최악의 방법과 같이 될 것이라고 생각
{% if error %}
<div>{{ error.message }}</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" />
{#
If you want to control the URL the user is redirected to on success (more details below)
<input type="hidden" name="_target_path" value="/account" />
#}
<input type="submit" name="login" />
:
이 템플릿입니까?
편집 : 내가 일을 가지고 :
사람이 작업을 수행해야하는 경우, 당신은 config.yml
#app/config/config.yml
framework:
translator: { fallback: en }
이 줄을 추가해야하고,에 넣어 파일 messages.whateverisyourlanguage.yml, 내 경우 messages.es.yml, 다음과 같은 라인 :
번역하려는 텍스트
#Foo\DummyBundle\Resources\translations\messages.es.yml
The presented password cannot be empty.: El campo contrasena no debe estar vacio
The presented password is invalid.: Los datos suministrados son incorrectos
Bad credentials: Los datos suministrados son incorrectos
번역하려는 텍스트에주의하십시오. 텍스트 끝에 점이 있으면 점을 찍어야합니다. 나는 그렇게하지 않고 있었고 작동하지도 않았다.
footranslate.
는 footranslate
인사말 다릅니다! :)
감사합니다. 이제 로그인 양식이 던져야하는 모든 오류 메시지를 어디에서 찾을 수 있습니까? 메시지 파일에 표시 될 메시지를 정확하게 넣어야하므로 메시지를 모두 번역 할 수는 있지만 메시지가 확실하지는 않습니다. –
메시지가 몇 개 밖에 없다 -'./vendor/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/'에있는 파일에서 예외 메시지를 체크 아웃하라. – jkucharovic
여기에도 메시지가있다 : vendor \ symfony \ src \ Symfony \ Component \ Security \ Core \ User \ UserChecker.php –