Php Symfony2:同一细枝视图的本地更改
我已经在symfony2应用程序中实现了JMSI18nRuntingBundle: 我原以为是这样,但现在我已经开始进行一些翻译,我意识到用于翻译由twig中的trans标记包围的文本的区域设置在单个模板中有所不同 请参见探查器的输出: 你知道是什么引起的吗 在我的模板中,我有以下代码:Php Symfony2:同一细枝视图的本地更改,php,symfony,twig,translation,locale,Php,Symfony,Twig,Translation,Locale,我已经在symfony2应用程序中实现了JMSI18nRuntingBundle: 我原以为是这样,但现在我已经开始进行一些翻译,我意识到用于翻译由twig中的trans标记包围的文本的区域设置在单个模板中有所不同 请参见探查器的输出: 你知道是什么引起的吗 在我的模板中,我有以下代码: {# src/FoodMeUp/CoreBundle/Resources/views/Default/header.html.twig #} {% trans_default_domain 'header'
{# src/FoodMeUp/CoreBundle/Resources/views/Default/header.html.twig #}
{% trans_default_domain 'header' %}
<header>
<section id="toprow" class="greybg">
<ul class="wrapperext">
<li id="startup_button">
<a href="{{ path('cms', {'dir' : 'general', 'page' : 'startup'}) }}" class="bold align_center">{% trans %}howto{% endtrans %} <span>{% trans %}start{% endtrans %} </span><i class="fa fa-question-circle"></i></a>
</li>
<li id="top_row_message" class="padding-h">{{ socialButtons({url: 'home', padding: false , facebookLike : { layout : 'button_count'}, facebookShare : { layout : 'button_count'}, twitter : { count : 'horizontal'} , googleplus : { annotation: 'bubble'} }) }}</li>
</ul>
</section>
<section id="header_content" class="padding-v whitebg clearfix">
<div id="pres" class="wrapper fmu_flex space-between center">
<h2 class="align_left">{% trans %}description.left.normal{% endtrans %} <strong>{% trans %}description.left.strong{% endtrans %}</strong>...</h2>
<a id="logo" href="{{ path('home') }}"><img src="{{ asset('images/foodmeup_horizontal_w280.png') }}" alt="logo Foodmeup" class="margin-auto block"></a>
<h2 class="align_right">...{% trans %}description.right.normal{% endtrans %} <strong>{% trans %}description.right.strong{% endtrans %}</strong> {% trans %}description.right.normal2{% endtrans %}</h2>
</div>
{% if isAuthenticated() == false %}
<div id="create_account_button" class="wrapper align_center"><a href="{{ path('fos_user_security_login') }}" class="btn btn-default btn-xs">{% trans %}create.account{% endtrans %}</a></div>
{% endif %}
</section>
</header>
fr:
编辑1:
我发现这可能是我的区域设置侦听器的一个优先问题。
如果我将优先级设置为17,则模板的区域设置保持不变。这是因为有一个优先级为10的翻译侦听器,它使用请求的语言环境默认值更改语言环境,该值实际上是由语言环境侦听器通过读取会话值来设置的
对于给定模板和使用render(controller())生成的模板,我仍然有不同的区域设置。。。调查这一点。找到了解决方案,哎呀,这就是我编辑之后的内容 除了向我的区域设置侦听器添加优先级17之外,我还需要确保它还处理子请求 请参见此处更正的代码:
howto: 'How to'
start: 'start'
connect: 'Connect'
description.left.normal: 'FoodMeUp is a platform of'
description.left.strong: 'services'
description.right.normal: 'dedicated to'
description.right.strong: 'professionals'
description.right.normal2: 'of the food industry'
create.account: 'Create your account in one minute'
start: 'démarrer'
howto: 'Comment'
connect: 'Connexion'
description.left.normal: 'FoodMeUp est une plateforme de'
description.left.strong: 'services'
description.right.normal: 'dédiée aux'
description.right.strong: 'professionnels'
description.right.normal2: 'des métiers de bouche'
create.account: 'Créez votre compte en 1 minute'