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

Propagate flags to checks

parent d8d01d8f
......@@ -3,20 +3,20 @@ from django.utils.translation import ugettext_lazy as _
CHECKS = {}
def plural_check(f):
def _plural_check(sources, targets):
if f(sources[0], targets[0]):
def _plural_check(sources, targets, flags):
if f(sources[0], targets[0], flags):
return True
if len(sources) == 1:
return False
for t in targets[1:]:
if f(sources[1], t):
if f(sources[1], t, flags):
return True
return False
return _plural_check
@plural_check
def check_same(source, target):
def check_same(source, target, flags):
return (source == target)
CHECKS['same'] = (_('Not translated'), check_same, _('Source and translated strings are same'))
......@@ -29,13 +29,13 @@ def check_newline(source, target, pos):
return (s == '\n' and t != '\n') or (s != '\n' and t == '\n')
@plural_check
def check_begin_newline(source, target):
def check_begin_newline(source, target, flags):
return check_newline(source, target, 0)
CHECKS['begin_newline'] = (_('Starting newline'), check_begin_newline, _('Source and translated do not both start with newline'))
@plural_check
def check_end_newline(source, target):
def check_end_newline(source, target, flags):
return check_newline(source, target, -1)
CHECKS['end_newline'] = (_('Trailing newline'), check_end_newline, _('Source and translated do not both end with newline'))
......@@ -572,7 +572,7 @@ class Unit(models.Model):
tgt = self.get_target_plurals()
failing = []
for check in trans.checks.CHECKS:
if trans.checks.CHECKS[check][1](src, tgt):
if trans.checks.CHECKS[check][1](src, tgt, self.flags):
failing.append(check)
for check in self.checks():
......
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