2011-12-13 2 views
1

FOSUserBundle 로그인 양식을 사용하고 있으며 오류 메시지를 번역하고 싶습니다. 이러한 메시지는 여기에서 시작됩니다 공급 업체/심포니/SRC/심포니/컴포넌트/보안/코어/인증/제공/DaoAuthenticationProvider.php로그인 양식의 오류 메시지 번역

protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token) 
    { 
     $currentUser = $token->getUser(); 
     if ($currentUser instanceof UserInterface) { 
      if ($currentUser->getPassword() !== $user->getPassword()) { 
       throw new BadCredentialsException('The credentials were changed from another session.'); 
      } 
     } else { 
      if (!$presentedPassword = $token->getCredentials()) { 
       throw new BadCredentialsException('The presented password cannot be empty.'); 
      } 

      if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) { 
       throw new BadCredentialsException('The presented password is invalid.'); 
      } 
     } 
    } 

내가 작성했습니다 응용 프로그램/자원/번역/validators.fr .yml

"The presented password cannot be empty.":  "Veuillez saisir un mot de passe." 

내가 응용 프로그램/자원/번역/messages.fr.yml

"The presented password cannot be empty.":  "Veuillez saisir un mot de passe." 
,691 쓰기했습니다

하지만 작동하지 않습니다. 다른 번역이 작동하지만 (=> fr),이 메시지에 문제가 있습니다.

이러한 메시지에 대한 특수 절차는 무엇입니까?

답변

7

/UserBundle/자원/조회/관리/보안/login.html.twig들 :

<div class="alert-message error">{{ error|trans({}, 'SonataUserBundle') }}</div> 

그래서 당신은 당신이 사용하는 어떤 번역 파일에 SonataUserBundle을 변경하거나 SRC를 추가해야합니다/. 당신의/번들/자료/번역/SonataUserBundle {로케일}

을 .yml 번역 파일 내부 :

'Bad credentials': 'Your translation' 
'The presented password is invalid.': 'Your translation' 
'The presented password cannot be empty.': 'Your translation' 

나는 충분히 분명 희망]

+0

비슷한 방법을 사용했습니다 : 오류를 잡아서 trans로 나뭇 가지에 표시하십시오. . – bux

0

나는 그렇게 생각하지 않는다. 오류를 잡아서해야 할 일을해야합니다 ... 예를 들어 플래시 세션 메시지가있는 메시지를 표시하고 잊어 버린 암호 페이지로 리디렉션하십시오. 파일 소나타에서

+0

예, 아이디어입니다. 시도해 보겠습니다. – bux

+1

ID는 FOSUserBundle의 내부입니다 :/나는 catch 할 수 없습니다 – bux

+0

비슷한 생각입니다 : catch error, do something =) – bux

2

FOSUserBundle "Bad Credentials"버전 1.3에서는 실제로 "Bad Credentials"입니다. (마지막 점 마음을).