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
8a6f210f
Commit
8a6f210f
authored
Mar 13, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out generic char checker
parent
3a3ddf5f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
trans/checks.py
trans/checks.py
+9
-6
No files found.
trans/checks.py
View file @
8a6f210f
...
@@ -62,24 +62,27 @@ def check_same(source, target, flags, language):
...
@@ -62,24 +62,27 @@ def check_same(source, target, flags, language):
CHECKS
[
'same'
]
=
(
_
(
'Not translated'
),
check_same
,
_
(
'Source and translated strings are same'
))
CHECKS
[
'same'
]
=
(
_
(
'Not translated'
),
check_same
,
_
(
'Source and translated strings are same'
))
# Checks for newlines at beginning/end
def
check_chars
(
source
,
target
,
pos
,
chars
):
'''
def
check_newline
(
source
,
target
,
pos
):
Generic checker for chars presence.
'''
if
len
(
target
)
==
0
:
if
len
(
target
)
==
0
:
return
False
return
False
s
=
source
[
pos
]
s
=
source
[
pos
]
t
=
target
[
pos
]
t
=
target
[
pos
]
return
(
s
==
'
\
n
'
and
t
!=
'
\
n
'
)
or
(
s
!=
'
\
n
'
and
t
==
'
\
n
'
)
return
(
s
in
chars
and
t
not
in
chars
)
or
(
s
not
in
chars
and
t
in
chars
)
# Checks for newlines at beginning/end
@
plural_check
@
plural_check
def
check_begin_newline
(
source
,
target
,
flags
,
language
):
def
check_begin_newline
(
source
,
target
,
flags
,
language
):
return
check_
newline
(
source
,
target
,
0
)
return
check_
chars
(
source
,
target
,
0
,
[
'
\
n
'
]
)
CHECKS
[
'begin_newline'
]
=
(
_
(
'Starting newline'
),
check_begin_newline
,
_
(
'Source and translated do not both start with newline'
))
CHECKS
[
'begin_newline'
]
=
(
_
(
'Starting newline'
),
check_begin_newline
,
_
(
'Source and translated do not both start with newline'
))
@
plural_check
@
plural_check
def
check_end_newline
(
source
,
target
,
flags
,
language
):
def
check_end_newline
(
source
,
target
,
flags
,
language
):
return
check_
newline
(
source
,
target
,
-
1
)
return
check_
chars
(
source
,
target
,
-
1
,
[
'
\
n
'
]
)
CHECKS
[
'end_newline'
]
=
(
_
(
'Trailing newline'
),
check_end_newline
,
_
(
'Source and translated do not both end with newline'
))
CHECKS
[
'end_newline'
]
=
(
_
(
'Trailing newline'
),
check_end_newline
,
_
(
'Source and translated do not both end with newline'
))
...
...
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