问题描述
作为表示我已覆盖
FOSUserBundle的layout.html.twig模板。
as here is said I've overrided the layout.html.twig template ofFOSUserBundle.
这是新模板:
//app/Resources/FOSUserBundle/views
{% extends 'AibFrontendBundle::layout.html.twig' %}
{% block content%}
<div>
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
{{ 'layout.logged_in_as'|trans({'%username%':
app.user.username}, 'FOSUserBundle') }} |
<a href="{{ path('fos_user_security_logout') }}">
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
</a>
{% else %}
<a
href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|
trans({}, 'FOSUserBundle') }}</a>
{% endif %}
</div>
{% for key, message in app.session.getFlashes() %}
<div class="{{ key }}">
{{ message|trans({}, 'messages') }}
</div>
{% endfor %}
<div>
{% block fos_user_content %}
{% endblock fos_user_content %}
</div>
{% endblock %}
您可以看到我的layout.html .twig与原始的
FOSUserBundle几乎相同,但是我把i18n目录称为消息。
As you can see my layout.html.twig is almost the same as the originalFOSUserBundle, but I'm calling the i18n catalog "messages".
我里面有messages.it.xliff / Aib / FrontendBundle / Resources /
翻译。在这里是:
I have messages.it.xliff inside /Aib/FrontendBundle/Resources/translations. Here it is:
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext"
original="file.ext">
<body>
<trans-unit id="1">
<source>Bad credentials</source>
<target>Username o password invalidi</target>
</trans-unit>
</body>
</file>
</xliff>
问题:错误凭据的翻译不起作用。
The problem: the translation of "Bad credentials" doesn't work..
我清除了缓存。
推荐答案
我找到了答案的解决方案。
在这里创建yml文件对我有用: app / Resources / translations / FOSUserBundle.fr.yml
如果您不知道如何要填充此文件,请在捆绑软件中查找具有相似名称的文件。清除缓存很重要。
I found the solution to your answer.creating a yml file here did the trick for me: app/Resources/translations/FOSUserBundle.fr.yml
If you don't know how to fill this file, look for the file with a similar name in the bundle. Clearing the cache is important.
您确实不满足于我对这个问题(以及其他几个问题)的看法,这让我很生气,但是您的问题是一个很好的问题,还有一些其他人可能需要答案,没有理由让他们没有答案,所以这里就是。祝您有美好的一天,请在有人与您交谈时回复。这是基本的礼貌。
You really pissed me off by not answering my comment on this question (and on several others), but your question is a good question and some other people may need the answer, and there is no reason for them not to get an answer so here it is. Have a good day, and please reply when someone talks to you. It is basic politeness.
这篇关于如何将目录应用于FOSUserBundle的覆盖布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!