mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-05-25 04:33:46 +00:00
Rewrite urls to be RESTful & views to be class-based & less cache-heavy
Previously, state was extensively persisted in the cache. This large-scale rewrite uses the cache only to persist changes to the catalog file when it is read-only. State is now conveyed through the url structure and through query string arguments. The primary downside to this new approach is that there's no explicit way of purging a cached catalog from memory, or refreshing it from what's on disk. The user is forced (untransparently!) to wait until the cached file falls out of the cache (untransparently!), which is currently 24 hours after the last save (or after if the session ends). Addressing this would require some design considerations, and probably some new text that would require its own translation.
This commit is contained in:
parent
1ae24a13a1
commit
d797b76a10
8 changed files with 1324 additions and 822 deletions
|
|
@ -7,11 +7,11 @@
|
|||
<div class="app-rosetta module">
|
||||
<table>
|
||||
<caption>
|
||||
<a class="section" href="{% url 'rosetta-home' %}">Rosetta</a>
|
||||
<a class="section" href="{% url 'rosetta-file-list' po_filter='project' %}">Rosetta</a>
|
||||
</caption>
|
||||
<tbody><tr>
|
||||
<th scope="row"><a href="{% url 'rosetta-home' %}">{% trans "Translations" %}</a></th>
|
||||
<td colspan="2"><a href="{% url 'rosetta-home' %}" class="changelink">{% trans "Change" %}</a></td>
|
||||
<th scope="row"><a href="{% url 'rosetta-file-list' po_filter='project' %}">{% trans "Translations" %}</a></th>
|
||||
<td colspan="2"><a href="{% url 'rosetta-file-list' po_filter='project' %}" class="changelink">{% trans "Change" %}</a></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<div id="header">
|
||||
{% block header %}
|
||||
<div id="branding">
|
||||
<h1 id="site-name"><a href="{% url 'rosetta-pick-file' %}">Rosetta</a> </h1>
|
||||
<h1 id="site-name"><a href="{% url 'rosetta-file-list' po_filter='project' %}">Rosetta</a> </h1>
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
{% block pagetitle %}{{block.super}} - {% trans "Language selection" %}{% endblock %}
|
||||
|
||||
{% block breadcumbs %}
|
||||
<div><a href="{% url 'rosetta-pick-file' %}">{% trans "Home" %}</a> › {% trans "Language selection" %}</div>
|
||||
<div><a href="{% url 'rosetta-file-list' po_filter=po_filter %}">{% trans "Home" %}</a> › {% 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 %}
|
||||
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
<h1> </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>
|
||||
<li{% ifequal po_filter 'project' %} class="active"{% endifequal %}><a href="{% url 'rosetta-file-list' po_filter='project' %}">{% trans "Project" %}</a></li>
|
||||
<li{% ifequal po_filter 'third-party' %} class="active"{% endifequal %}><a href="{% url 'rosetta-file-list' po_filter='third-party' %}">{% trans "Third party" %}</a></li>
|
||||
<li{% ifequal po_filter 'django' %} class="active"{% endifequal %}><a href="{% url 'rosetta-file-list' po_filter='django' %}">Django</a></li>
|
||||
<li{% ifequal po_filter 'all' %} class="active"{% endifequal %}><a href="{% url 'rosetta-file-list' po_filter='all' %}">{% trans "All" %}</a></li>
|
||||
</ul>
|
||||
|
||||
{% if has_pos %}
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<tbody>
|
||||
{% for app,path,po in pos %}
|
||||
<tr class="{% cycle 'row1' 'row2' %}">
|
||||
<td><a href="{% url 'rosetta-language-selection' lid forloop.counter0 %}">{{ app|title }}</a></td>
|
||||
<td><a href="{% url 'rosetta-form' po_filter=po_filter lang_id=lid idx=forloop.counter0 %}">{{ app|title }}</a></td>
|
||||
<td class="ch-progress r">{{po.percent_translated}}%</td>
|
||||
{% with po.untranslated_entries|length as len_untranslated_entries %}
|
||||
<td class="ch-messages r">{{po.translated_entries|length|add:len_untranslated_entries}}</td>
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
{{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>
|
||||
<span><a href="{% url 'rosetta-file-list' po_filter=po_filter %}">{% trans "Pick another file" %}</a> /
|
||||
<a href="{% url 'rosetta-download-file' po_filter=po_filter lang_id=lang_id idx=idx %}">{% trans "Download this catalog" %}</a></span>
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
|
@ -18,13 +18,12 @@
|
|||
|
||||
{% block breadcumbs %}
|
||||
<div>
|
||||
<a href="{% url 'rosetta-pick-file' %}">{% trans "Home" %}</a> ›
|
||||
<a href="{% url 'rosetta-file-list' po_filter=po_filter %}">{% trans "Home" %}</a> ›
|
||||
{{ rosetta_i18n_lang_name }} ›
|
||||
{{ rosetta_i18n_app|title }} ›
|
||||
{% blocktrans with rosetta_i18n_pofile.percent_translated as percent_translated %}Progress: {{ percent_translated }}%{% endblocktrans %}
|
||||
</div>
|
||||
{% 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 %}
|
||||
{% if messages %}
|
||||
<div class="messages errornote save-conflict">
|
||||
{% for message in messages %}
|
||||
|
|
@ -39,31 +38,30 @@
|
|||
|
||||
<ul class="object-tools">
|
||||
<li class="nobubble">{% trans "Display:" %}</li>
|
||||
<li {% if rosetta_i18n_filter == 'untranslated' %}class="active"{% endif %}><a href="?filter=untranslated">{% trans "Untranslated only" %}</a></li>
|
||||
<li {% if rosetta_i18n_filter == 'translated' %}class="active"{% endif %}><a href="?filter=translated">{% trans "Translated only" %}</a></li>
|
||||
<li {% if rosetta_i18n_filter == 'fuzzy' %}class="active"{% endif %}><a href="?filter=fuzzy">{% trans "Fuzzy only" %}</a></li>
|
||||
<li {% if rosetta_i18n_filter == 'all' %}class="active"{% endif %}><a href="?filter=all">{% trans "All" %}</a></li>
|
||||
<li {% if rosetta_i18n_filter == 'untranslated' %}class="active"{% endif %}><a href="?{{ filter_query_string_base }}&msg_filter=untranslated">{% trans "Untranslated only" %}</a></li>
|
||||
<li {% if rosetta_i18n_filter == 'translated' %}class="active"{% endif %}><a href="?{{ filter_query_string_base }}&msg_filter=translated">{% trans "Translated only" %}</a></li>
|
||||
<li {% if rosetta_i18n_filter == 'fuzzy' %}class="active"{% endif %}><a href="?{{ filter_query_string_base }}&msg_filter=fuzzy">{% trans "Fuzzy only" %}</a></li>
|
||||
<li {% if rosetta_i18n_filter == 'all' %}class="active"{% endif %}><a href="?{{ filter_query_string_base }}&msg_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">
|
||||
<form id="changelist-search" action="" method="get">
|
||||
<div>
|
||||
{% rosetta_csrf_token %}
|
||||
<label for="searchbar"><img src="{% static "admin/img/icon_searchbox_rosetta.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" %}" />
|
||||
<input type="text" size="40" name="query" value="{{query}}" id="searchbar" tabindex="0" />
|
||||
<input type="submit" name="s" value="{% trans "Go" %}" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if ENABLE_REFLANG %}
|
||||
{% if rosetta_settings.ENABLE_REFLANG %}
|
||||
<div class="actions">
|
||||
<label for="ref-language-selector">{% trans "Reference language" %}:</label>
|
||||
<select class="select-across" id="ref-language-selector" onchange="javascript:window.location.href = this.value;">
|
||||
{% for langid, langname in LANGUAGES %}
|
||||
<option{% ifequal ref_lang langid %} selected="selected"{% endifequal %} value="{% url 'rosetta-reference-selection' langid=langid %}">{{langname}}</option>
|
||||
<option{% ifequal ref_lang langid %} selected="selected"{% endifequal %} value="?ref_lang={{ langid }}">{{langname}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
@ -108,7 +106,7 @@
|
|||
</td>
|
||||
{% else %}
|
||||
<td class="original">
|
||||
{% if ENABLE_REFLANG %}
|
||||
{% if rosetta_settings.ENABLE_REFLANG %}
|
||||
<span class="message">{{ message.ref_txt|format_message|linebreaksbr }}</span>
|
||||
{% else %}
|
||||
<span class="message">{{ message.msgid|format_message|linebreaksbr }}</span>
|
||||
|
|
@ -159,7 +157,7 @@
|
|||
{% if i == page %}
|
||||
<span class="this-page">{{i}}</span>
|
||||
{% else %}
|
||||
<a href="?page={{i}}{% if query %}&query={{query}}{% endif %}">{{i}}</a>
|
||||
<a href="?{{ pagination_query_string_base }}&page={{i}}">{{i}}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
170
rosetta/tests/django.po.test44.template
Normal file
170
rosetta/tests/django.po.test44.template
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Rosetta\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2009-10-21 12:21+0200\n"
|
||||
"PO-Revision-Date: 2008-09-22 11:02\n"
|
||||
"Last-Translator: Admin Admin <admin@admin.com>\n"
|
||||
"Language-Team: French <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Translated-Using: django-rosetta 0.4.RC2\n"
|
||||
|
||||
|
||||
msgid "String 1"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 2"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 3"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 4"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 5"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 6"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 7"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 8"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 9"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 10"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 11"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 12"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 13"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 14"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 15"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 16"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 17"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 18"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 19"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 20"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 21"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 22"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 23"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 24"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 25"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 26"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 27"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 28"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 29"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 30"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 31"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 32"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 33"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 34"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 35"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 36"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 37"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 38"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 39"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 40"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 41"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 42"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 43"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 44"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 45"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 46"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 47"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 48"
|
||||
msgstr ""
|
||||
|
||||
msgid "String 49"
|
||||
msgstr ""
|
||||
|
||||
#. Translators: consectetur adipisicing
|
||||
#: templates/eiusmod/tempor.html:43
|
||||
msgid "Lorem ipsum"
|
||||
msgstr "dolor sit amet"
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,11 +1,45 @@
|
|||
from django.conf.urls import url
|
||||
from .views import (home, list_languages, download_file, lang_sel, translate_text, ref_sel)
|
||||
from django.views.generic.base import RedirectView
|
||||
try:
|
||||
from django.urls import reverse_lazy
|
||||
except ImportError:
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', home, name='rosetta-home'),
|
||||
url(r'^pick/$', list_languages, name='rosetta-pick-file'),
|
||||
url(r'^download/$', download_file, name='rosetta-download-file'),
|
||||
url(r'^select/(?P<langid>[\w\-_\.]+)/(?P<idx>\d+)/$', lang_sel, name='rosetta-language-selection'),
|
||||
url(r'^select-ref/(?P<langid>[\w\-_\.]+)/$', ref_sel, name='rosetta-reference-selection'),
|
||||
url(r'^translate/$', translate_text, name='translate_text'),
|
||||
|
||||
url(r'^$',
|
||||
RedirectView.as_view(url=reverse_lazy('rosetta-file-list',
|
||||
kwargs={'po_filter': 'project'})),
|
||||
name='rosetta-old-home-redirect',
|
||||
),
|
||||
|
||||
url(r'^files/$',
|
||||
RedirectView.as_view(url=reverse_lazy('rosetta-file-list',
|
||||
kwargs={'po_filter': 'project'})),
|
||||
name='rosetta-file-list-redirect',
|
||||
),
|
||||
|
||||
url(r'^files/(?P<po_filter>[\w-]+)/$',
|
||||
views.TranslationFileListView.as_view(),
|
||||
name='rosetta-file-list',
|
||||
),
|
||||
|
||||
url(r'^files/(?P<po_filter>[\w-]+)/(?P<lang_id>[\w\-_\.]+)/(?P<idx>\d+)/$',
|
||||
views.TranslationFormView.as_view(),
|
||||
name='rosetta-form',
|
||||
),
|
||||
|
||||
url(r'^files/(?P<po_filter>[\w-]+)/(?P<lang_id>[\w\-_\.]+)/(?P<idx>\d+)/download/$',
|
||||
views.TranslationFileDownload.as_view(),
|
||||
name='rosetta-download-file',
|
||||
),
|
||||
|
||||
url(r'^translate/$',
|
||||
views.translate_text,
|
||||
name='translate_text',
|
||||
),
|
||||
|
||||
]
|
||||
|
|
|
|||
1017
rosetta/views.py
1017
rosetta/views.py
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue