Adding new email translation in FOSUserBundle

和自甴很熟 提交于 2019-12-12 03:49:11

问题


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:


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.



来源:https://stackoverflow.com/questions/41652849/adding-new-email-translation-in-fosuserbundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!