Commit ac4fbf6e authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 5695aa53 9937cf64
......@@ -34,6 +34,7 @@ Released on ? 2015.
* Added quality check for AngularJS interpolation.
* Added extensive group based ACLs.
* Clarified terminology on strings needing review (formerly fuzzy).
* Clarified terminology on strings needing action and not translated strings.
weblate 2.4
-----------
......
......@@ -116,7 +116,7 @@
<div class="panel-body">
<div class="list-group">
{% for c in object.get_translation_checks %}
<a class="list-group-item list-group-item-{{ c.3 }}" href="{{ object.get_translate_url }}?type={{ c.0 }}"><span class="badge">{{ c.2 }}</span>{{ c.1 }}</a>
<a class="list-group-item list-group-item-{{ c.3 }}" href="{{ object.get_translate_url }}?type={{ c.0 }}">{% if c.4 %}<span class="badge">{% blocktrans count c.4 as count %}{{ count }} word{% plural %}{{ count }} words{% endblocktrans %}</span>{% endif %}<span class="badge">{{ c.2 }}</span>{{ c.1 }}</a>
{% endfor %}
</div>
</div>
......
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2016 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
class TranslationChecklist(list):
"""Simple list wrapper for translation checklist"""
def add_if(self, name, label, count, level, words=None):
"""Add to list if there are matches"""
if count > 0:
self.add(name, label, count, level, words)
def add(self, name, label, count, level, words=None):
"""Adds item to the list"""
if words is not None:
self.append((name, label, count, level, words))
else:
self.append((name, label, count, level))
......@@ -47,6 +47,7 @@ from weblate.trans.mixins import URLMixin, PercentMixin, LoggerMixin
from weblate.trans.boolean_sum import BooleanSum
from weblate.accounts.models import notify_new_string, get_author_name
from weblate.trans.models.changes import Change
from weblate.trans.checklists import TranslationChecklist
class TranslationManager(models.Manager):
......@@ -926,47 +927,41 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
'''
Returns list of failing source checks on current subproject.
'''
result = [
(
'all',
_('All strings'),
self.total,
'success',
)
]
result = TranslationChecklist()
result.add(
'all',
_('All strings'),
self.total,
'success',
)
# All checks
sourcechecks = self.unit_set.count_type('sourcechecks', self)
if sourcechecks > 0:
result.append((
'sourcechecks',
_('Strings with any failing checks'),
sourcechecks,
'danger',
))
result.add_if(
'sourcechecks',
_('Strings with any failing checks'),
self.unit_set.count_type('sourcechecks', self),
'danger',
)
# Process specific checks
for check in CHECKS:
if not CHECKS[check].source:
check_obj = CHECKS[check]
if not check_obj.source:
continue
cnt = self.unit_set.count_type(check, self)
if cnt > 0:
result.append((
check,
CHECKS[check].description,
cnt,
CHECKS[check].severity,
))
result.add_if(
check,
check_obj.description,
self.unit_set.count_type(check, self),
check_obj.severity,
)
# Grab comments
sourcecomments = self.unit_set.count_type('sourcecomments', self)
if sourcecomments > 0:
result.append((
'sourcecomments',
_('Strings with comments'),
sourcecomments,
'info',
))
result.add_if(
'sourcecomments',
_('Strings with comments'),
self.unit_set.count_type('sourcecomments', self),
'info',
)
return result
......@@ -974,92 +969,88 @@ class Translation(models.Model, URLMixin, PercentMixin, LoggerMixin):
'''
Returns list of failing checks on current translation.
'''
result = [
(
'all',
_('All strings'),
self.total,
'success',
)
]
result = TranslationChecklist()
# All strings
result.add(
'all',
_('All strings'),
self.total,
'success',
self.total_words
)
# Count of translated strings
if self.translated > 0:
result.append((
'translated',
_('Translated strings'),
self.translated,
'success',
))
result.add_if(
'translated',
_('Translated strings'),
self.translated,
'success',
self.translated_words,
)
# Not translated strings
result.add_if(
'nottranslated',
_('Not translated strings'),
self.total - self.translated - self.fuzzy,
'danger',
self.total_words - self.translated_words - self.fuzzy_words,
)
# Untranslated strings
nottranslated = self.total - self.translated
if nottranslated > 0:
result.append((
'untranslated',
_('Untranslated strings'),
nottranslated,
'danger',
))
# Untranslated words, the link is same, just to show number of words
nottranslated = self.total_words - self.translated_words
if nottranslated > 0:
result.append((
'untranslated',
_('Untranslated words'),
nottranslated,
'danger',
))
result.add_if(
'todo',
_('Strings needing attention'),
self.total - self.translated,
'danger',
self.total_words - self.translated_words,
)
# Fuzzy strings
if self.fuzzy > 0:
result.append((
'fuzzy',
_('Strings needing review'),
self.fuzzy,
'danger',
))
result.add_if(
'fuzzy',
_('Strings needing review'),
self.fuzzy,
'danger',
self.fuzzy_words,
)
# Translations with suggestions
if self.have_suggestion > 0:
result.append((
'suggestions',
_('Strings with suggestions'),
self.have_suggestion,
'info',
))
result.add_if(
'suggestions',
_('Strings with suggestions'),
self.have_suggestion,
'info',
)
# All checks
if self.failing_checks > 0:
result.append((
'allchecks',
_('Strings with any failing checks'),
self.failing_checks,
'danger',
))
result.add_if(
'allchecks',
_('Strings with any failing checks'),
self.failing_checks,
'danger',
)
# Process specific checks
for check in CHECKS:
if not CHECKS[check].target:
check_obj = CHECKS[check]
if not check_obj.target:
continue
cnt = self.unit_set.count_type(check, self)
if cnt > 0:
result.append((
check,
CHECKS[check].description,
cnt,
CHECKS[check].severity,
))
result.add_if(
check,
check_obj.description,
self.unit_set.count_type(check, self),
check_obj.severity,
)
# Grab comments
if self.have_comment > 0:
result.append((
'comments',
_('Strings with comments'),
self.have_comment,
'info',
))
result.add_if(
'comments',
_('Strings with comments'),
self.have_comment,
'info',
)
return result
......
......@@ -50,6 +50,8 @@ from weblate.trans.util import (
SIMPLE_FILTERS = {
'fuzzy': {'fuzzy': True},
'untranslated': {'translated': False},
'todo': {'translated': False},
'nottranslated': {'translated': False, 'fuzzy': False},
'translated': {'translated': True},
'suggestions': {'has_suggestion': True},
'comments': {'has_comment': True},
......
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