Commits

Ales Zabala Alava committed a8c1e54

i18n of models and templates

Comments (0)

Files changed (6)

sphinxdoc/models.py

 
 """
 from django.db import models
+from django.utils.translation import ugettext_lazy as _
 
 from sphinxdoc.validators import validate_isdir
 
     """
     name = models.CharField(max_length=100)
     slug = models.SlugField(unique=True,
-            help_text=u'Used in the URL for the project. Must be unique.')
+            help_text=_(u'Used in the URL for the project. Must be unique.'))
     path = models.CharField(max_length=255, validators=[validate_isdir],
-            help_text=u'Directory that contains Sphinx’ <tt>conf.py</tt>.')
+            help_text=_(u'Directory that contains Sphinx’ <tt>conf.py</tt>.'))
+
+    class Meta:
+        verbose_name = _('project')
+        verbose_name_plural = _('projects')
 
     def __unicode__(self):
         return self.name
     title = models.CharField(max_length=255)
     body = models.TextField(blank=True)
 
+    class Meta:
+        verbose_name = _('document')
+        verbose_name_plural = _('documents')
+
     def __unicode__(self):
         return self.path
 

sphinxdoc/templates/sphinxdoc/documentation.html

 {% extends 'base.html' %}
+{% load i18n %}
 
 {% block title %}{{ block.super }} » {{ project.name }}{% for p in doc.parents %} » {{ p.title|striptags|safe }}{% endfor %} » {{ doc.title|striptags|safe }}{% endblock %}
 
 <div class="pagination-top">
     <div class="breadcrumbs">
 		» <a href="{{ project.get_absolute_url }}">
-			{{ project.name }} documentation</a>
+            {% blocktrans with project_name=project.name %}{{ project_name }} documentation{% endblocktrans %}</a>
     {% for p in doc.parents %}
     	» <a href="{{ p.link }}">{{ p.title|safe }}</a>
     {% endfor %}
     {% if doc.prev or doc.next %}
     <span class="alignleft">
         {% if doc.prev %}
-          Prev: <a href="{{ doc.prev.link }}">{{ doc.prev.title|safe }}</a>
+          {% trans "Prev:" %} <a href="{{ doc.prev.link }}">{{ doc.prev.title|safe }}</a>
         {% endif %}</span>
 	<span class="alignright">
         {% if doc.next %}
-          Next: <a href="{{ doc.next.link }}">{{ doc.next.title|safe }}</a>
+          {% trans "Next:" %} <a href="{{ doc.next.link }}">{{ doc.next.title|safe }}</a>
         {% endif %}</span><div class="clearboth">.</div>
     {% endif %}
 </div>
     {% if doc.prev or doc.next %}
     <span class="alignleft">
         {% if doc.prev %}
-          Prev: <a href="{{ doc.prev.link }}">{{ doc.prev.title|safe }}</a>
+          {% trans "Prev:" %} <a href="{{ doc.prev.link }}">{{ doc.prev.title|safe }}</a>
         {% endif %}</span>
 	<span class="alignright">
         {% if doc.next %}
-          Next: <a href="{{ doc.next.link }}">{{ doc.next.title|safe }}</a>
+          {% trans "Next:" %} <a href="{{ doc.next.link }}">{{ doc.next.title|safe }}</a>
         {% endif %}</span><div class="clearboth">.</div>
     {% endif %}
 	<div class="breadcrumbs">
-    	» <a href="{{ project.get_absolute_url }}">{{ project.name }} documentation</a>
+        » <a href="{{ project.get_absolute_url }}">{% blocktrans with project_name=project.name %}{{ project_name }} documentation{% endblocktrans %}</a>
     {% for p in doc.parents %}
     	» <a href="{{ p.link }}">{{ p.title|safe }}</a>
     {% endfor %}
     	» {{ doc.title|safe }}
 	</div>
 	<div class="meta">
-    	Last update: {{ update_date|date:"Y-m-d H:i" }} (<a href="http://www.timeanddate.com/worldclock/city.html?n=37">CET</a>)
+        {% trans "Last update:" %} {{ update_date|date:"SHORT_DATETIME_FORMAT" }} (<a href="http://www.timeanddate.com/worldclock/city.html?n=37">CET</a>)
 	</div>
 </div>
 {% endblock content %}
 {% block sidebar %}
     {% block doc_toc %}
 <div class="box">
-    <h2>Contents</h2>
+    <h2>{% trans "Contents" %}</h2>
     {{ doc.toc|safe }}
 </div>
     {% endblock %}
 <div class="box">
-    <h2>Search</h2>
+    <h2>{% trans "Search" %}</h2>
 	<form method="GET" action="{{ search }}">
-	<input type="text" id="q" name="q" /><input type="submit" value="Search" />
+    <input type="text" id="q" name="q" /><input type="submit" value="{% trans "Search" %}" />
 	</form>
 </div>
     {{ block.super }}

sphinxdoc/templates/sphinxdoc/genindex.html

 {% extends 'sphinxdoc/documentation.html' %}
+{% load i18n %}
 
 {% block doc_body %}
-    <h1>General Index</h1>
+    <h1>{% trans "General Index" %}</h1>
     <p class="indexletters">
     {% for letter, _ in doc.genindexentries %}
         <a href="#{{ letter }}">{{ letter }}</a> {% if not forloop.last %} •{% endif %}
                 {% for subname, sublinks in contents.1 %}
         <dd>
             <a href="{{ sublinks.0 }}">{{ subname }}</a>
-                    {% for link in sublinks|slice:"1:" %}, <a href="{{ link }}">[Link]</a>{% endfor %}
+                    {% for link in sublinks|slice:"1:" %}, <a href="{{ link }}">{% trans "[Link]" %}</a>{% endfor %}
         </dd>
                 {% endfor %}
             {% endif %}

sphinxdoc/templates/sphinxdoc/modindex.html

 {% extends 'sphinxdoc/documentation.html' %}
+{% load i18n %}
 
 {% block doc_body %}
-    <h1>Module Index</h1>
+    <h1>{% trans "Module Index" %}</h1>
     <dl>
     {% for modname, collapse, cgroup, indent, fname, synops, pform, dep in doc.modindexentries %}
         <dt><a href="{{ fname }}"><tt class="literal xref">{{ modname }}</tt></a></dt>

sphinxdoc/templates/sphinxdoc/project_list.html

 {% extends 'base.html' %}
+{% load i18n %}
 
-{% block title %}{{ block.super }} » Documentation Overview{% endblock %}
+{% block title %}{{ block.super }} » {% trans "Documentation Overview" %}{% endblock %}
 
 {% block content %}
 <div>
-    <h2 class="pagetitle">Documentation Overview</h2>
+    <h2 class="pagetitle">{% trans "Documentation Overview" %}</h2>
     <ul>
     {% for project in project_list %}
         <li><a href="{{ project.get_absolute_url }}">{{ project.name }}</a></li>

sphinxdoc/templates/sphinxdoc/search.html

 {% extends 'sphinxdoc/documentation.html' %}
+{% load i18n %}
 
 {% block doc_body %}
-<h2>Search results: {{ page.object_list|length }}</h2>
+<h2>{% trans "Search results:" %} {{ page.object_list|length }}</h2>
 <div class="section">
     {% if query %}
     <ul>
         <li><a href="{{ doc.get_absolute_url }}">{{ doc.title|safe }}</a></li>
             {% endwith %}
         {% empty %}
-        <li>No results found.</li>
+        <li>{% trans "No results found." %}</li>
         {% endfor %}
     </ul>
     {% else %}
-    <p>No search query entered.</p>
+    <p>{% trans "No search query entered." %}</p>
     {% endif %}
 </div>
 {% endblock doc_body %}