Commits

Viliam Segeda  committed 474b9ba

custom rosetta admin templates

  • Participants
  • Parent commits c54a903

Comments (0)

Files changed (3)

File templates/admin/index.html

+{% extends "admin/base_site.html" %}
+{% load i18n admin_static %}
+
+{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}" />{% endblock %}
+
+{% block coltype %}colMS{% endblock %}
+
+{% block bodyclass %}dashboard{% endblock %}
+
+{% block breadcrumbs %}{% endblock %}
+
+{% block content %}
+<div id="content-main">
+
+{% if app_list %}
+    {% for app in app_list %}
+        <div class="module">
+        <table summary="{% blocktrans with name=app.name %}Models available in the {{ name }} application.{% endblocktrans %}">
+        <caption><a href="{{ app.app_url }}" class="section">{% blocktrans with name=app.name %}{{ name }}{% endblocktrans %}</a></caption>
+        {% for model in app.models %}
+            <tr>
+            {% if model.admin_url %}
+                <th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th>
+            {% else %}
+                <th scope="row">{{ model.name }}</th>
+            {% endif %}
+
+            {% if model.add_url %}
+                <td><a href="{{ model.add_url }}" class="addlink">{% trans 'Add' %}</a></td>
+            {% else %}
+                <td>&nbsp;</td>
+            {% endif %}
+
+            {% if model.admin_url %}
+                <td><a href="{{ model.admin_url }}" class="changelink">{% trans 'Change' %}</a></td>
+            {% else %}
+                <td>&nbsp;</td>
+            {% endif %}
+            </tr>
+        {% endfor %}
+        </table>
+        </div>
+    {% endfor %}
+    {% if app_list|length != 1 %}
+        <div class="module">
+            <table>
+                <caption><a class="section">{% trans "System Translations" %}</a></caption>
+                <tr class="row2">
+                    <th scope="row">
+                        <a href="translation/">
+                            {% trans "Translations" %}
+                        </a>
+                    </th>
+                    <td>&nbsp;</td>
+                    <td>&nbsp;</td>
+                </tr>
+            </table>
+        </div>
+    {% endif %}
+{% else %}
+    <p>{% trans "You don't have permission to edit anything." %}</p>
+{% endif %}
+</div>
+{% endblock %}
+
+{% block sidebar %}
+<div id="content-related">
+    <div class="module" id="recent-actions-module">
+        <h2>{% trans 'Recent Actions' %}</h2>
+        <h3>{% trans 'My Actions' %}</h3>
+            {% load log %}
+            {% get_admin_log 10 as admin_log for_user user %}
+            {% if not admin_log %}
+            <p>{% trans 'None available' %}</p>
+            {% else %}
+            <ul class="actionlist">
+            {% for entry in admin_log %}
+            <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
+                {% if entry.is_deletion or not entry.get_admin_url %}
+                    {{ entry.object_repr }}
+                {% else %}
+                    <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
+                {% endif %}
+                <br/>
+                {% if entry.content_type %}
+                    <span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span>
+                {% else %}
+                    <span class="mini quiet">{% trans 'Unknown content' %}</span>
+                {% endif %}
+            </li>
+            {% endfor %}
+            </ul>
+            {% endif %}
+    </div>
+</div>
+{% endblock %}

File templates/rosetta/languages.html

+{% extends "rosetta/base.html" %}
+{% load i18n %}
+
+{% block pagetitle %}{{block.super}} - {% trans "Language selection" %}{% endblock %}
+
+{% block breadcumbs %}
+    {#<div><a href="{% url rosetta-pick-file %}">{% trans "Home" %}</a> &rsaquo; {% trans "Language selection" %}</div>#}
+    <div><a href="/admin/">{% trans "Home" %}</a> &rsaquo; <a href="{% url rosetta-pick-file %}">{% trans "Rosetta" %}</a> &rsaquo;
+    {% trans "Language selection" %}
+    </div>
+    {% if do_session_warn %}<p class="errornote session-warn">{% trans "Couldn't load the specified language file. This usually happens when using the Encrypted Cookies Session Storage backend on Django 1.4 or higher.<br/>Setting ROSETTA_STORAGE_CLASS = 'rosetta.storage.CacheRosettaStorage' in your settings file should fix this." %}</p>{% endif %}
+{% endblock %}
+
+{% block main %}
+    <h1>&nbsp;</h1>
+    <ul class="object-tools">
+        <li class="nobubble">{% trans "Filter" %}:</li>
+        <li{% ifequal rosetta_i18n_catalog_filter 'project' %} class="active"{% endifequal %}><a href="?filter=project">{% trans "Project" %}</a></li>
+        <li{% ifequal rosetta_i18n_catalog_filter 'third-party' %} class="active"{% endifequal %}><a href="?filter=third-party">{% trans "Third party" %}</a></li>
+        <li{% ifequal rosetta_i18n_catalog_filter 'django' %} class="active"{% endifequal %}><a href="?filter=django">Django</a></li>
+        <li{% ifequal rosetta_i18n_catalog_filter 'all' %} class="active"{% endifequal %}><a href="?filter=all">{% trans "All" %}</a></li>
+    </ul>
+
+    {% if has_pos %}
+
+    {% for lid,language,pos in languages %}
+    {% if pos %}
+
+        <div class="module">
+            <h2>{{language}}</h2>
+            <table cellspacing="0">
+                <thead>
+                    <tr>
+                        <th>{% trans "Application" %}</th>
+                        <th class="r">{% trans "Progress"%}</th>
+                        <th class="r">{% trans "Messages" %}</th>
+                        <th class="r">{% trans "Translated" %}</th>
+                        <th class="r">{% trans "Fuzzy"%}</th>
+                        <th class="r">{% trans "Obsolete"%}</th>
+                        <th>{% trans "File" %}</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    {% for app,path,po in pos %}
+                    <tr class="{% cycle row1,row2 %}">
+                        <td><a href="{% url rosetta-language-selection lid,forloop.counter0 %}{% if do_django %}?django{% endif %}{% if do_rosetta %}?rosetta{% endif %}">{{ app|title }}</a></td>
+                        <td class="ch-progress r">{{po.percent_translated|floatformat:2}}%</td>
+                        {% with po.untranslated_entries|length as len_untranslated_entries %}
+                        <td class="ch-messages r">{{po.translated_entries|length|add:len_untranslated_entries}}</td>
+                        {% endwith %}
+                        <td class="ch-translated r">{{po.translated_entries|length}}</td>
+                        <td class="ch-fuzzy r">{{po.fuzzy_entries|length}}</td>
+                        <td class="ch-obsolete r">{{po.obsolete_entries|length}}</td>
+                        <td class="hint">{{ path }}</td>
+                    </tr>
+                    {% endfor %}
+                </tbody>
+            </table>
+        </div>
+    {% endif %}
+    {% endfor %}
+    {% else %}
+    <h1>{% trans "Nothing to translate!" %}</h1>
+    <p>{% trans "You haven't specified any languages in your settings file, or haven't yet generated a batch of translation catalogs." %}</p>
+    <p>{% blocktrans with "http://docs.djangoproject.com/en/dev/topics/i18n/#topics-i18n" as i18n_doc_link  %}Please refer to <a href="{{i18n_doc_link}}">Django's I18N documentation</a> for a guide on how to set up internationalization for your project.{% endblocktrans %}</p>
+    {% endif %}
+{% endblock %}

File templates/rosetta/pofile.html

+{% extends "rosetta/base.html" %}
+{% load rosetta i18n %}
+
+{% block header %}
+    {{block.super}}
+    <div id="user-tools">
+        <p>
+            <span><a href="{% url rosetta-pick-file %}">{% trans "Pick another file" %}</a> /
+            <a href="{% url rosetta-download-file %}">{% trans "Download this catalog" %}</a></span>
+        </p>
+    </div>
+    <script type="text/javascript">
+    </script>
+
+{% endblock %}
+
+{% block pagetitle %}{{block.super}} - {{MESSAGES_SOURCE_LANGUAGE_NAME}} - {{rosetta_i18n_lang_name}} ({{ rosetta_i18n_pofile.percent_translated|floatformat:0 }}%){% endblock %}
+
+{% block breadcumbs %}
+  <div>
+      <a href="/admin/">{% trans "Home" %}</a> &rsaquo;
+      <a href="{% url rosetta-pick-file %}">{% trans "Rosetta" %}</a> &rsaquo;
+      {{ rosetta_i18n_lang_name }} &rsaquo;
+      {{ rosetta_i18n_app|title }} &rsaquo;
+      {% blocktrans with rosetta_i18n_pofile.percent_translated|floatformat:2 as percent_translated  %}Progress: {{ percent_translated }}%{% endblocktrans %}
+      {% if not rosetta_i18n_write %}<p class="errornote read-only">{% trans "File is read-only: download the file when done editing!" %}</p>{% endif %}
+      {% if rosetta_last_save_error %}<p class="errornote save-conflict">{% trans "Some items in your last translation block couldn't be saved: this usually happens when the catalog file changes on disk after you last loaded it." %}</p>{% endif %}
+  </div>
+{% endblock %}
+
+{% block main %}
+    <h1>{% blocktrans  %}Translate into {{rosetta_i18n_lang_name}}{% endblocktrans %}</h1>
+
+    <ul class="object-tools">
+        <li class="nobubble">{% trans "Display:" %}</li>
+        <li {% ifequal rosetta_i18n_filter 'untranslated' %}class="active"{% endifequal %}><a href="?filter=untranslated">{% trans "Untranslated only" %}</a></li>
+        <li {% ifequal rosetta_i18n_filter 'translated' %}class="active"{% endifequal %}><a href="?filter=translated">{% trans "Translated only" %}</a></li>
+        <li {% ifequal rosetta_i18n_filter 'fuzzy' %}class="active"{% endifequal %}><a href="?filter=fuzzy">{% trans "Fuzzy only" %}</a></li>
+        <li {% ifequal rosetta_i18n_filter 'all' %}class="active"{% endifequal %}><a href="?filter=all">{% trans "All" %}</a></li>
+    </ul>
+    <div id="changelist" class="module{% if rosetta_i18n_lang_bidi %} rtl{% endif %}">
+        <div id="toolbar">
+        <form id="changelist-search" action="" method="post">
+            <div><!-- DIV needed for valid HTML -->
+                {% rosetta_csrf_token %}
+                <label for="searchbar"><img src="{{ADMIN_IMAGE_DIR}}/icon_searchbox.png" alt="{% trans "Search" %}" /></label>
+                <input type="text" size="40" name="query" value="{% if query %}{{query}}{% endif %}" id="searchbar" tabindex="0" />
+                <input type="submit" name="search" value="{% trans "Go" %}" />
+            </div>
+        </form>
+        {% comment %}
+        {% if ENABLE_TRANSLATION_SUGGESTIONS %}
+        <form id="translate-all">
+            <div>
+                <input type="submit" class="googleall" value="{% trans "Suggest All Translations" %}" />
+            </div>
+        </form>
+        {% endif %}
+        {% endcomment %}
+        </div>
+
+        <form method="post" action="">
+            <table>
+                <thead>
+                    <tr>
+                        {% rosetta_csrf_token %}
+                        <th><div class="text">{% trans "Original" %}</div></th>
+                        {% if main_language %}<th>{{ main_language }}</th>{% endif %}
+                        <th>{{ rosetta_i18n_lang_name }}</th>
+                        <th class="c"><span class="checkall">[-]</span> {% trans "Fuzzy" %}</th>
+                        <th>{% trans "Occurrences(s)" %}</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    {% for message in rosetta_messages %}
+                    <tr class="{% cycle row1,row2 %}">
+                        {% if message.msgid_plural %}
+                            <td class="original plural">
+                                <div class="plural-container">
+                                    <span class="part">{{message.msgid|format_message|linebreaksbr}}</span>
+                                    <span class="part">{{message.msgid_plural|format_message|linebreaksbr}}</span>
+                                </div>
+
+                                {% if message.msgctxt %}
+                                    <span class="context">{% trans "Context hint" %}: {{message.msgctxt|safe}}</span>
+                                {% else %}
+                                    {% if message.comment %}
+                                    <span class="context">{% trans "Context hint" %}: {{message.comment|safe}}</span>
+                                    {% endif %}
+                                {% endif %}
+
+                            </td>
+                            <td class="translation">
+                                {% for k, msgstr in message.msgstr_plural.items|dictsort:"0"  %}
+                                    <label for="m_{{message.md5hash}}_{{k}}">{{k}}:</label>
+                                    <textarea rows="{{message.msgid|format_message|lines_count}}" cols="40" id="m_{{message.md5hash}}_{{k}}" name="m_{{message.md5hash}}_{{k}}" tabindex="{% increment tab_idx %}">{{msgstr}}</textarea>
+                                {% endfor %}
+                            </td>
+                        {% else %}
+                            <td class="original">
+                                <span class="message">{{ message.msgid|format_message|linebreaksbr }}</span>
+                            {% if message.msgctxt %}
+                                <span class="context">{% trans "Context hint" %}: "{{message.msgctxt|safe}}"</span>
+                                {% else %}
+                                {% if message.comment %}
+                                <span class="context">{% trans "Context hint" %}: {{message.comment|safe}}</span>
+                                {% endif %}
+                            {% endif %}
+                            </td>
+                            {% if main_language %}<td class="original">{{ message.main_lang|format_message|linebreaksbr }}</td>{% endif %}
+                            <td class="translation">
+                                <textarea rows="{{message.msgid|format_message|lines_count}}" cols="40" name="m_{{message.md5hash}}" tabindex="{% increment tab_idx %}">{{message.msgstr}}</textarea>
+                                {% if ENABLE_TRANSLATION_SUGGESTIONS %}<a href="#" class="suggest">{% trans "suggest" %}</a>{% endif %}
+                            </td>
+                        {% endif %}
+                            <td class="c">
+                                <input type="checkbox" name="f_{{message.md5hash}}" value="1" {% if message|is_fuzzy %}checked="checked"{% endif %} />
+                            </td>
+                            <td class="location">
+                                {% for fn,lineno in message.occurrences %}
+                                    <code{% if forloop.counter|gt:"3" %} class="hide"{% endif %}>{{ fn }}:{{lineno}}</code>
+                                {% endfor %}
+                                {% if message.occurrences|length|gt:"3" %}
+                                    <a href="#">&hellip; ({% blocktrans count message.occurrences|length|minus:"3" as more_count %}{{more_count}} more{% plural %}{{more_count}} more{% endblocktrans %})</a>
+                                {% endif %}
+                            </td>
+                    </tr>
+                    {% endfor %}
+                </tbody>
+            </table>
+            <div class="submit-row">
+                <p class="paginator">
+                    {% if query %}
+                        <input type="hidden" name="query" value="{{query}}"  />
+                    {% endif %}
+                    <input type="submit" class="default" name="_next" value="{% trans "Save and translate next block" %}" tabindex="{% increment tab_idx %}"/>
+
+
+                    {% if needs_pagination %}
+                    {% trans "Skip to page:" %}
+                    {% for i in page_range %}
+                        {% ifequal i '...' %}
+                        <span class="space">{{ i }}</span>
+                        {% else %}
+                        {% ifequal i page %}
+                            <span class="this-page">{{i}}</span>
+                        {% else %}
+                            <a href="?page={{i}}{% if query %}&amp;query={{query}}{% endif %}">{{i}}</a>
+                        {% endifequal %}
+                        {% endifequal %}
+                    {% endfor %}
+                    {% else %}
+                    {% trans "Displaying:" %}
+                    {% endif %}
+
+                    {% with paginator.object_list|length as hits %}
+                    <strong>{% blocktrans count rosetta_i18n_pofile|length as message_number %}{{hits}}/{{message_number}} message{% plural %}{{hits}}/{{message_number}} messages{% endblocktrans %}</strong>
+                    {% endwith %}
+
+
+                </p>
+            </div>
+        </form>
+    </div>
+{% endblock %}