bux*_*bux 1 translation symfony
我使用FOSUserBundle登录表单,我想翻译错误消息.这些消息在这里发布:vendor/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/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.');
}
}
}
Run Code Online (Sandbox Code Playgroud)
我写了app/Resources/translations/validators.fr.yml
"The presented password cannot be empty.": "Veuillez saisir un mot de passe."
Run Code Online (Sandbox Code Playgroud)
我写了app/Resources/translations/messages.fr.yml
"The presented password cannot be empty.": "Veuillez saisir un mot de passe."
Run Code Online (Sandbox Code Playgroud)
但它不起作用.其他翻译工作(=> fr),但我对这些消息有疑问.
这些消息的特殊程序?
小智 7
在文件Sonata/UserBundle/Resources/views/Admin/Security/login.html.twig您有:
<div class="alert-message error">{{ error|trans({}, 'SonataUserBundle') }}</div>
Run Code Online (Sandbox Code Playgroud)
所以您必须将SonataUserBundle更改为您正在使用的任何翻译文件或添加src /您的/ Bundle/Resources/translations/SonataUserBundle.{locale} .yml
和内部翻译文件:
'Bad credentials': 'Your translation'
'The presented password is invalid.': 'Your translation'
'The presented password cannot be empty.': 'Your translation'
Run Code Online (Sandbox Code Playgroud)
我希望它足够清楚;]
| 归档时间: |
|
| 查看次数: |
10493 次 |
| 最近记录: |