Commit cb6cb7ba authored by Michal Čihař's avatar Michal Čihař

Improve page description for project bound pages

Fixes #976
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 6a17be7d
......@@ -29,9 +29,10 @@ from six.moves.urllib.parse import urlparse
from django.core.exceptions import ImproperlyConfigured
from django.core.cache import cache
from django.http import HttpResponseRedirect
from django.shortcuts import resolve_url
from django.shortcuts import resolve_url, render as django_render
from django.conf import settings
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from weblate.logger import LOGGER
from weblate.trans.data import data_dir
......@@ -236,3 +237,21 @@ def report_error(error, exc_info, request=None, extra_data=None):
# Print error when running testsuite
if sys.argv[1:2] == ['test']:
traceback.print_exc()
def get_project_description(project):
"""Returns verbose description for project translation"""
return _(
'{0} is translated into {1} languages using Weblate. '
'Join the translation or start translating your own project.',
).format(
project,
project.get_language_count()
)
def render(request, template, context):
"""Wrapper around Django render to extend context"""
if 'project' in context:
context['description'] = get_project_description(context['project'])
return django_render(request, template, context)
......@@ -22,7 +22,7 @@ import datetime
from six.moves.urllib.parse import urlencode
from django.shortcuts import render, redirect
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.contrib.auth.decorators import login_required
from django.contrib import messages
......@@ -49,6 +49,7 @@ from weblate.trans.views.helper import (
get_project, get_subproject, get_translation,
try_set_language,
)
from weblate.trans.util import render
import weblate
......
......@@ -21,7 +21,7 @@
import csv
import sys
from django.shortcuts import render, get_object_or_404, redirect
from django.shortcuts import get_object_or_404, redirect
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _, ungettext
from django.http import HttpResponse, HttpResponseRedirect
......@@ -37,7 +37,7 @@ from weblate.trans.models import Translation, Dictionary, Change
from weblate.lang.models import Language
from weblate.trans.formats import FileFormat
from weblate.trans.site import get_site_url
from weblate.trans.util import report_error
from weblate.trans.util import report_error, render
from weblate.trans.forms import WordForm, DictUploadForm, LetterForm
from weblate.trans.views.helper import get_project, import_message
import weblate
......
......@@ -23,7 +23,7 @@ from __future__ import unicode_literals
import uuid
import time
from django.shortcuts import render, get_object_or_404, redirect
from django.shortcuts import get_object_or_404, redirect
from django.views.decorators.http import require_POST
from django.utils.translation import ugettext as _, ungettext
from django.utils.encoding import force_text
......@@ -45,7 +45,7 @@ from weblate.trans.forms import (
)
from weblate.trans.views.helper import get_translation, import_message
from weblate.trans.checks import CHECKS
from weblate.trans.util import join_plural
from weblate.trans.util import join_plural, render
from weblate.trans.autotranslate import auto_translate
from weblate.trans.permissions import (
can_translate, can_suggest, can_accept_suggestion, can_delete_suggestion,
......
......@@ -22,7 +22,7 @@ from django.http import Http404
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.exceptions import PermissionDenied
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect, get_object_or_404
from django.shortcuts import redirect, get_object_or_404
from django.utils.translation import ugettext as _
from django.utils.encoding import force_text
from django.views.decorators.http import require_POST
......@@ -33,6 +33,7 @@ from weblate.trans.views.helper import get_subproject
from weblate.trans.models import Translation, Source
from weblate.trans.forms import PriorityForm, CheckFlagsForm
from weblate.trans.permissions import can_edit_flags, can_edit_priority
from weblate.trans.util import render
def get_source(request, project, subproject):
......@@ -87,6 +88,7 @@ def review_source(request, project, subproject):
'source-review.html',
{
'object': obj,
'project': obj.project,
'source': source,
'page_obj': sources,
'query_string': urlencode(query_string),
......@@ -108,6 +110,7 @@ def show_source(request, project, subproject):
'source.html',
{
'object': obj,
'project': obj.project,
'source': source,
'title': _('Source strings in %s') % force_text(obj),
}
......
......@@ -19,7 +19,7 @@
#
from django.http import HttpResponse, Http404
from django.shortcuts import render, redirect
from django.shortcuts import redirect
from django.core.urlresolvers import reverse
from django.views.decorators.cache import cache_page
......@@ -28,6 +28,7 @@ from weblate.lang.models import Language
from weblate.trans.forms import EnageLanguageForm
from weblate.trans.widgets import WIDGETS
from weblate.trans.views.helper import get_project, try_set_language
from weblate.trans.util import render
def widgets_root(request):
......@@ -109,6 +110,7 @@ def widgets(request, project):
'widget_list': widget_list,
'widget_base_url': widget_base_url,
'object': obj,
'project': obj,
'image_src': widget_list[0]['colors'][0]['url'],
'form': form,
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment