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
d3097976
Commit
d3097976
authored
Apr 23, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments
parent
ddc7808a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
weblate/trans/models.py
weblate/trans/models.py
+31
-1
No files found.
weblate/trans/models.py
View file @
d3097976
...
...
@@ -314,18 +314,30 @@ class SubProject(models.Model):
Ensures local tracking branch exists and is checkouted.
'''
gitrepo
=
self
.
get_repo
()
# create branch if it does not exist
if
not
self
.
branch
in
gitrepo
.
heads
:
gitrepo
.
git
.
branch
(
'--track'
,
self
.
branch
,
'origin/%s'
%
self
.
branch
)
# switch to correct branch
gitrepo
.
git
.
checkout
(
self
.
branch
)
# force cleanup
del
gitrepo
def
do_update
(
self
,
request
=
None
):
'''
Wrapper for doing repository update and pushing them to translations.
'''
# commit possible pending changes
self
.
commit_pending
()
# update remote branc
ret
=
self
.
update_branch
(
request
)
# create translation objects for all files
self
.
create_translations
()
return
ret
def
do_push
(
self
,
request
=
None
):
...
...
@@ -799,6 +811,11 @@ class Translation(models.Model):
def
git_commit
(
self
,
author
,
force_commit
=
False
,
sync
=
False
):
'''
Wrapper for commiting translation to git.
force_commit forces commit with lazy commits enabled
sync updates git hash stored within the translation (otherwise
translation rescan will be needed)
'''
gitrepo
=
self
.
get_repo
()
if
not
self
.
git_needs_commit
(
gitrepo
):
...
...
@@ -824,23 +841,33 @@ class Translation(models.Model):
store
=
self
.
get_store
()
src
=
unit
.
get_source_plurals
()[
0
]
need_save
=
False
# Find all units with same source
for
pounit
in
store
.
findunits
(
src
):
# Does context match?
if
pounit
.
getcontext
()
==
unit
.
context
:
# Is it plural?
if
hasattr
(
pounit
.
target
,
'strings'
):
potarget
=
join_plural
(
pounit
.
target
.
strings
)
else
:
potarget
=
pounit
.
target
# Is there any change
if
unit
.
target
!=
potarget
or
unit
.
fuzzy
!=
pounit
.
isfuzzy
():
# Update fuzzy flag
pounit
.
markfuzzy
(
unit
.
fuzzy
)
# Store translations
if
unit
.
is_plural
():
pounit
.
settarget
(
unit
.
get_target_plurals
())
else
:
pounit
.
settarget
(
unit
.
target
)
# We need to update backend
need_save
=
True
# We should have only one match
break
# Save backend if there was a change
if
need_save
:
author
=
self
.
get_author_name
(
request
.
user
)
author
=
self
.
get_author_name
(
request
.
usr
)
# Update po file header
if
hasattr
(
store
,
'updateheader'
):
po_revision_date
=
datetime
.
now
().
strftime
(
'%Y-%m-%d %H:%M'
)
+
poheader
.
tzstring
()
...
...
@@ -852,8 +879,11 @@ class Translation(models.Model):
PO_Revision_Date
=
po_revision_date
,
x_generator
=
'Weblate %s'
%
weblate
.
VERSION
)
# commit possible previous changes (by other author)
self
.
commit_pending
(
author
)
# save translation changes
store
.
save
()
# commit Git repo if needed
self
.
git_commit
(
author
,
sync
=
True
)
return
need_save
,
pounit
...
...
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