Commit 9d565b61 authored by Michal Čihař's avatar Michal Čihař

Merge branch 'master' into api

parents 6b32680d fed1333b
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<li><a href="{% url 'download_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" title="{% trans "Download for an offline translation." %}">{% trans "Download original translation file" %}</a></li> <li><a href="{% url 'download_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" title="{% trans "Download for an offline translation." %}">{% trans "Download original translation file" %}</a></li>
<li><a href="{% url 'download_translation_format' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code fmt='xliff'%}" title="{% trans "Download for an offline translation." %}">{% trans "Download translation as XLIFF" %}</a></li> <li><a href="{% url 'download_translation_format' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code fmt='xliff'%}" title="{% trans "Download for an offline translation." %}">{% trans "Download translation as XLIFF" %}</a></li>
<li><a href="{% url 'download_translation_format' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code fmt='xliff12'%}" title="{% trans "Download for an offline translation." %}">{% trans "Download translation as XLIFF 1.2" %}</a></li>
<li><a href="{% url 'download_translation_format' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code fmt='po'%}" title="{% trans "Download for an offline translation." %}">{% trans "Download translation as Gettext PO" %}</a></li> <li><a href="{% url 'download_translation_format' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code fmt='po'%}" title="{% trans "Download for an offline translation." %}">{% trans "Download translation as Gettext PO" %}</a></li>
{% if object.supports_language_pack %} {% if object.supports_language_pack %}
<li><a href="{% url 'download_language_pack' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" title="{% trans "Download for using within an application." %}">{% trans "Download compiled translation" %}</a></li> <li><a href="{% url 'download_language_pack' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" title="{% trans "Download for using within an application." %}">{% trans "Download compiled translation" %}</a></li>
......
...@@ -24,6 +24,7 @@ from django.http import HttpResponse ...@@ -24,6 +24,7 @@ from django.http import HttpResponse
from translate.misc.multistring import multistring from translate.misc.multistring import multistring
from translate.storage.po import pofile from translate.storage.po import pofile
from translate.storage.poxliff import PoXliffFile
from translate.storage.xliff import xlifffile from translate.storage.xliff import xlifffile
from translate.storage.tbx import tbxfile from translate.storage.tbx import tbxfile
...@@ -140,12 +141,23 @@ class PoExporter(BaseExporter): ...@@ -140,12 +141,23 @@ class PoExporter(BaseExporter):
@register_exporter @register_exporter
class XliffExporter(BaseExporter): class PoXliffExporter(BaseExporter):
name = 'xliff' name = 'xliff'
content_type = 'application/x-xliff+xml' content_type = 'application/x-xliff+xml'
extension = 'xlf' extension = 'xlf'
has_lang = True has_lang = True
def get_storage(self):
return PoXliffFile()
@register_exporter
class XliffExporter(BaseExporter):
name = 'xliff12'
content_type = 'application/x-xliff+xml'
extension = 'xlf'
has_lang = True
def get_storage(self): def get_storage(self):
return xlifffile() return xlifffile()
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from __future__ import unicode_literals
import os import os
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
......
...@@ -398,6 +398,12 @@ class ExportTest(ViewTestCase): ...@@ -398,6 +398,12 @@ class ExportTest(ViewTestCase):
response, 'Orangutan has %d banana' response, 'Orangutan has %d banana'
) )
def test_export_xliff(self):
response = self.export_format('xliff12')
self.assertContains(
response, 'Orangutan has %d banana'
)
def test_export_invalid(self): def test_export_invalid(self):
response = self.export_format('invalid') response = self.export_format('invalid')
self.assertEqual(response.status_code, 404) self.assertEqual(response.status_code, 404)
......
...@@ -191,7 +191,7 @@ urlpatterns = [ ...@@ -191,7 +191,7 @@ urlpatterns = [
name='download_translation', name='download_translation',
), ),
url( url(
r'^download/' + TRANSLATION + '(?P<fmt>[a-z]+)/$', r'^download/' + TRANSLATION + '(?P<fmt>[a-z0-9]+)/$',
weblate.trans.views.files.download_translation_format, weblate.trans.views.files.download_translation_format,
name='download_translation_format', name='download_translation_format',
), ),
......
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