Commit 8a511d26 authored by Michal Čihař's avatar Michal Čihař

Add check for newlines

parent e478dab1
......@@ -323,6 +323,7 @@ CHECK_LIST = (
'weblate.trans.checks.PluralsCheck',
'weblate.trans.checks.ConsistencyCheck',
'weblate.trans.checks.DirectionCheck',
'weblate.trans.checks.NewlineCountingCheck',
)
# E-mail address that error messages come from.
......
......@@ -145,6 +145,7 @@ DEFAULT_CHECK_LIST = (
'weblate.trans.checks.PluralsCheck',
'weblate.trans.checks.ConsistencyCheck',
'weblate.trans.checks.DirectionCheck',
'weblate.trans.checks.NewlineCountingCheck',
)
class Check(object):
......@@ -495,6 +496,26 @@ class DirectionCheck(Check):
return False
return not targets[0].lower() in ['ltr', 'rtl']
class CountingCheck(Check):
'''
Check whether there is same count of given string.
'''
string = None
def check_single(self, source, target, flags, language, unit):
if len(target) == 0:
return False
return source.count(self.string) != target.count(self.string)
class NewlineCountingCheck(Check):
'''
Check whether there is same amount of \n strings
'''
string = '\\n'
check_id = 'escaped_newline'
name = _('Mismatched \\n')
description = _('Number of \\n in translation does not match source')
# Initialize checks list
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