Skip to content

Commit 7e39d39

Browse files
committed
Use translated text in templates
1 parent c85e58f commit 7e39d39

21 files changed

+183
-182
lines changed

roundup/cgi/engine_jinja2.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,17 @@
3838

3939
from roundup.cgi.templating import context, LoaderBase, TemplateBase
4040

41-
'''
42-
def get_gettext_translations():
43-
return gettext.find('??')
44-
'''
45-
4641
class Jinja2Loader(LoaderBase):
4742
def __init__(self, dir):
4843
extensions = [
4944
'jinja2.ext.autoescape',
50-
'jinja2.ext.i18n',
5145
]
5246
print "Jinja2 templates: ", dir
5347
print "Extensions: ", extensions
54-
#translations = get_gettext_translations()
5548
self._env = jinja2.Environment(
5649
loader=jinja2.FileSystemLoader(dir),
5750
extensions=extensions
5851
)
59-
#self._env.install_gettext_translations(translations)
6052

6153
def check(self, tplname):
6254
#print tplname
@@ -83,16 +75,6 @@ def render(self, client, classname, request, **options):
8375
# [ ] limit the information passed to the minimal necessary set
8476
c = context(client, self, classname, request)
8577
c.update({'options': options})
86-
87-
'''
88-
def translate(msgid, domain=None, mapping=None, default=None):
89-
result = client.translator.translate(domain, msgid,
90-
mapping=mapping, default=default)
91-
return unicode(result, client.translator.OUTPUT_ENCODING)
92-
93-
output = self._pt.render(None, translate, **c)
94-
return output.encode(client.charset)
95-
'''
9678
return self._tpl.render(c)
9779

9880
def __getitem__(self, name):

share/roundup/templates/jinja2/html/file.index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<h4>Files</h4>
1+
<h4>{{ i18n.gettext('Files') }}</h4>
22
<table class='table'>
33
<tr>
4-
<th>File name</th>
5-
<th>Uploaded</th>
6-
<th>Type</th>
7-
<th>Edit</th>
8-
<th>Remove</th>
4+
<th>{{ i18n.gettext('File name') }}</th>
5+
<th>{{ i18n.gettext('Uploaded') }}</th>
6+
<th>{{ i18n.gettext('Type') }}</th>
7+
<th>{{ i18n.gettext('Edit') }}</th>
8+
<th>{{ i18n.gettext('Remove') }}</th>
99
</tr>
1010
{% for file in context.files %}
1111
<tr>
@@ -16,15 +16,15 @@ <h4>Files</h4>
1616
<td>{{ file.type }}</td>
1717
{% if file.is_edit_ok %}
1818
<td>
19-
<a href='file{{ file.id }}'>edit</a>
19+
<a href='file{{ file.id }}'>{{ i18n.gettext('edit') }}</a>
2020
</td>
2121
{% endif %}
2222
{% if context.is_edit_ok %}
2323
<td>
2424
<form method="POST" action='issue{{ context.id }}'>
25-
<input type="hidden" name="@remove@files" value='file.id'>
26-
<input type="hidden" name="@action" value="edit">
27-
<input type="submit" value="remove" i18n:attributes="value">
25+
<input type="hidden" name="@remove@files" value='{{ file.id }}'>
26+
<input type="hidden" name="@action" value="{{ i18n.gettext('edit') }}">
27+
<input type="submit" value="{{ i18n.gettext('remove') }}">
2828
</form>
2929
</td>
3030
{% endif %}

share/roundup/templates/jinja2/html/file.item.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{% extends 'layout/page.html' %}
22

3+
{% block head_title %}
4+
{{ i18n.gettext('File display') }}
5+
{% endblock %}
6+
37
{% block page_header %}
4-
File display
8+
{{ i18n.gettext('File display') }}
59
{% endblock %}
610

711
{% block content %}
@@ -13,9 +17,9 @@
1317
enctype="multipart/form-data" action='{{ context.designator() }}'>
1418

1519
<dl class='dl-horizontal'>
16-
<dt>Name</dt>
20+
<dt>{{ i18n.gettext('Name') }}</dt>
1721
<dd>{{ context.name.field() }}</dd>
18-
<dt>Content Type</dt>
22+
<dt>{{ i18n.gettext('Content Type') }}</dt>
1923
<dd>{{ context.type.field() }}</dd>
2024
</dl>
2125

@@ -33,7 +37,7 @@
3337

3438
{% if context.id and context.is_view_ok() %}
3539
<div class='row-fluid'>
36-
<a href='file{{ context.id }}/{{ context.name }}'>Download</a>
40+
<a href='file{{ context.id }}/{{ context.name }}'>{{ i18n.gettext('Download') }}</a>
3741
</div>
3842
{% endif %}
3943

share/roundup/templates/jinja2/html/home.classlist.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{% extends 'layout/page.html' %}
22

3+
{% block head_title %}
4+
{{ i18n.gettext('List of classes') }}
5+
{% endblock %}
6+
37
{% block page_header %}
4-
List of classes
8+
{{ i18n.gettext('List of classes') }}
59
{% endblock %}
610

711
{% block content %}

share/roundup/templates/jinja2/html/issue.index.html

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{% extends 'layout/page.html' %}
22

3+
{% block head_title %}
4+
{{ i18n.gettext('List of issues') }}
5+
{% endblock %}
6+
37
{% block page_header %}
4-
List of issues
8+
{{ i18n.gettext('List of issues') }}
59
{% endblock %}
610

711
{% block content %}
@@ -12,15 +16,15 @@
1216
{% if context.list() %}
1317
<table class='table'>
1418
<tr class='info'>
15-
<td>Priority</td>
16-
<td>ID</td>
17-
<td>Activity</td>
18-
<td>Actor</td>
19-
<td>Keyword</td>
20-
<td>Title</td>
21-
<td>Status</td>
22-
<td>Creator</td>
23-
<td>Assigned&nbsp;To</td>
19+
<td>{{ i18n.gettext('Priority') }}</td>
20+
<td>{{ i18n.gettext('ID') }}</td>
21+
<td>{{ i18n.gettext('Activity') }}</td>
22+
<td>{{ i18n.gettext('Actor') }}</td>
23+
<td>{{ i18n.gettext('Keyword') }}</td>
24+
<td>{{ i18n.gettext('Title') }}</td>
25+
<td>{{ i18n.gettext('Status') }}</td>
26+
<td>{{ i18n.gettext('Creator') }}</td>
27+
<td>{{ i18n.gettext('Assigned To') }}</td>
2428
</tr>
2529
{% for issue in context.list() %}
2630
<tr>
@@ -39,15 +43,18 @@
3943
{% endfor %}
4044
</table>
4145
{% else %}
42-
<p class='text-error'>There are no issue yet!</p>
46+
<p class='text-error'>{{ i18n.gettext('There are no issue yet!') }}</p>
4347
{% endif %}
4448
{% endif %}
4549

4650
{% include 'layout/pagination.html' %}
4751

4852
<div class='row-fluid'>
4953
<div class='pull-right'>
50-
<a class='btn btn-success' href="{{ request.indexargs_url('issue', {'@action':'export_csv'}) }}">Download as CSV</a>
54+
<a class='btn btn-success'
55+
href="{{ request.indexargs_url('issue', {'@action':'export_csv'}) }}">
56+
{{ i18n.gettext('Download as CSV') }}
57+
</a>
5158
</div>
5259
</div>
5360

share/roundup/templates/jinja2/html/issue.item.edit.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<!-- title -->
1212
<div class='row-fluid'>
1313
<div class='control-group'>
14-
<label class='control-label' for='title'>Title</label>
14+
<label class='control-label' for='title'>{{ i18n.gettext('Title') }}</label>
1515
<div class='controls'>
1616
<input name='title' id='title' type='text' class='input-xxlarge' value='{{ context.title }}' required>
1717
</div>
@@ -21,13 +21,13 @@
2121
<!-- priority & Status -->
2222
<div class='row-fluid'>
2323
<div class='control-group span6'>
24-
<label class='control-label' for='priority'>Priority</label>
24+
<label class='control-label' for='priority'>{{ i18n.gettext('Priority') }}</label>
2525
<div class='controls'>
2626
{{ context.priority.menu() }}
2727
</div>
2828
</div>
2929
<div class='control-group span6'>
30-
<label class='control-label' for='status'>Status</label>
30+
<label class='control-label' for='status'>{{ i18n.gettext('Status') }}</label>
3131
<div class='controls'>
3232
{{ context.status.menu() }}
3333
</div>
@@ -37,13 +37,13 @@
3737
<!-- Superseder & nosy list -->
3838
<div class='row-fluid'>
3939
<div class='control-group span6'>
40-
<label class='control-label' for='superseder'>Superseder</label>
40+
<label class='control-label' for='superseder'>{{ i18n.gettext('Superseder') }}</label>
4141
<div class='controls'>
4242
<input type='text' name='superseder'>
4343
</div>
4444
</div>
4545
<div class='control-group span6'>
46-
<label class='control-label' for='nosylist'>Nosy list</label>
46+
<label class='control-label' for='nosylist'>{{ i18n.gettext('Nosy list') }}</label>
4747
<div class='controls'>
4848
<input type='text' name='nosy'>
4949
</div>
@@ -53,13 +53,13 @@
5353
<!-- Assigned to & keywords -->
5454
<div class='row-fluid'>
5555
<div class='control-group span6'>
56-
<label class='control-label' for='assignedto'>Assigned to</label>
56+
<label class='control-label' for='assignedto'>{{ i18n.gettext('Assigned to') }}</label>
5757
<div class='controls'>
5858
{{ context.assignedto.menu() }}
5959
</div>
6060
</div>
6161
<div class='control-group span6'>
62-
<label class='control-label' for='keywords'>Keywords</label>
62+
<label class='control-label' for='keywords'>{{ i18n.gettext('Keywords') }}</label>
6363
<div class='controls'>
6464
<input type='text' name='keywords' id='keywords'>
6565
</div>
@@ -69,7 +69,7 @@
6969
<!-- Note -->
7070
<div class='row-fluid'>
7171
<div class='control-group'>
72-
<label class='control-label' for='change_note'>Change note</label>
72+
<label class='control-label' for='change_note'>{{ i18n.gettext('Change note') }}</label>
7373
<div class='controls'>
7474
<textarea name="@note" rows="5" class='input-xxlarge' id='change_note'></textarea>
7575
</div>
@@ -79,7 +79,7 @@
7979
<!-- File upload -->
8080
<div class='row-fluid'>
8181
<div class='control-group'>
82-
<label class='control-label' for='file_upload'>File</label>
82+
<label class='control-label' for='file_upload'>{{ i18n.gettext('File') }}</label>
8383
<div class='controls'>
8484
<input type="file" name="@file" id='file_upload'>
8585
</div>
@@ -89,7 +89,7 @@
8989
<div class='form-actions'>
9090
{{ context.submit() }}
9191
{% if context.id %}
92-
<a href='{{ context.copy_url() }}'>Make a copy</a>
92+
<a href='{{ context.copy_url() }}'>{{ i18n.gettext('Make a copy') }}</a>
9393
{% endif %}
9494
</div>
9595
<input type="hidden" name="@template" value="item">
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<dl class='dl-horizontal'>
2-
<dt>Title</dt>
2+
<dt>{{ i18n.gettext('Title') }}</dt>
33
<dd>{{ context.title.plain() }}</dd>
4-
<dt>Priority</dt>
4+
<dt>{{ i18n.gettext('Priority') }}</dt>
55
<dd>{{ context.priority.plain() }}</dd>
6-
<dt>Status</dt>
6+
<dt>{{ i18n.gettext('Status') }}</dt>
77
<dd>{{ context.status.plain() }}</dd>
8-
<dt>Superseder</dt>
8+
<dt>{{ i18n.gettext('Superseder') }}</dt>
99
<dd>{{ context.superseder.plain() }}</dd>
10-
<dt>Nosy list</dt>
10+
<dt>{{ i18n.gettext('Nosy list') }}</dt>
1111
<dd>{{ context.nosy.plain() }}</dd>
12-
<dt>Assigned to</dt>
12+
<dt>{{ i18n.gettext('Assigned to') }}</dt>
1313
<dd>{{ context.assignedto.plain() }}</dd>
14-
<dt>Keywords</dt>
14+
<dt>{{ i18n.gettext('Keywords') }}</dt>
1515
<dd>{{ context.keyword.plain() }}</dd>
1616
</dl>

share/roundup/templates/jinja2/html/keyword.item.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{% extends 'layout/page.html' %}
22

3+
{% block head_title %}
4+
{{ i18n.gettext('Keyword editing') }}
5+
{% endblock %}
6+
37
{% block page_header %}
4-
Keyword editing
8+
{{ i18n.gettext('Keyword editing') }}
59
{% endblock %}
610

711
{% block content %}
812

913
<h4>Existing Keywords</h4>
1014
<p class='text-warning'>
11-
To edit an existing keyword (for spelling or typing errors),
12-
click on its entry above.
15+
{{ i18n.gettext('To edit an existing keyword (for spelling or typing errors),
16+
click on its entry above.') }}
1317
</p>
1418

1519
<ul class='nav nav-pills nav-stacked'>
@@ -18,7 +22,7 @@ <h4>Existing Keywords</h4>
1822
<a href='keyword{{ keyword.id }}'>{{ keyword.name }}</a>
1923
</li>
2024
{% else %}
21-
<p class='text-mute'>There are no keywords yet. Be the first -</p>
25+
<p class='text-mute'>{{ i18n.gettext('There are no keywords yet. Be the first -') }}</p>
2226
{% endfor %}
2327
</ul>
2428

@@ -27,8 +31,6 @@ <h4>Existing Keywords</h4>
2731
<input type="hidden" name="@required" value="name">
2832
<input type="hidden" name="@template" value="item">
2933
<input type="hidden" name="@action" value="new">
30-
<input type='submit' class='btn btn-primary' value='Create keyword'>
34+
<input type='submit' class='btn btn-primary' value="{{ i18n.gettext('Create keyword') }}">
3135
</form>
3236
{% endblock %}
33-
34-

share/roundup/templates/jinja2/html/layout/banner.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
<div class="navbar">
22
<div class='container-fluid'>
33
<div class='navbar-inner'>
4-
<a href="/" class='brand'><i class='icon-home'></i> Roundup Demo Tracker</a>
4+
<a href="/" class='brand'><i class='icon-home'></i> {{ i18n.gettext('Roundup Demo Tracker') }}</a>
55
<form name="searchform" method="get" action="bug" class='navbar-search pull-right'>
6-
<!-- FIXME:
7-
<input type="hidden" name="@columns" tal:attributes="value bug_columns_showall"/>
8-
-->
6+
<input type="hidden" name="@columns" value="{{ bug_columns_showall }}"/>
97
<input type="hidden" name="@sort" value="-activity">
108
<input type="hidden" name="@group" value="priority">
119
<input type="hidden" name="@filter" value="status">
12-
<!-- FIXME:
13-
<input type="hidden" name="status" tal:attributes="value bug_status_notclosed"/>
14-
-->
10+
<input type="hidden" name="status" value="{{ bug_status_notclosed }}"/>
1511
<input class="input-medium search-query" id="search-text" type="search" name="@search_text">
16-
<input type="submit" value="search in open bugs" name="submit" class='btn'>
12+
<input type="submit" value="{{ i18n.gettext('search in open bugs') }}" name="submit" class='btn'>
1713
</form>
1814
</div> <!-- navbar-inner -->
1915
</div> <!-- container-fluid -->
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<footer>
22
<div class='container-fluid'>
33
<hr>
4-
A <a href='http://roundup.sourceforge.net/'>roundup</a> production.
4+
{{ i18n.gettext('A') }}
5+
<a href='http://roundup.sourceforge.net/'>{{ i18n.gettext('roundup') }}</a>
6+
{{ i18n.gettext('production') }}.
57
</div>
68
</footer>

0 commit comments

Comments
 (0)