[英]Symfony2: local changes for same twig view
我已經在我的symfony2應用程序中實現了Jmsi18nRountingBundle: symfony2:如何參數化本地化以便我們可以使用2種語言?
我以為是這樣,但是現在我開始進行一些翻譯,我意識到,用於翻譯由樹枝中的trans標簽包圍的文本的語言環境在單個模板中有所不同。
參見分析器的輸出:
任何可能是什么原因的想法?
在我的模板中,我有以下代碼:
{# 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>
我有兩個翻譯文件,header.fr.xlf和header.en.xlf:en:
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'
fr:
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'
編輯1:
我發現這可能是我的區域設置偵聽器的優先級問題。 如果將優先級設置為17,則語言環境對於模板保持不變。 這是因為存在一個優先級為10的轉換偵聽器,該偵聽器會使用針對該語言環境的請求默認值來更改語言環境,該默認值實際上是由語言環境偵聽器通過讀取會話值來設置的。
對於給定的模板和使用render(controller())生成的模板,我仍然具有不同的語言環境。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.