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
0e65bfce
Commit
0e65bfce
authored
Jan 25, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify code for highlights formatting
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
03a9715c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
11 deletions
+5
-11
weblate/trans/templatetags/translations.py
weblate/trans/templatetags/translations.py
+5
-11
No files found.
weblate/trans/templatetags/translations.py
View file @
0e65bfce
...
...
@@ -82,15 +82,6 @@ def fmt_whitespace(value):
return
value
def
fmt_check_highlights
(
value
,
unit
):
"""Formats check highlights"""
if
unit
is
None
:
return
[]
#then transform highlights to escaped html
highlights
=
[(
h
[
0
],
h
[
1
],
escape
(
force_text
(
h
[
2
])))
for
h
in
highlight_string
(
value
,
unit
)]
return
highlights
@
register
.
inclusion_tag
(
'format-translation.html'
)
def
format_translation
(
value
,
language
,
diff
=
None
,
search_match
=
None
,
simple
=
False
,
num_plurals
=
2
,
unit
=
None
):
...
...
@@ -118,7 +109,9 @@ def format_translation(value, language, diff=None, search_match=None,
parts
=
[]
for
idx
,
value
in
enumerate
(
plurals
):
highlights
=
fmt_check_highlights
(
value
,
unit
)
highlights
=
[]
if
unit
is
not
None
:
highlights
=
highlight_string
(
value
,
unit
)
# HTML escape
value
=
escape
(
force_text
(
value
))
...
...
@@ -131,7 +124,8 @@ def format_translation(value, language, diff=None, search_match=None,
# Create span for checks highlights
if
highlights
:
start_search
=
0
for
htext
in
[
h
[
2
]
for
h
in
highlights
]:
for
highlight
in
highlights
:
htext
=
escape
(
force_text
(
highlight
[
2
]))
find_highlight
=
value
.
find
(
htext
,
start_search
)
if
find_highlight
>=
0
:
newpart
=
u'<span class="hlcheck">{0}</span>'
.
format
(
htext
)
...
...
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