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
886278db
Commit
886278db
authored
Jul 14, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #778 from phw/checks-can-be-disabled-by-default
Checks can be disabled by default
parents
72d423c8
bcf3895f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
16 deletions
+9
-16
weblate/trans/checks/base.py
weblate/trans/checks/base.py
+5
-0
weblate/trans/checks/format.py
weblate/trans/checks/format.py
+1
-9
weblate/trans/validators.py
weblate/trans/validators.py
+3
-7
No files found.
weblate/trans/checks/base.py
View file @
886278db
...
...
@@ -32,17 +32,22 @@ class Check(object):
target
=
False
source
=
False
ignore_untranslated
=
True
default_disabled
=
False
severity
=
'info'
def
__init__
(
self
):
id_dash
=
self
.
check_id
.
replace
(
'_'
,
'-'
)
self
.
doc_id
=
'check-%s'
%
id_dash
self
.
enable_string
=
id_dash
self
.
ignore_string
=
'ignore-%s'
%
id_dash
def
check_target
(
self
,
sources
,
targets
,
unit
):
'''
Checks target strings.
'''
# Is this disabled by default
if
self
.
default_disabled
and
not
self
.
enable_string
in
unit
.
all_flags
:
return
False
# Is this check ignored
if
self
.
ignore_string
in
unit
.
all_flags
:
return
False
...
...
weblate/trans/checks/format.py
View file @
886278db
...
...
@@ -103,18 +103,14 @@ class BaseFormatCheck(TargetCheck):
'''
Base class for fomat string checks.
'''
flag
=
None
regexp
=
None
default_disabled
=
True
severity
=
'danger'
def
check_target_unit
(
self
,
sources
,
targets
,
unit
):
'''
Checks single unit, handling plurals.
'''
# Verify unit is properly flagged
if
self
.
flag
not
in
unit
.
all_flags
:
return
False
# Special case languages with single plural form
if
len
(
sources
)
>
1
and
len
(
targets
)
==
1
:
return
self
.
check_format
(
...
...
@@ -225,7 +221,6 @@ class PythonFormatCheck(BaseFormatCheck):
check_id
=
'python_format'
name
=
_
(
'Python format'
)
description
=
_
(
'Format string does not match source'
)
flag
=
'python-format'
regexp
=
PYTHON_PRINTF_MATCH
def
is_position_based
(
self
,
string
):
...
...
@@ -239,7 +234,6 @@ class PHPFormatCheck(BaseFormatCheck):
check_id
=
'php_format'
name
=
_
(
'PHP format'
)
description
=
_
(
'Format string does not match source'
)
flag
=
'php-format'
regexp
=
PHP_PRINTF_MATCH
def
is_position_based
(
self
,
string
):
...
...
@@ -253,7 +247,6 @@ class CFormatCheck(BaseFormatCheck):
check_id
=
'c_format'
name
=
_
(
'C format'
)
description
=
_
(
'Format string does not match source'
)
flag
=
'c-format'
regexp
=
C_PRINTF_MATCH
def
is_position_based
(
self
,
string
):
...
...
@@ -267,7 +260,6 @@ class PythonBraceFormatCheck(BaseFormatCheck):
check_id
=
'python_brace_format'
name
=
_
(
'Python brace format'
)
description
=
_
(
'Format string does not match source'
)
flag
=
'python-brace-format'
regexp
=
PYTHON_BRACE_MATCH
def
is_position_based
(
self
,
string
):
...
...
weblate/trans/validators.py
View file @
886278db
...
...
@@ -21,14 +21,10 @@ from django.core.exceptions import ValidationError
from
django.utils.translation
import
ugettext
as
_
,
ugettext_lazy
from
weblate.trans.checks
import
CHECKS
EXTRA_FLAGS
=
{
v
.
enable_string
:
v
.
name
for
k
,
v
in
CHECKS
.
iteritems
()
\
if
v
.
default_disabled
}
EXTRA_FLAGS
=
{
'rst-text'
:
ugettext_lazy
(
'RST text'
),
'python-format'
:
ugettext_lazy
(
'Python format string'
),
'c-format'
:
ugettext_lazy
(
'C format string'
),
'php-format'
:
ugettext_lazy
(
'PHP format string'
),
'python-brace-format'
:
ugettext_lazy
(
'Python brace format string'
),
}
EXTRA_FLAGS
[
'rst-text'
]
=
ugettext_lazy
(
'RST text'
)
IGNORE_CHECK_FLAGS
=
set
([
CHECKS
[
x
].
ignore_string
for
x
in
CHECKS
])
...
...
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