Grab unit to translate
This commit is contained in:
parent
d293d97ecd
commit
d2ef58f523
@ -40,3 +40,11 @@ class UnitManager(models.Manager):
|
|||||||
|
|
||||||
dbunit.update_from_unit(unit, force)
|
dbunit.update_from_unit(unit, force)
|
||||||
return dbunit
|
return dbunit
|
||||||
|
|
||||||
|
def filter_type(self, rqtype):
|
||||||
|
if rqtype == 'all':
|
||||||
|
return self.all()
|
||||||
|
elif rqtype == 'fuzzy':
|
||||||
|
return self.filter(fuzzy = True)
|
||||||
|
elif rqtype == 'untranslated':
|
||||||
|
return self.filter(translated = False)
|
||||||
|
@ -276,8 +276,8 @@ class Translation(models.Model):
|
|||||||
Returns list of failing checks on current translation.
|
Returns list of failing checks on current translation.
|
||||||
'''
|
'''
|
||||||
result = []
|
result = []
|
||||||
nottranslated = self.unit_set.filter(translated = False).count()
|
nottranslated = self.unit_set.filter_type('untranslated').count()
|
||||||
fuzzy = self.unit_set.filter(fuzzy = True).count()
|
fuzzy = self.unit_set.filter_type('fuzzy').count()
|
||||||
if nottranslated > 0:
|
if nottranslated > 0:
|
||||||
result.append(('untranslated', _('Not translated strings (%d)') % nottranslated))
|
result.append(('untranslated', _('Not translated strings (%d)') % nottranslated))
|
||||||
if fuzzy > 0:
|
if fuzzy > 0:
|
||||||
|
@ -30,9 +30,16 @@ def show_translation(request, project, subproject, lang):
|
|||||||
def translate(request, project, subproject, lang):
|
def translate(request, project, subproject, lang):
|
||||||
obj = get_object_or_404(Translation, language__code = lang, subproject__slug = subproject, subproject__project__slug = project)
|
obj = get_object_or_404(Translation, language__code = lang, subproject__slug = subproject, subproject__project__slug = project)
|
||||||
|
|
||||||
|
rqtype = request.REQUEST.get('type', 'all')
|
||||||
|
offset = request.REQUEST.get('offset', '0')
|
||||||
|
try:
|
||||||
|
offset = int(offset)
|
||||||
|
except:
|
||||||
|
offset = 0
|
||||||
|
units = obj.unit_set.filter_type(rqtype)
|
||||||
|
|
||||||
return render_to_response('translate.html', RequestContext(request, {
|
return render_to_response('translate.html', RequestContext(request, {
|
||||||
'object': obj,
|
'object': obj,
|
||||||
'title': '%s @ Weblate' % (obj.__unicode__()),
|
'title': '%s @ Weblate' % (obj.__unicode__()),
|
||||||
|
'unit': units[offset],
|
||||||
}))
|
}))
|
||||||
|
Loading…
Reference in New Issue
Block a user