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
8098bdb7
Commit
8098bdb7
authored
Mar 12, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use FileUnits while storing to backend
parent
dfae51e2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
16 deletions
+29
-16
trans/formats.py
trans/formats.py
+25
-12
trans/models/translation.py
trans/models/translation.py
+4
-4
No files found.
trans/formats.py
View file @
8098bdb7
...
...
@@ -208,6 +208,18 @@ class FileUnit(object):
'''
return
self
.
mainunit
.
istranslatable
()
and
not
self
.
mainunit
.
isblank
()
def
set_target
(
self
,
target
):
'''
Sets translation unit target.
'''
self
.
unit
.
settarget
(
target
)
def
mark_fuzzy
(
self
,
fuzzy
):
'''
Sets fuzzy flag on translated unit.
'''
self
.
unit
.
markfuzzy
(
fuzzy
)
class
FileFormat
(
object
):
'''
...
...
@@ -298,17 +310,18 @@ class FileFormat(object):
unit is new one.
'''
if
self
.
has_template
:
# Need to create new unit based on template
template_pounit
=
self
.
template_store
.
findid
(
context
)
# We search by ID when using template
pounit
=
self
.
store
.
findid
(
context
)
# We always need new unit to translate
if
pounit
is
None
:
pounit
=
template_pounit
add
=
True
else
:
add
=
False
if
pounit
is
not
None
:
return
(
pounit
,
False
)
# Need to create new unit based on template
pounit
=
self
.
template_store
.
findid
(
context
)
if
pounit
is
not
None
:
return
(
pounit
,
True
)
return
(
FileUnit
(
pounit
,
template_pounit
),
add
)
else
:
# Find all units with same source
found_units
=
self
.
store
.
findunits
(
source
)
...
...
@@ -316,12 +329,12 @@ class FileFormat(object):
for
pounit
in
found_units
:
# Does context match?
if
pounit
.
getcontext
()
==
context
:
return
(
pounit
,
False
)
return
(
FileUnit
(
pounit
)
,
False
)
else
:
# Fallback to manual find for value based files
for
pounit
in
self
.
store
.
units
:
if
get_source
(
pounit
)
==
source
:
return
(
pounit
,
False
)
return
(
FileUnit
(
pounit
)
,
False
)
return
(
None
,
False
)
...
...
@@ -331,9 +344,9 @@ class FileFormat(object):
'''
if
isinstance
(
self
.
store
,
LISAfile
):
# LISA based stores need to know this
self
.
store
.
addunit
(
pounit
,
new
=
True
)
self
.
store
.
addunit
(
pounit
.
unit
,
new
=
True
)
else
:
self
.
store
.
addunit
(
pounit
)
self
.
store
.
addunit
(
pounit
.
unit
)
def
update_header
(
self
,
**
kwargs
):
'''
...
...
trans/models/translation.py
View file @
8098bdb7
...
...
@@ -789,14 +789,14 @@ class Translation(models.Model):
return
False
,
None
# Detect changes
if
unit
.
target
!=
get_target
(
pounit
)
or
unit
.
fuzzy
!=
pounit
.
is
fuzzy
():
if
unit
.
target
!=
pounit
.
get_target
()
or
unit
.
fuzzy
!=
pounit
.
is_
fuzzy
():
# Store translations
if
unit
.
is_plural
():
pounit
.
settarget
(
unit
.
get_target_plurals
())
pounit
.
set
_
target
(
unit
.
get_target_plurals
())
else
:
pounit
.
settarget
(
unit
.
target
)
pounit
.
set
_
target
(
unit
.
target
)
# Update fuzzy flag
pounit
.
markfuzzy
(
unit
.
fuzzy
)
pounit
.
mark
_
fuzzy
(
unit
.
fuzzy
)
# Optionally add unit to translation file
if
add
:
self
.
store
.
add_unit
(
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