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
aa570e8e
Commit
aa570e8e
authored
Jul 14, 2015
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
561db89f
91179572
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
weblate/trans/autofixes/whitespace.py
weblate/trans/autofixes/whitespace.py
+8
-4
No files found.
weblate/trans/autofixes/whitespace.py
View file @
aa570e8e
...
...
@@ -22,6 +22,10 @@ import re
from
django.utils.translation
import
ugettext_lazy
as
_
from
weblate.trans.autofixes.base
import
AutoFix
NEWLINES
=
re
.
compile
(
r'\r\n|\r|\n'
)
START
=
re
.
compile
(
r'^(\
s+)
', re.UNICODE)
END = re.compile(r'
(
\
s
+
)
$
', re.UNICODE)
class SameBookendingWhitespace(AutoFix):
'''
...
...
@@ -32,17 +36,17 @@ class SameBookendingWhitespace(AutoFix):
def fix_single_target(self, target, source, unit):
# normalize newlines of source
source
=
re
.
compile
(
r'\r\n|\r|\n'
)
.
sub
(
'
\
n
'
,
source
)
source =
NEWLINES
.sub('
\
n
', source)
# capture preceding and tailing whitespace
start
=
re
.
compile
(
r'^(\
s+)
')
.search(source)
end =
re.compile(r'
(
\
s
+
)
$
')
.search(source)
start =
START
.search(source)
end =
END
.search(source)
head = start.group() if start else ''
tail = end.group() if end else ''
# add the whitespace around the target translation (ignore blanks)
stripped = target.strip()
if stripped:
newtarget =
'
%
s
%
s
%
s
' % (head, stripped, tail
)
newtarget =
u''.join((head, stripped, tail)
)
return newtarget, newtarget != target
return target, False
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