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
cd5d63f7
Commit
cd5d63f7
authored
Mar 04, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial untested merging of translations
parent
5696ace3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
trans/models.py
trans/models.py
+27
-0
trans/views.py
trans/views.py
+5
-2
No files found.
trans/models.py
View file @
cd5d63f7
...
...
@@ -354,6 +354,33 @@ class Translation(models.Model):
result
.
append
((
'suggestions'
,
_
(
'Strings with suggestions (%d)'
)
%
suggestions
))
return
result
def
merge_upload
(
self
,
request
,
fileobj
,
overwrite
,
mergefuzzy
=
False
):
store2
=
factory
.
getobjects
(
fileobj
)
store1
=
self
.
get_store
()
store
.
require_index
()
for
unit2
in
store2
.
units
:
if
unit2
.
isheader
():
if
isinstance
(
store1
,
poheader
):
store1
.
mergeheaders
(
store2
)
continue
unit1
=
store1
.
findid
(
unit2
.
getid
())
if
unit1
is
None
:
unit1
=
store1
.
findunit
(
unit2
.
source
)
if
unit1
is
None
:
logger
.
error
(
"The template does not contain the following unit:
\
n
%s"
,
str
(
unit2
))
else
:
if
len
(
unit2
.
target
.
strip
())
==
0
:
continue
if
not
mergefuzzy
:
if
unit2
.
isfuzzy
():
continue
unit1
.
merge
(
unit2
,
overwrite
=
overwrite
)
store1
.
save
()
author
=
'%s <%s>'
%
(
request
.
user
.
get_full_name
(),
request
.
user
.
email
)
self
.
git_commit
(
author
)
class
Unit
(
models
.
Model
):
translation
=
models
.
ForeignKey
(
Translation
)
...
...
trans/views.py
View file @
cd5d63f7
...
...
@@ -180,7 +180,10 @@ def upload_translation(request, project, subproject, lang):
if
request
.
method
==
'POST'
:
form
=
UploadForm
(
request
.
POST
,
request
.
FILES
)
if
form
.
is_valid
():
# FIXME: process upload
messages
.
add_message
(
request
,
messages
.
INFO
,
_
(
'File content successfully merged into translation.'
))
try
:
obj
.
merge_upload
(
request
,
request
.
FILES
[
'file'
],
form
.
cleaned_data
[
'overwrite'
])
messages
.
add_message
(
request
,
messages
.
INFO
,
_
(
'File content successfully merged into translation.'
))
except
Exception
,
e
:
messages
.
add_message
(
request
,
messages
.
ERROR
,
_
(
'File content merge failed: %s'
%
str
(
e
)))
return
HttpResponseRedirect
(
obj
.
get_absolute_url
())
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