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
ce1e6fcb
Commit
ce1e6fcb
authored
Oct 22, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starting whitespace check (issue #127)
parent
49b84234
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
docs/usage.rst
docs/usage.rst
+9
-0
weblate/settings_example.py
weblate/settings_example.py
+1
-0
weblate/trans/checks.py
weblate/trans/checks.py
+25
-0
No files found.
docs/usage.rst
View file @
ce1e6fcb
...
...
@@ -183,6 +183,15 @@ Trailing newline
Source and translated do not both end with a newline.
.. _check-begin_space:
Starting spaces
+++++++++++++++
Source and translation do not both start with same number of spaces. Space in
beginning is usually used for indentation in the interface and thus is
important.
.. _check-end_space:
Trailing space
...
...
weblate/settings_example.py
View file @
ce1e6fcb
...
...
@@ -312,6 +312,7 @@ CHECK_LIST = (
'weblate.trans.checks.SameCheck'
,
'weblate.trans.checks.BeginNewlineCheck'
,
'weblate.trans.checks.EndNewlineCheck'
,
'weblate.trans.checks.BeginSpaceCheck'
,
'weblate.trans.checks.EndSpaceCheck'
,
'weblate.trans.checks.EndStopCheck'
,
'weblate.trans.checks.EndColonCheck'
,
...
...
weblate/trans/checks.py
View file @
ce1e6fcb
...
...
@@ -136,6 +136,7 @@ DEFAULT_CHECK_LIST = (
'
weblate
.
trans
.
checks
.
SameCheck
',
'
weblate
.
trans
.
checks
.
BeginNewlineCheck
',
'
weblate
.
trans
.
checks
.
EndNewlineCheck
',
'
weblate
.
trans
.
checks
.
BeginSpaceCheck
',
'
weblate
.
trans
.
checks
.
EndSpaceCheck
',
'
weblate
.
trans
.
checks
.
EndStopCheck
',
'
weblate
.
trans
.
checks
.
EndColonCheck
',
...
...
@@ -298,6 +299,30 @@ class EndNewlineCheck(Check):
def
check_single
(
self
,
source
,
target
,
flags
,
language
,
unit
):
return
self
.
check_chars
(
source
,
target
,
-
1
,
[
'
\
n
'
])
class
BeginSpaceCheck
(
Check
):
'''
Whitespace check, starting whitespace usually is important for UI
'''
check_id
=
'begin_space'
name
=
_
(
'Starting spaces'
)
description
=
_
(
'Source and translation do not both start with same number of spaces'
)
def
check_single
(
self
,
source
,
target
,
flags
,
language
,
unit
):
# One letter things are usually decimal/thousand separators
if
len
(
source
)
<=
1
and
len
(
target
)
<=
1
:
return
False
# Count space chars in source
cnt
=
0
while
source
[
cnt
]
==
' '
:
cnt
+=
1
# Compare that with target
if
target
[:
cnt
]
!=
' '
*
cnt
:
return
True
return
False
class
EndSpaceCheck
(
Check
):
'''
Whitespace check
...
...
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