Authentication 在symfony2中翻译身份验证错误的推荐方法
例如,我需要用另一种语言显示“坏凭证”消息。 到目前为止,我发现它在Authentication 在symfony2中翻译身份验证错误的推荐方法,authentication,internationalization,symfony,Authentication,Internationalization,Symfony,例如,我需要用另一种语言显示“坏凭证”消息。 到目前为止,我发现它在 \vendor\symfony\src\symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider.php authenticate作为 抛出新的BadCredentialsException('Bad credentials',0,$notFound) 我想知道用另一种语言显示此消息的推荐方式是什么。只是在这个地方更改字
\vendor\symfony\src\symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider.php
authenticate
作为抛出新的BadCredentialsException('Bad credentials',0,$notFound)代码>
我想知道用另一种语言显示此消息的推荐方式是什么。只是在这个地方更改字符串似乎不是最优的。。。
此外,在身份验证期间可能还会显示其他消息
我正在使用JMSSecurityExtraBundle
和FOSUserBundle
,我想可能有一些内置的功能来处理这个
覆盖登录模板:将FOSUserBundle/Resources/views/Security/login.html.twig复制到app/Resources/views/Security/login.html.twig(请参阅,)
将trans过滤器添加到login.html.twig中的error变量(请参阅):
{{error | trans}}
在翻译文件src/YourBundlePath/Resources/translations/messages.{locale}.yml中添加:
错误凭据:您的错误文本
覆盖登录模板:将FOSUserBundle/Resources/views/Security/login.html.twig复制到app/Resources/views/Security/login.html.twig(请参阅,)
将trans过滤器添加到login.html.twig中的error变量(请参阅):
{{error | trans}}
在翻译文件src/YourBundlePath/Resources/translations/messages.{locale}.yml中添加:
错误凭据:您的错误文本
太好了,谢谢。我只需要清除dev缓存就可以生效了。太好了,谢谢。我只需要清除dev缓存以使其生效。