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
7080d388
Commit
7080d388
authored
Jan 21, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do auto translation string matching at database level
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
c65e3d58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
weblate/trans/autotranslate.py
weblate/trans/autotranslate.py
+23
-20
No files found.
weblate/trans/autotranslate.py
View file @
7080d388
...
...
@@ -50,28 +50,31 @@ def auto_translate(user, translation, source, inconsistent, overwrite):
translation
=
translation
)
# Filter by strings
units
=
units
.
filter
(
source__in
=
sources
.
values
(
'source'
)
)
translation
.
commit_pending
(
None
)
for
unit
in
units
.
iterator
():
update
=
sources
.
filter
(
source
=
unit
.
source
)
if
update
.
exists
():
# Get first entry
update
=
update
[
0
]
# No save if translation is same
if
unit
.
fuzzy
==
update
.
fuzzy
and
unit
.
target
==
update
.
target
:
continue
# Copy translation
unit
.
fuzzy
=
update
.
fuzzy
unit
.
target
=
update
.
target
# Create signle change object for whole merge
change
=
Change
.
objects
.
create
(
action
=
Change
.
ACTION_AUTO
,
unit
=
unit
,
user
=
user
,
author
=
user
)
# Save unit to backend
unit
.
save_backend
(
None
,
False
,
False
,
user
=
user
)
updated
+=
1
# Get first matching entry
update
=
sources
.
filter
(
source
=
unit
.
source
)[
0
]
# No save if translation is same
if
unit
.
fuzzy
==
update
.
fuzzy
and
unit
.
target
==
update
.
target
:
continue
# Copy translation
unit
.
fuzzy
=
update
.
fuzzy
unit
.
target
=
update
.
target
# Create signle change object for whole merge
change
=
Change
.
objects
.
create
(
action
=
Change
.
ACTION_AUTO
,
unit
=
unit
,
user
=
user
,
author
=
user
)
# Save unit to backend
unit
.
save_backend
(
None
,
False
,
False
,
user
=
user
)
updated
+=
1
return
updated
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