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
6a32f17b
Commit
6a32f17b
authored
Jun 24, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #322 from bertm/patch-2
checks: fix empty source and target strings causing exceptions.
parents
2f4b3c04
34b9164b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
trans/checks/base.py
trans/checks/base.py
+4
-3
trans/checks/chars.py
trans/checks/chars.py
+10
-8
No files found.
trans/checks/base.py
View file @
6a32f17b
...
@@ -65,10 +65,11 @@ class Check(object):
...
@@ -65,10 +65,11 @@ class Check(object):
'''
'''
Generic checker for chars presence.
Generic checker for chars presence.
'''
'''
if
len
(
target
)
==
0
or
len
(
source
)
==
0
:
try
:
src
=
source
[
pos
]
tgt
=
target
[
pos
]
except
:
return
False
return
False
src
=
source
[
pos
]
tgt
=
target
[
pos
]
return
(
return
(
(
src
in
chars
and
tgt
not
in
chars
)
(
src
in
chars
and
tgt
not
in
chars
)
or
(
src
not
in
chars
and
tgt
in
chars
)
or
(
src
not
in
chars
and
tgt
in
chars
)
...
...
trans/checks/chars.py
View file @
6a32f17b
...
@@ -81,9 +81,9 @@ class EndSpaceCheck(TargetCheck):
...
@@ -81,9 +81,9 @@ class EndSpaceCheck(TargetCheck):
# One letter things are usually decimal/thousand separators
# One letter things are usually decimal/thousand separators
if
len
(
source
)
<=
1
and
len
(
target
)
<=
1
:
if
len
(
source
)
<=
1
and
len
(
target
)
<=
1
:
return
False
return
False
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
not
source
or
not
target
:
if
len
(
target
)
==
0
:
return
False
return
False
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
source
[
-
1
]
in
[
':'
,
'!'
,
'?'
]
and
target
[
-
1
]
==
' '
:
if
source
[
-
1
]
in
[
':'
,
'!'
,
'?'
]
and
target
[
-
1
]
==
' '
:
return
False
return
False
...
@@ -106,6 +106,8 @@ class EndStopCheck(TargetCheck):
...
@@ -106,6 +106,8 @@ class EndStopCheck(TargetCheck):
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
if
len
(
source
)
<=
4
and
len
(
target
)
<=
4
:
if
len
(
source
)
<=
4
and
len
(
target
)
<=
4
:
return
False
return
False
if
not
source
:
return
False
if
self
.
is_language
(
unit
,
[
'ja'
])
and
source
[
-
1
]
in
[
':'
,
';'
]:
if
self
.
is_language
(
unit
,
[
'ja'
])
and
source
[
-
1
]
in
[
':'
,
';'
]:
# Japanese sentence might need to end with full stop
# Japanese sentence might need to end with full stop
# in case it's used before list.
# in case it's used before list.
...
@@ -136,9 +138,9 @@ class EndColonCheck(TargetCheck):
...
@@ -136,9 +138,9 @@ class EndColonCheck(TargetCheck):
colon_fr
=
(
' :'
,
' :'
,
u' :'
)
colon_fr
=
(
' :'
,
' :'
,
u' :'
)
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
if
not
source
or
not
target
:
return
False
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
len
(
target
)
==
0
or
len
(
source
)
==
0
:
return
False
if
source
[
-
1
]
==
':'
:
if
source
[
-
1
]
==
':'
:
# Accept variant with trailing space as well
# Accept variant with trailing space as well
if
target
[
-
1
]
==
' '
:
if
target
[
-
1
]
==
' '
:
...
@@ -176,7 +178,7 @@ class EndQuestionCheck(TargetCheck):
...
@@ -176,7 +178,7 @@ class EndQuestionCheck(TargetCheck):
question_el
=
(
'?'
,
';'
,
';'
)
question_el
=
(
'?'
,
';'
,
';'
)
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
if
len
(
target
)
==
0
or
len
(
source
)
==
0
:
if
not
source
or
not
target
:
return
False
return
False
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
source
[
-
1
]
!=
'?'
:
if
source
[
-
1
]
!=
'?'
:
...
@@ -209,15 +211,13 @@ class EndExclamationCheck(TargetCheck):
...
@@ -209,15 +211,13 @@ class EndExclamationCheck(TargetCheck):
exclamation_fr
=
(
' !'
,
' !'
,
u' !'
,
' ! '
,
' ! '
,
u' ! '
)
exclamation_fr
=
(
' !'
,
' !'
,
u' !'
,
' ! '
,
' ! '
,
u' ! '
)
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
if
len
(
source
)
==
0
:
if
not
source
or
not
target
:
return
False
return
False
if
self
.
is_language
(
unit
,
[
'eu'
]):
if
self
.
is_language
(
unit
,
[
'eu'
]):
if
source
[
-
1
]
==
'!'
:
if
source
[
-
1
]
==
'!'
:
if
u'¡'
in
target
and
u'!'
in
target
:
if
u'¡'
in
target
and
u'!'
in
target
:
return
False
return
False
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
self
.
is_language
(
unit
,
[
'fr'
,
'br'
]):
if
len
(
target
)
==
0
:
return
False
if
source
[
-
1
]
==
'!'
:
if
source
[
-
1
]
==
'!'
:
if
target
[
-
2
:]
not
in
self
.
exclamation_fr
:
if
target
[
-
2
:]
not
in
self
.
exclamation_fr
:
return
True
return
True
...
@@ -239,6 +239,8 @@ class EndEllipsisCheck(TargetCheck):
...
@@ -239,6 +239,8 @@ class EndEllipsisCheck(TargetCheck):
description
=
_
(
'Source and translation do not both end with an ellipsis'
)
description
=
_
(
'Source and translation do not both end with an ellipsis'
)
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
def
check_single
(
self
,
source
,
target
,
unit
,
cache_slot
):
if
not
target
:
return
False
# Allow ... to be translated into ellipsis
# Allow ... to be translated into ellipsis
if
source
.
endswith
(
'...'
)
and
target
[
-
1
]
==
u'…'
:
if
source
.
endswith
(
'...'
)
and
target
[
-
1
]
==
u'…'
:
return
False
return
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