kvd*_*vdb 5 google-app-engine template-engine internationalization jinja2
从Jinja2模板,这是我追求的渲染线(英文):
This is the <a href="roadmap.html">roadmap</a>
Run Code Online (Sandbox Code Playgroud)
用荷兰语翻译应该导致:
Dit is de <a href="roadmap.html">planning</a>
Run Code Online (Sandbox Code Playgroud)
这条Jinja2系列让我在那里 - 几乎 -
{{ _('This is the %(roadmap)s.', roadmap='<a href="roadmap.html">roadmap</a>'|safe) }}
Run Code Online (Sandbox Code Playgroud)
不幸的是,"路线图"一词并未翻译.
Jinja2实现这一目标的方法是什么?拆分roadmap1和roadmap2中的链接?我希望有更聪明的东西.
这些应该有效:
{{ _('This is the') }} <a href="roadmap.html">{{ _('roadmap') }}</a>
{{ _('This is the %(roadmap)s', roadmap=('<a href="roadmap.html">%s</a>' % _('roadmap'))|safe) }}
Run Code Online (Sandbox Code Playgroud)
另外,如果您使用 webapp2,您可能需要将 href="roadmap.html" 替换为例如href="{{ uri_for('roadmap') }}"
| 归档时间: |
|
| 查看次数: |
350 次 |
| 最近记录: |