[英]How to translation "Invalid credentials." error in FOSUserBundle symfony
I have this part of code in login.html.twig page我在 login.html.twig 页面中有这部分代码
I want to translate error message "Invalid credentials."我想翻译错误消息“无效的凭据”。
{% if error %}
<div style="color:red">
{{ error.messageKey|trans(error.messageData, 'security') }}
</div>
{% endif %}
now, i'm trying to translat in messages.en.yml or in FOSUserBundle.en.yml and nothing happen.现在,我正在尝试在 messages.en.yml 或 FOSUserBundle.en.yml 中进行翻译,但没有任何反应。 (using symfony3)
(使用 symfony3)
After looking for a while, I found it can help找了一会儿,发现有帮助
I looked for where the message came fromץץ and i found that this message "Invalid credentials."我查找了消息的来源ץץ,发现此消息“凭据无效”。 coming from this path.
来自这条道路。
vendor\symfony\symfony\src\Symfony\Component\Security\Core\Resources\translations\security.en.xlf
so i copeid the file security.en.xlf into app\Resources\translations and made some change to the part i wanted to translate所以我将文件security.en.xlf复制到app\Resources\translations并对我想要翻译的部分进行了一些更改
<trans-unit id="4">
<source>Invalid credentials.</source>
<target>Username/password doesn't match</target>
</trans-unit>
Btw, in my case, I just uncomment the following line in config.yml :顺便说一句,就我而言,我只是取消注释 config.yml 中的以下行:
framework:
translator: { fallbacks: ['%locale%'] }
And my locale was set to "fr"我的语言环境设置为“fr”
parameters:
locale: fr
Change fr
by the locale you want to make default:通过您要设为默认的语言环境更改
fr
:
# config/packages/translation.yaml
framework:
default_locale: fr
Source : https://symfony.com/doc/current/translation/locale.html来源: https ://symfony.com/doc/current/translation/locale.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.