2012-07-26 52 views
3

我使用Flask,忍者和Mustachjs一起。鬍子,babel和gettext

爲了完成工作,我使用{%raw%}標記。

現在,它是一個多語言應用程序,我使用Babel。

我該怎麼辦:

{% raw %} 
    <script id="details" type="text/template"> 

     <table class="table" > 

     <thead> 
     <tr> 
       <th>**{{gettext('col1')}}</th> 
       <th>**{{gettext('col2')}}</th> 
       <th>**{{gettext('col6')}}</th> 

     </tr> 
     </thead> 
     <tbody> 
     {{#skyrsla}} 
       <tr> 
         <td> {{index}}</td> 
         <td> {{nafn}}</td> 
         <td> {{mean_growth_index}}</td> 
       </tr> 
     {{/skyrsla}} 
     </tbody> 

     </table> 
</script> 
{% endraw %} 

既然是原始標記之間,巴貝爾擴展沒有檢測{{gettext的(「COL1」)} 有沒有辦法來改變通天的配置。

我的實際配置是這樣的:

[python: **.py] 
[jinja2: **/templates/**.html] 
extensions=jinja2.ext.autoescape,jinja2.ext.with_ 

回答

3

簡單地結束通話之間您的原始塊gettext

{% raw %} 
    <script id="details" type="text/template"> 

     <table class="table" > 

     <thead> 
     <tr> 
       <th>**{% endraw %}{{gettext('col1')}}{% raw %}</th> 
       <th>**{% endraw %}{{gettext('col2')}}{% raw %}</th> 
       <th>**{% endraw %}{{gettext('col6')}}{% raw %}</th> 

     </tr> 
     </thead> 
     <tbody> 
     {{#skyrsla}} 
       <tr> 
         <td> {{index}}</td> 
         <td> {{nafn}}</td> 
         <td> {{mean_growth_index}}</td> 
       </tr> 
     {{/skyrsla}} 
     </tbody> 

     </table> 
</script> 
{% endraw %}