Skip to content

Commit

Permalink
Add check for zero-width space (issue #146)
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Nov 13, 2012
1 parent afc7f5c commit 9c16b4b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/usage.rst
Expand Up @@ -311,6 +311,14 @@ Mismatched BBcode
BBcode in translation does not match source. The method for detecting BBcode is
currently quite simple.

.. _check-zero-width-space:

Zero-width space
~~~~~~~~~~~~~~~~

Translation contains extra zero-width space (<U+200B>) character. This
character is usually inserted by mistake.

.. _check-optional-plural:

Source checks
Expand Down
1 change: 1 addition & 0 deletions weblate/settings_example.py
Expand Up @@ -338,6 +338,7 @@
'weblate.trans.checks.DirectionCheck',
'weblate.trans.checks.NewlineCountingCheck',
'weblate.trans.checks.BBCodeCheck',
'weblate.trans.checks.ZeroWidthSpaceCheck',
'weblate.trans.checks.OptionalPluralCheck',
'weblate.trans.checks.EllipsisCheck',
)
Expand Down
12 changes: 12 additions & 0 deletions weblate/trans/checks.py
Expand Up @@ -154,6 +154,7 @@
'weblate.trans.checks.DirectionCheck',
'weblate.trans.checks.NewlineCountingCheck',
'weblate.trans.checks.BBCodeCheck',
'weblate.trans.checks.ZeroWidthSpaceCheck',
'weblate.trans.checks.OptionalPluralCheck',
'weblate.trans.checks.EllipsisCheck',
)
Expand Down Expand Up @@ -601,6 +602,17 @@ def check_single(self, source, target, flags, language, unit):
tgt_tags = set([x[0] for x in tgt_match])
return (src_tags != tgt_tags)

class ZeroWidthSpaceCheck(TargetCheck):
'''
Check for zero width space char (<U+200B>).
'''
check_id = 'zero-width-space'
name = _('Zero-width space')
description = _('Translation contains extra zero-width space character')

def check_single(self, source, target, flags, language, unit):
return u'\u200b' in target and not u'\u200b' in source

class OptionalPluralCheck(SourceCheck):
'''
Check for not used plural form.
Expand Down

0 comments on commit 9c16b4b

Please sign in to comment.