Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 875f29a

Browse files
committed
doc: i18n HTML templates
Issue #25907: Use {% trans %} tags in HTML templates to ease the translation of the documentation. The tag comes from Jinja templating system, used by Sphinx. Patch written by Julien Palard.
1 parent 3cdd5fb commit 875f29a

3 files changed

Lines changed: 59 additions & 59 deletions

File tree

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
{% extends "defindex.html" %}
22
{% block tables %}
3-
<p><strong>Parts of the documentation:</strong></p>
3+
<p><strong>{% trans %}Parts of the documentation:{% endtrans %}</strong></p>
44
<table class="contentstable" align="center"><tr>
55
<td width="50%">
6-
<p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br/>
7-
<span class="linkdescr">or <a href="{{ pathto("whatsnew/index") }}">all "What's new" documents</a> since 2.0</span></p>
8-
<p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br/>
9-
<span class="linkdescr">start here</span></p>
10-
<p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br/>
11-
<span class="linkdescr">keep this under your pillow</span></p>
12-
<p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br/>
13-
<span class="linkdescr">describes syntax and language elements</span></p>
14-
<p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Python Setup and Usage</a><br/>
15-
<span class="linkdescr">how to use Python on different platforms</span></p>
16-
<p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br/>
17-
<span class="linkdescr">in-depth documents on specific topics</span></p>
6+
<p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">{% trans %}What's new in Python {{ version }}?{% endtrans %}</a><br/>
7+
<span class="linkdescr"> {% trans whatsnew_index=pathto("whatsnew/index") %}or <a href="{{ whatsnew_index }}">all "What's new" documents</a> since 2.0{% endtrans %}</span></p>
8+
<p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">{% trans %}Tutorial{% endtrans %}</a><br/>
9+
<span class="linkdescr">{% trans %}start here{% endtrans %}</span></p>
10+
<p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">{% trans %}Library Reference{% endtrans %}</a><br/>
11+
<span class="linkdescr">{% trans %}keep this under your pillow{% endtrans %}</span></p>
12+
<p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">{% trans %}Language Reference{% endtrans %}</a><br/>
13+
<span class="linkdescr">{% trans %}describes syntax and language elements{% endtrans %}</span></p>
14+
<p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">{% trans %}Python Setup and Usage{% endtrans %}</a><br/>
15+
<span class="linkdescr">{% trans %}how to use Python on different platforms{% endtrans %}</span></p>
16+
<p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">{% trans %}Python HOWTOs{% endtrans %}</a><br/>
17+
<span class="linkdescr">{% trans %}in-depth documents on specific topics{% endtrans %}</span></p>
1818
</td><td width="50%">
19-
<p class="biglink"><a class="biglink" href="{{ pathto("installing/index") }}">Installing Python Modules</a><br/>
20-
<span class="linkdescr">installing from the Python Package Index &amp; other sources</span></p>
21-
<p class="biglink"><a class="biglink" href="{{ pathto("distributing/index") }}">Distributing Python Modules</a><br/>
22-
<span class="linkdescr">publishing modules for installation by others</span></p>
23-
<p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">Extending and Embedding</a><br/>
24-
<span class="linkdescr">tutorial for C/C++ programmers</span></p>
25-
<p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">Python/C API</a><br/>
26-
<span class="linkdescr">reference for C/C++ programmers</span></p>
27-
<p class="biglink"><a class="biglink" href="{{ pathto("faq/index") }}">FAQs</a><br/>
28-
<span class="linkdescr">frequently asked questions (with answers!)</span></p>
19+
<p class="biglink"><a class="biglink" href="{{ pathto("installing/index") }}">{% trans %}Installing Python Modules{% endtrans %}</a><br/>
20+
<span class="linkdescr">{% trans %}installing from the Python Package Index &amp; other sources{% endtrans %}</span></p>
21+
<p class="biglink"><a class="biglink" href="{{ pathto("distributing/index") }}">{% trans %}Distributing Python Modules{% endtrans %}</a><br/>
22+
<span class="linkdescr">{% trans %}publishing modules for installation by others{% endtrans %}</span></p>
23+
<p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">{% trans %}Extending and Embedding{% endtrans %}</a><br/>
24+
<span class="linkdescr">{% trans %}tutorial for C/C++ programmers{% endtrans %}</span></p>
25+
<p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">{% trans %}Python/C API{% endtrans %}</a><br/>
26+
<span class="linkdescr">{% trans %}reference for C/C++ programmers{% endtrans %}</span></p>
27+
<p class="biglink"><a class="biglink" href="{{ pathto("faq/index") }}">{% trans %}FAQs{% endtrans %}</a><br/>
28+
<span class="linkdescr">{% trans %}frequently asked questions (with answers!){% endtrans %}</span></p>
2929
</td></tr>
3030
</table>
3131

32-
<p><strong>Indices and tables:</strong></p>
32+
<p><strong>{% trans %}Indices and tables:{% endtrans %}</strong></p>
3333
<table class="contentstable" align="center"><tr>
3434
<td width="50%">
35-
<p class="biglink"><a class="biglink" href="{{ pathto("py-modindex") }}">Global Module Index</a><br/>
36-
<span class="linkdescr">quick access to all modules</span></p>
37-
<p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br/>
38-
<span class="linkdescr">all functions, classes, terms</span></p>
39-
<p class="biglink"><a class="biglink" href="{{ pathto("glossary") }}">Glossary</a><br/>
40-
<span class="linkdescr">the most important terms explained</span></p>
35+
<p class="biglink"><a class="biglink" href="{{ pathto("py-modindex") }}">{% trans %}Global Module Index{% endtrans %}</a><br/>
36+
<span class="linkdescr">{% trans %}quick access to all modules{% endtrans %}</span></p>
37+
<p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">{% trans %}General Index{% endtrans %}</a><br/>
38+
<span class="linkdescr">{% trans %}all functions, classes, terms{% endtrans %}</span></p>
39+
<p class="biglink"><a class="biglink" href="{{ pathto("glossary") }}">{% trans %}Glossary{% endtrans %}</a><br/>
40+
<span class="linkdescr">{% trans %}the most important terms explained{% endtrans %}</span></p>
4141
</td><td width="50%">
42-
<p class="biglink"><a class="biglink" href="{{ pathto("search") }}">Search page</a><br/>
43-
<span class="linkdescr">search this documentation</span></p>
44-
<p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">Complete Table of Contents</a><br/>
45-
<span class="linkdescr">lists all sections and subsections</span></p>
42+
<p class="biglink"><a class="biglink" href="{{ pathto("search") }}">{% trans %}Search page{% endtrans %}</a><br/>
43+
<span class="linkdescr">{% trans %}search this documentation{% endtrans %}</span></p>
44+
<p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">{% trans %}Complete Table of Contents{% endtrans %}</a><br/>
45+
<span class="linkdescr">{% trans %}lists all sections and subsections{% endtrans %}</span></p>
4646
</td></tr>
4747
</table>
4848

49-
<p><strong>Meta information:</strong></p>
49+
<p><strong>{% trans %}Meta information:{% endtrans %}</strong></p>
5050
<table class="contentstable" align="center"><tr>
5151
<td width="50%">
52-
<p class="biglink"><a class="biglink" href="{{ pathto("bugs") }}">Reporting bugs</a></p>
53-
<p class="biglink"><a class="biglink" href="{{ pathto("about") }}">About the documentation</a></p>
52+
<p class="biglink"><a class="biglink" href="{{ pathto("bugs") }}">{% trans %}Reporting bugs{% endtrans %}</a></p>
53+
<p class="biglink"><a class="biglink" href="{{ pathto("about") }}">{% trans %}About the documentation{% endtrans %}</a></p>
5454
</td><td width="50%">
55-
<p class="biglink"><a class="biglink" href="{{ pathto("license") }}">History and License of Python</a></p>
56-
<p class="biglink"><a class="biglink" href="{{ pathto("copyright") }}">Copyright</a></p>
55+
<p class="biglink"><a class="biglink" href="{{ pathto("license") }}">{% trans %}History and License of Python{% endtrans %}</a></p>
56+
<p class="biglink"><a class="biglink" href="{{ pathto("copyright") }}">{% trans %}Copyright{% endtrans %}</a></p>
5757
</td></tr>
5858
</table>
5959
{% endblock %}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<h3>Download</h3>
2-
<p><a href="{{ pathto('download') }}">Download these documents</a></p>
3-
<h3>Docs for other versions</h3>
1+
<h3>{% trans %}Download{% endtrans %}</h3>
2+
<p><a href="{{ pathto('download') }}">{% trans %}Download these documents{% endtrans %}</a></p>
3+
<h3>{% trans %}Docs for other versions{% endtrans %}</h3>
44
<ul>
5-
<li><a href="https://docs.python.org/2.7/">Python 2.7 (stable)</a></li>
6-
<li><a href="https://docs.python.org/3.4/">Python 3.4 (stable)</a></li>
7-
<li><a href="https://www.python.org/doc/versions/">Old versions</a></li>
5+
<li><a href="https://docs.python.org/2.7/">{% trans %}Python 2.7 (stable){% endtrans %}</a></li>
6+
<li><a href="https://docs.python.org/3.4/">{% trans %}Python 3.4 (stable){% endtrans %}</a></li>
7+
<li><a href="https://www.python.org/doc/versions/">{% trans %}Old versions{% endtrans %}</a></li>
88
</ul>
99

10-
<h3>Other resources</h3>
10+
<h3>{% trans %}Other resources{% endtrans %}</h3>
1111
<ul>
1212
{# XXX: many of these should probably be merged in the main docs #}
13-
<li><a href="https://www.python.org/dev/peps/">PEP Index</a></li>
14-
<li><a href="https://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li>
15-
<li><a href="https://wiki.python.org/moin/PythonBooks">Book List</a></li>
16-
<li><a href="https://www.python.org/doc/av/">Audio/Visual Talks</a></li>
13+
<li><a href="https://www.python.org/dev/peps/">{% trans %}PEP Index{% endtrans %}</a></li>
14+
<li><a href="https://wiki.python.org/moin/BeginnersGuide">{% trans %}Beginner's Guide{% endtrans %}</a></li>
15+
<li><a href="https://wiki.python.org/moin/PythonBooks">{% trans %}Book List{% endtrans %}</a></li>
16+
<li><a href="https://www.python.org/doc/av/">{% trans %}Audio/Visual Talks{% endtrans %}</a></li>
1717
</ul>

Doc/tools/templates/layout.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<li>
77
{%- if versionswitcher is defined %}
88
<span class="version_switcher_placeholder">{{ release }}</span>
9-
<a href="{{ pathto('index') }}">Documentation</a>{{ reldelim1 }}
9+
<a href="{{ pathto('index') }}">{% trans %}Documentation {% endtrans %}</a>{{ reldelim1 }}
1010
{%- else %}
1111
<a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}
1212
{%- endif %}
@@ -79,24 +79,24 @@
7979
{% endblock %}
8080
{% block footer %}
8181
<div class="footer">
82-
&copy; <a href="{{ pathto('copyright') }}">Copyright</a> {{ copyright|e }}.
82+
&copy; <a href="{{ pathto('copyright') }}">{% trans %}Copyright{% endtrans %}</a> {{ copyright|e }}.
8383
<br />
84-
The Python Software Foundation is a non-profit corporation.
85-
<a href="https://www.python.org/psf/donations/">Please donate.</a>
84+
{% trans %}The Python Software Foundation is a non-profit corporation.{% endtrans %}
85+
<a href="https://www.python.org/psf/donations/">{% trans %}Please donate.{% endtrans %}</a>
8686
<br />
87-
Last updated on {{ last_updated|e }}.
88-
<a href="{{ pathto('bugs') }}">Found a bug</a>?
87+
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
88+
{% trans pathto_bugs=pathto('bugs') %}<a href="{{ pathto_bugs }}">Found a bug</a>?{% endtrans %}
8989
<br />
90-
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version|e }}.
90+
{% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
9191
</div>
9292
{% endblock %}
9393
{% block sidebarsourcelink %}
9494
{%- if show_source and has_source and sourcename %}
9595
<h3>{{ _('This Page') }}</h3>
9696
<ul class="this-page-menu">
97-
<li><a href="{{ pathto('bugs') }}">Report a Bug</a></li>
97+
<li><a href="{{ pathto('bugs') }}">{% trans %}Report a Bug{% endtrans %}</a></li>
9898
<li><a href="{{ pathto('_sources/' + sourcename, true)|e }}"
99-
rel="nofollow">Show Source</a></li>
99+
rel="nofollow">{% trans %}Show Source{% endtrans %}</a></li>
100100
</ul>
101101
{%- endif %}
102102
{% endblock %}

0 commit comments

Comments
 (0)