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
842137a5
Commit
842137a5
authored
Mar 12, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move checks definition to separate file and actually do checks
parent
21079844
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
3 deletions
+36
-3
trans/checks.py
trans/checks.py
+10
-0
trans/models.py
trans/models.py
+26
-3
No files found.
trans/checks.py
0 → 100644
View file @
842137a5
from
django.utils.translation
import
ugettext_lazy
as
_
CHECKS
=
[]
def
check_same
(
sources
,
targets
):
if
sources
[
0
]
==
targets
[
0
]:
return
True
return
False
CHECKS
.
append
((
'same'
,
_
(
'Not translated'
),
check_same
))
trans/models.py
View file @
842137a5
...
...
@@ -19,6 +19,7 @@ from translate.storage import poheader
from
datetime
import
datetime
import
trans
import
trans.checks
from
trans.managers
import
TranslationManager
,
UnitManager
from
util
import
is_plural
,
split_plural
,
join_plural
...
...
@@ -530,6 +531,7 @@ class Unit(models.Model):
logger
.
error
(
'Unit.save called without backend sync: %s'
,
''
.
join
(
traceback
.
format_stack
()))
else
:
del
kwargs
[
'backend'
]
self
.
check
()
super
(
Unit
,
self
).
save
(
*
args
,
**
kwargs
)
def
get_location_links
(
self
):
...
...
@@ -565,6 +567,29 @@ class Unit(models.Model):
ignore
=
False
)
def
check
(
self
):
src
=
self
.
get_source_plurals
()
tgt
=
self
.
get_target_plurals
()
failing
=
[]
for
check
in
trans
.
checks
.
CHECKS
:
if
check
[
2
](
src
,
tgt
):
failing
.
append
(
check
[
0
])
for
check
in
self
.
checks
():
if
check
.
check
in
failing
:
failing
.
remove
(
check
.
check
)
continue
check
.
delete
()
for
check
in
failing
:
Check
.
objects
.
create
(
checksum
=
self
.
checksum
,
project
=
self
.
translation
.
subproject
.
project
,
language
=
self
.
translation
.
language
,
ignore
=
False
,
check
=
check
)
class
Suggestion
(
models
.
Model
):
checksum
=
models
.
CharField
(
max_length
=
40
,
default
=
''
,
blank
=
True
,
db_index
=
True
)
target
=
models
.
TextField
()
...
...
@@ -583,9 +608,7 @@ class Suggestion(models.Model):
unit
.
fuzzy
=
False
unit
.
save_backend
(
request
,
False
)
CHECK_CHOICES
=
(
(
'same'
,
ugettext_lazy
(
'Not translated'
)),
)
CHECK_CHOICES
=
[(
x
[
0
],
x
[
1
])
for
x
in
trans
.
checks
.
CHECKS
]
class
Check
(
models
.
Model
):
checksum
=
models
.
CharField
(
max_length
=
40
,
default
=
''
,
blank
=
True
,
db_index
=
True
)
...
...
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