Commit 01ea4957 authored by Michal Čihař's avatar Michal Čihař

Added XLIFF export for dictionary.

Issue #810
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 88818f90
......@@ -42,6 +42,7 @@ Released on ? 2015.
* Improved notifications on parse erorrs.
* Added option to import components with duplicate name to import_project.
* Improved support for translating PHP files
* Added XLIFF export for dictionary.
weblate 2.4
-----------
......
......@@ -100,6 +100,7 @@
<ul>
<li><a href="{% url 'download_dictionary' project=project.slug lang=language.code %}?format=csv">{% trans "Comma separated values (CSV)" %}</a></li>
<li><a href="{% url 'download_dictionary' project=project.slug lang=language.code %}?format=po">{% trans "Gettext (PO)" %}</a></li>
<li><a href="{% url 'download_dictionary' project=project.slug lang=language.code %}?format=xliff">{% trans "XML Localisation Interchange File Format (XLIFF)" %}</a></li>
<li><a href="{% url 'download_dictionary' project=project.slug lang=language.code %}?format=tbx">{% trans "TermBase eXchange (TBX)" %}</a></li>
</ul>
</div>
......
......@@ -218,6 +218,26 @@ class DictionaryTest(ViewTestCase):
'<term>webové stránky</term>'
)
def test_download_xliff(self):
'''
Test for downloading XLIFF file.
'''
# Import test data
self.import_file(TEST_TBX)
response = self.client.get(
self.get_url('download_dictionary'),
{'format': 'xliff'}
)
self.assertContains(
response,
'<source>website</source>'
)
self.assertContains(
response,
'<target state="translated">webové stránky</target>'
)
def test_download_po(self):
'''
Test for downloading PO file.
......
......@@ -208,6 +208,15 @@ def download_dictionary_ttkit(export_format, prj, lang, words):
)),
)
)
elif export_format == 'xliff':
# Construct store
from translate.storage.xliff import xlifffile
store = xlifffile()
# Export parameters
content_type = 'application/x-xliff+xml'
extension = 'xlf'
has_lang = True
else:
# Construct store
from translate.storage.tbx import tbxfile
......@@ -249,7 +258,7 @@ def download_dictionary(request, project, lang):
export_format = None
if 'format' in request.GET:
export_format = request.GET['format']
if export_format not in ('csv', 'po', 'tbx'):
if export_format not in ('csv', 'po', 'tbx', 'xliff'):
export_format = 'csv'
# Grab all words
......@@ -259,7 +268,7 @@ def download_dictionary(request, project, lang):
).order_by('source')
# Translate toolkit based export
if export_format in ('po', 'tbx'):
if export_format in ('po', 'tbx', 'xliff'):
return download_dictionary_ttkit(export_format, prj, lang, words)
# Manually create CSV file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment