Adding new email translation in FOSUserBundle

2019-09-14 01:05发布

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条回答
甜甜的少女心
2楼-- · 2019-09-14 02:04

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.

查看更多
登录 后发表回答