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
a79c4baf
Commit
a79c4baf
authored
Nov 23, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Xliff specific code to the separate class
Issue #816 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
1d6d2192
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
weblate/trans/formats.py
weblate/trans/formats.py
+25
-11
No files found.
weblate/trans/formats.py
View file @
a79c4baf
...
...
@@ -106,8 +106,7 @@ class FileUnit(object):
'''
# JSON, XLIFF and PHP are special in ttkit - it uses locations for what
# is context in other formats
if
(
isinstance
(
self
.
mainunit
,
xliffunit
)
or
isinstance
(
self
.
mainunit
,
propunit
)
or
if
(
isinstance
(
self
.
mainunit
,
propunit
)
or
isinstance
(
self
.
mainunit
,
phpunit
)):
return
''
result
=
', '
.
join
(
self
.
mainunit
.
getlocations
())
...
...
@@ -234,15 +233,7 @@ class FileUnit(object):
Returns context of message. In some cases we have to use
ID here to make all backends consistent.
'''
# XLIFF is special in ttkit - it uses locations for what
# is context in other formats
if
isinstance
(
self
.
mainunit
,
xliffunit
):
context
=
self
.
mainunit
.
getlocations
()
if
len
(
context
)
==
0
:
return
''
else
:
return
context
[
0
]
elif
isinstance
(
self
.
mainunit
,
pounit
)
and
self
.
template
is
not
None
:
if
isinstance
(
self
.
mainunit
,
pounit
)
and
self
.
template
is
not
None
:
# Monolingual JSON files
return
self
.
template
.
getid
()
else
:
...
...
@@ -346,6 +337,28 @@ class FileUnit(object):
self
.
unit
.
markfuzzy
(
fuzzy
)
class
XliffUnit
(
FileUnit
):
def
get_context
(
self
):
'''
Returns context of message. In some cases we have to use
ID here to make all backends consistent.
XLIFF is special in ttkit - it uses locations for what
is context in other formats
'''
context
=
self
.
mainunit
.
getlocations
()
if
len
(
context
)
==
0
:
return
''
else
:
return
context
[
0
]
def
get_locations
(
self
):
'''
Returns comma separated list of locations.
'''
return
''
class
MonolingualIDUnit
(
FileUnit
):
def
get_context
(
self
):
if
self
.
template
is
not
None
:
...
...
@@ -911,6 +924,7 @@ class XliffFormat(FileFormat):
format_id
=
'xliff'
loader
=
(
'xliff'
,
'xlifffile'
)
autoload
=
(
'.xlf'
,
'.xliff'
)
unit_class
=
XliffUnit
@
classmethod
def
supports_new_language
(
cls
):
...
...
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