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
b9e95a3f
Commit
b9e95a3f
authored
Mar 24, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move more exporter logic to the exporter class
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
b1a7a745
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
weblate/trans/exporters.py
weblate/trans/exporters.py
+14
-4
weblate/trans/views/files.py
weblate/trans/views/files.py
+2
-7
No files found.
weblate/trans/exporters.py
View file @
b9e95a3f
...
@@ -52,10 +52,16 @@ class BaseExporter(object):
...
@@ -52,10 +52,16 @@ class BaseExporter(object):
name
=
''
name
=
''
has_lang
=
False
has_lang
=
False
def
__init__
(
self
,
project
,
language
,
url
):
def
__init__
(
self
,
project
=
None
,
language
=
None
,
url
=
None
,
self
.
project
=
project
translation
=
None
):
self
.
language
=
language
if
translation
is
not
None
:
self
.
url
=
url
self
.
project
=
translation
.
subproject
.
project
self
.
langauge
=
obj
.
language
self
.
url
=
obj
.
get_absolute_url
()
else
:
self
.
project
=
project
self
.
language
=
language
self
.
url
=
url
self
.
storage
=
self
.
get_storage
()
self
.
storage
=
self
.
get_storage
()
self
.
storage
.
setsourcelanguage
(
project
.
source_language
.
code
)
self
.
storage
.
setsourcelanguage
(
project
.
source_language
.
code
)
self
.
storage
.
settargetlanguage
(
language
.
code
)
self
.
storage
.
settargetlanguage
(
language
.
code
)
...
@@ -72,6 +78,10 @@ class BaseExporter(object):
...
@@ -72,6 +78,10 @@ class BaseExporter(object):
unit
.
target
=
word
.
target
unit
.
target
=
word
.
target
self
.
storage
.
addunit
(
unit
)
self
.
storage
.
addunit
(
unit
)
def
add_units
(
self
,
translation
):
for
unit
intranslation
.
unit_set
.
iterator
():
self
.
add_unit
(
unit
)
def
add_unit
(
self
,
unit
):
def
add_unit
(
self
,
unit
):
if
unit
.
is_plural
():
if
unit
.
is_plural
():
output
=
self
.
storage
.
UnitClass
(
output
=
self
.
storage
.
UnitClass
(
...
...
weblate/trans/views/files.py
View file @
b9e95a3f
...
@@ -41,16 +41,11 @@ def download_translation_format(request, project, subproject, lang, fmt):
...
@@ -41,16 +41,11 @@ def download_translation_format(request, project, subproject, lang, fmt):
obj
=
get_translation
(
request
,
project
,
subproject
,
lang
)
obj
=
get_translation
(
request
,
project
,
subproject
,
lang
)
try
:
try
:
exporter
=
get_exporter
(
fmt
)(
exporter
=
get_exporter
(
fmt
)(
translation
=
obj
)
obj
.
subproject
.
project
,
obj
.
language
,
obj
.
get_absolute_url
()
)
except
KeyError
:
except
KeyError
:
raise
Http404
(
'File format not supported'
)
raise
Http404
(
'File format not supported'
)
for
unit
in
obj
.
unit_set
.
iterator
():
exporter
.
add_units
(
obj
)
exporter
.
add_unit
(
unit
)
# Save to response
# Save to response
return
exporter
.
get_response
(
return
exporter
.
get_response
(
...
...
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