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
47740994
Commit
47740994
authored
Aug 13, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for adding new translations in XLIFF.
Fixes #801 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
97d9fbc0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
7 deletions
+55
-7
docs/changes.rst
docs/changes.rst
+1
-0
docs/formats.rst
docs/formats.rst
+0
-5
weblate/trans/formats.py
weblate/trans/formats.py
+26
-1
weblate/trans/tests/data/cs.xliff
weblate/trans/tests/data/cs.xliff
+13
-0
weblate/trans/tests/test_formats.py
weblate/trans/tests/test_formats.py
+15
-1
No files found.
docs/changes.rst
View file @
47740994
...
...
@@ -21,6 +21,7 @@ Released on ? 2015.
* Projects now can have multiple owners.
* Project owners can manage themselves.
* Added support for javascript-format used in Gettext PO.
* Support for adding new translations in XLIFF.
weblate 2.3
-----------
...
...
docs/formats.rst
View file @
47740994
...
...
@@ -120,11 +120,6 @@ is one of many standards in this area.
XLIFF is usually used as bilingual.
.. note::
Weblate does not support adding new language to the translations using this
format. This has to be done manually in the VCS.
.. seealso::
`XLIFF on Wikipedia <https://en.wikipedia.org/wiki/XLIFF>`_,
...
...
weblate/trans/formats.py
View file @
47740994
...
...
@@ -23,7 +23,7 @@ File format specific behavior.
from
django.utils.translation
import
ugettext_lazy
as
_
from
translate.storage.lisa
import
LISAfile
from
translate.storage.properties
import
propunit
,
propfile
from
translate.storage.xliff
import
xliffunit
from
translate.storage.xliff
import
xliffunit
,
xlifffile
from
translate.storage.po
import
pounit
,
pofile
from
translate.storage.php
import
phpunit
from
translate.storage.ts2
import
tsunit
...
...
@@ -854,6 +854,31 @@ class XliffFormat(FileFormat):
format_id
=
'xliff'
loader
=
(
'xliff'
,
'xlifffile'
)
@
classmethod
def
supports_new_language
(
cls
):
'''
Checks whether we can create new language file.
'''
return
True
@
staticmethod
def
is_valid_base_for_new
(
base
):
'''
Checks whether base is valid.
'''
try
:
xlifffile
.
parsefile
(
base
)
return
True
except
Exception
:
return
False
@
classmethod
def
create_new_file
(
cls
,
filename
,
code
,
base
):
"""Handles creation of new translation file."""
content
=
xlifffile
.
parsefile
(
base
)
content
.
settargetlanguage
(
code
)
content
.
savefile
(
filename
)
@
register_fileformat
class
StringsFormat
(
FileFormat
):
...
...
weblate/trans/tests/data/cs.xliff
0 → 100644
View file @
47740994
<xliff>
<file>
<body>
<trans-unit><source xml:space="preserve">Hello, world!
</source></trans-unit>
<trans-unit><source xml:space="preserve">Orangutan has %d banana.
</source></trans-unit>
<trans-unit><source xml:space="preserve">Try Weblate at <http://demo.weblate.org/>!
</source></trans-unit>
<trans-unit><source>Thank you for using Weblate.</source></trans-unit>
</body>
</file>
</xliff>
weblate/trans/tests/test_formats.py
View file @
47740994
...
...
@@ -24,7 +24,7 @@ import tempfile
from
unittest
import
TestCase
from
weblate.trans.formats
import
(
AutoFormat
,
PoFormat
,
AndroidFormat
,
PropertiesFormat
,
JSONFormat
,
RESXFormat
,
PhpFormat
,
JSONFormat
,
RESXFormat
,
PhpFormat
,
XliffFormat
,
FILE_FORMATS
,
)
from
weblate.trans.tests.utils
import
get_test_file
...
...
@@ -34,6 +34,7 @@ TEST_JSON = get_test_file('cs.json')
TEST_PHP
=
get_test_file
(
'cs.php'
)
TEST_PROPERTIES
=
get_test_file
(
'swing.properties'
)
TEST_ANDROID
=
get_test_file
(
'strings.xml'
)
TEST_XLIFF
=
get_test_file
(
'cs.xliff'
)
TEST_POT
=
get_test_file
(
'hello.pot'
)
TEST_POT_UNICODE
=
get_test_file
(
'unicode.pot'
)
TEST_RESX
=
get_test_file
(
'cs.resx'
)
...
...
@@ -145,6 +146,19 @@ class AndroidFormatTest(AutoFormatTest):
EXPECTED_PATH
=
'res/values-cs-rCZ/strings.xml'
class
XliffFormatTest
(
AutoFormatTest
):
FORMAT
=
XliffFormat
FILE
=
TEST_XLIFF
BASE
=
TEST_XLIFF
MIME
=
'application/x-xliff'
EXT
=
'xlf'
COUNT
=
4
MATCH
=
'<file target-language="cs">'
FIND_MATCH
=
u''
MASK
=
'loc/*/default.xliff'
EXPECTED_PATH
=
'loc/cs_CZ/default.xliff'
if
'resx'
in
FILE_FORMATS
:
class
RESXFormatTest
(
AutoFormatTest
):
FORMAT
=
RESXFormat
...
...
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