douyannuo7733 2017-01-14 17:25
浏览 44

在FOSUserBundle中添加新的电子邮件翻译

I have add a new translation field, email ,in FOSUserBundle as follows:

security:
    login:
        email: Email
        username: Username
        password: Password
        remember_me: Remember me
        submit: Log in

All the translation files are in src/UserBundle/Resources/translations. My login.html.twig file looks like:

{% extends "UserBundle::layout.html.twig" %}

{% trans_default_domain 'FOSUserBundle' %}

{% block fos_user_content %}
{% if error %}
    <div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}

<form action="{{ path("fos_user_security_check") }}" method="post">
    <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />

    <label for="email">{{ 'security.login.email'|trans }}</label>
    <input type="email" id="email" name="_email" value="{{ last_username }}" required="required" />

    <label for="password">{{ 'security.login.password'|trans }}</label>
    <input type="password" id="password" name="_password" required="required" />

    <input type="checkbox" id="remember_me" name="_remember_me" value="on" />
    <label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>

    <input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans }}" />
</form>
{% endblock fos_user_content %}

But when I load the login page the email field is not translated. What is going on?

  • 写回答

1条回答 默认 最新

  • dphfwzn8269 2017-04-27 19:26
    关注

    I've also got some customised translations - the file where I copied and have then overridden them is app/Resources/FOSUserBundle/translations/FOSUserBundle.en.yml.

    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致