Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
e8952931
Commit
e8952931
authored
Oct 30, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more structure to check objects
parent
c017a780
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
24 deletions
+29
-24
docs/admin.rst
docs/admin.rst
+4
-4
weblate/trans/checks.py
weblate/trans/checks.py
+25
-20
No files found.
docs/admin.rst
View file @
e8952931
...
...
@@ -349,10 +349,10 @@ contain string "foo".
.. code-block:: python
from weblate.trans.checks import Check
from weblate.trans.checks import
Target
Check
from django.utils.translation import ugettext_lazy as _
class FooCheck(Check):
class FooCheck(
Target
Check):
# Used as identifier for check, should be unique
check_id = 'foo'
...
...
@@ -375,10 +375,10 @@ language are not same.
.. code-block:: python
from weblate.trans.checks import Check
from weblate.trans.checks import
Target
Check
from django.utils.translation import ugettext_lazy as _
class PluralCzechCheck(Check):
class PluralCzechCheck(
Target
Check):
# Used as identifier for check, should be unique
check_id = 'foo'
...
...
weblate/trans/checks.py
View file @
e8952931
...
...
@@ -160,7 +160,7 @@ class Check(object):
check_id = ''
name = ''
description = ''
target =
Tru
e
target =
Fals
e
source = False
def check(self, sources, targets, flags, language, unit):
...
...
@@ -238,9 +238,14 @@ class Check(object):
self
.
check_id
,
)
class
TargetCheck
(
Check
):
'''
Basic class for target checks.
'''
target
=
True
class
SameCheck
(
Check
):
class
SameCheck
(
Target
Check
):
'''
Check for not translated entries.
'''
...
...
@@ -285,7 +290,7 @@ class SameCheck(Check):
return
(
source
==
target
)
class
BeginNewlineCheck
(
Check
):
class
BeginNewlineCheck
(
Target
Check
):
'''
Checks for newlines at beginning.
'''
...
...
@@ -296,7 +301,7 @@ class BeginNewlineCheck(Check):
def
check_single
(
self
,
source
,
target
,
flags
,
language
,
unit
):
return
self
.
check_chars
(
source
,
target
,
0
,
[
'
\
n
'
])
class
EndNewlineCheck
(
Check
):
class
EndNewlineCheck
(
Target
Check
):
'''
Checks for newlines at end.
'''
...
...
@@ -307,7 +312,7 @@ class EndNewlineCheck(Check):
def
check_single
(
self
,
source
,
target
,
flags
,
language
,
unit
):
return
self
.
check_chars
(
source
,
target
,
-
1
,
[
'
\
n
'
])
class
BeginSpaceCheck
(
Check
):
class
BeginSpaceCheck
(
Target
Check
):
'''
Whitespace check, starting whitespace usually is important for UI
'''
...
...
@@ -331,7 +336,7 @@ class BeginSpaceCheck(Check):
return
False
class
EndSpaceCheck
(
Check
):
class
EndSpaceCheck
(
Target
Check
):
'''
Whitespace check
'''
...
...
@@ -350,7 +355,7 @@ class EndSpaceCheck(Check):
return
False
return
self
.
check_chars
(
source
,
target
,
-
1
,
[
' '
])
class
EndStopCheck
(
Check
):
class
EndStopCheck
(
Target
Check
):
'''
Check for final stop
'''
...
...
@@ -368,7 +373,7 @@ class EndStopCheck(Check):
return
self
.
check_chars
(
source
,
target
,
-
1
,
[
u'.'
,
u'。'
,
u'।'
,
u'۔'
])
class
EndColonCheck
(
Check
):
class
EndColonCheck
(
Target
Check
):
'''
Check for final colon
'''
...
...
@@ -393,7 +398,7 @@ class EndColonCheck(Check):
return
self
.
check_chars
(
source
,
target
,
-
1
,
[
u':'
,
u':'
])
class
EndQuestionCheck
(
Check
):
class
EndQuestionCheck
(
Target
Check
):
'''
Check for final question mark
'''
...
...
@@ -411,7 +416,7 @@ class EndQuestionCheck(Check):
return
False
return
self
.
check_chars
(
source
,
target
,
-
1
,
[
u'?'
,
u'՞'
,
u'؟'
,
u'⸮'
,
u'?'
,
u'፧'
,
u'꘏'
,
u'⳺'
])
class
EndExclamationCheck
(
Check
):
class
EndExclamationCheck
(
Target
Check
):
'''
Check for final exclamation mark
'''
...
...
@@ -435,7 +440,7 @@ class EndExclamationCheck(Check):
return
False
return
self
.
check_chars
(
source
,
target
,
-
1
,
[
u'!'
,
u'!'
,
u'՜'
,
u'᥄'
,
u'႟'
,
u'߹'
])
class
EndElipsisCheck
(
Check
):
class
EndElipsisCheck
(
Target
Check
):
'''
Check for elipsis at the end of string.
'''
...
...
@@ -449,7 +454,7 @@ class EndElipsisCheck(Check):
# For now all format string checks use generic implementation, but
# it should be switched to language specific
class
PythonFormatCheck
(
Check
):
class
PythonFormatCheck
(
Target
Check
):
'''
Check for Python format string
'''
...
...
@@ -462,7 +467,7 @@ class PythonFormatCheck(Check):
return
False
return
self
.
check_format_strings
(
source
,
target
,
PYTHON_PRINTF_MATCH
)
class
PHPFormatCheck
(
Check
):
class
PHPFormatCheck
(
Target
Check
):
'''
Check for PHP format string
'''
...
...
@@ -475,7 +480,7 @@ class PHPFormatCheck(Check):
return
False
return
self
.
check_format_strings
(
source
,
target
,
PHP_PRINTF_MATCH
)
class
CFormatCheck
(
Check
):
class
CFormatCheck
(
Target
Check
):
'''
Check for C format string
'''
...
...
@@ -489,7 +494,7 @@ class CFormatCheck(Check):
return
self
.
check_format_strings
(
source
,
target
,
C_PRINTF_MATCH
)
class
PluralsCheck
(
Check
):
class
PluralsCheck
(
Target
Check
):
'''
Check for incomplete plural forms
'''
...
...
@@ -507,7 +512,7 @@ class PluralsCheck(Check):
# Check for empty translation
return
(
''
in
targets
)
class
ConsistencyCheck
(
Check
):
class
ConsistencyCheck
(
Target
Check
):
'''
Check for inconsistent translations
'''
...
...
@@ -532,7 +537,7 @@ class ConsistencyCheck(Check):
return
False
class
DirectionCheck
(
Check
):
class
DirectionCheck
(
Target
Check
):
'''
Check for text direction values
'''
...
...
@@ -548,7 +553,7 @@ class DirectionCheck(Check):
return
False
return
not
targets
[
0
].
lower
()
in
[
'ltr'
,
'rtl'
]
class
CountingCheck
(
Check
):
class
CountingCheck
(
Target
Check
):
'''
Check whether there is same count of given string.
'''
...
...
@@ -559,7 +564,7 @@ class CountingCheck(Check):
return
False
return
source
.
count
(
self
.
string
)
!=
target
.
count
(
self
.
string
)
class
NewlineCountingCheck
(
Check
):
class
NewlineCountingCheck
(
Target
Check
):
'''
Check whether there is same amount of
\
n
strings
'''
...
...
@@ -568,7 +573,7 @@ class NewlineCountingCheck(Check):
name
=
_
(
'Mismatched
\
\
n'
)
description
=
_
(
'Number of
\
\
n in translation does not match source'
)
class
BBCodeCheck
(
Check
):
class
BBCodeCheck
(
Target
Check
):
'''
Check for matching bbcode tags.
'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment