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
23bda729
Commit
23bda729
authored
Mar 10, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move JSON special cases to separate class
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
6d3627f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
weblate/trans/formats.py
weblate/trans/formats.py
+24
-10
No files found.
weblate/trans/formats.py
View file @
23bda729
...
@@ -27,7 +27,6 @@ from translate.storage.xliff import xliffunit
...
@@ -27,7 +27,6 @@ from translate.storage.xliff import xliffunit
from
translate.storage.po
import
pounit
,
pofile
from
translate.storage.po
import
pounit
,
pofile
from
translate.storage.php
import
phpunit
from
translate.storage.php
import
phpunit
from
translate.storage.ts2
import
tsunit
from
translate.storage.ts2
import
tsunit
from
translate.storage.jsonl10n
import
JsonUnit
from
translate.storage
import
mo
from
translate.storage
import
mo
from
translate.storage
import
factory
from
translate.storage
import
factory
from
weblate.trans.util
import
get_string
,
join_plural
,
add_configuration_error
from
weblate.trans.util
import
get_string
,
join_plural
,
add_configuration_error
...
@@ -100,7 +99,6 @@ class FileUnit(object):
...
@@ -100,7 +99,6 @@ class FileUnit(object):
# is context in other formats
# is context in other formats
if
(
isinstance
(
self
.
mainunit
,
xliffunit
)
or
if
(
isinstance
(
self
.
mainunit
,
xliffunit
)
or
isinstance
(
self
.
mainunit
,
propunit
)
or
isinstance
(
self
.
mainunit
,
propunit
)
or
isinstance
(
self
.
mainunit
,
JsonUnit
)
or
isinstance
(
self
.
mainunit
,
phpunit
)):
isinstance
(
self
.
mainunit
,
phpunit
)):
return
''
return
''
result
=
', '
.
join
(
self
.
mainunit
.
getlocations
())
result
=
', '
.
join
(
self
.
mainunit
.
getlocations
())
...
@@ -181,8 +179,6 @@ class FileUnit(object):
...
@@ -181,8 +179,6 @@ class FileUnit(object):
self
.
unit
.
source
,
self
.
unit
.
source
,
self
.
unit
.
source
,
self
.
unit
.
source
,
])
])
if
isinstance
(
self
.
mainunit
,
JsonUnit
)
and
self
.
template
is
None
:
return
self
.
mainunit
.
getid
().
lstrip
(
'.'
)
if
self
.
is_unit_key_value
():
if
self
.
is_unit_key_value
():
# Need to decode property encoded string
# Need to decode property encoded string
if
isinstance
(
self
.
mainunit
,
propunit
):
if
isinstance
(
self
.
mainunit
,
propunit
):
...
@@ -237,10 +233,6 @@ class FileUnit(object):
...
@@ -237,10 +233,6 @@ class FileUnit(object):
return
''
return
''
else
:
else
:
return
context
[
0
]
return
context
[
0
]
elif
(
isinstance
(
self
.
mainunit
,
(
pounit
,
JsonUnit
))
and
self
.
template
is
not
None
):
# Monolingual JSON files
return
self
.
template
.
getid
()
else
:
else
:
context
=
self
.
mainunit
.
getcontext
()
context
=
self
.
mainunit
.
getcontext
()
if
self
.
is_unit_key_value
()
and
context
==
''
:
if
self
.
is_unit_key_value
()
and
context
==
''
:
...
@@ -324,8 +316,6 @@ class FileUnit(object):
...
@@ -324,8 +316,6 @@ class FileUnit(object):
For some reason, blank string does not mean non translatable
For some reason, blank string does not mean non translatable
unit in some formats (XLIFF), so lets skip those as well.
unit in some formats (XLIFF), so lets skip those as well.
'''
'''
if
isinstance
(
self
.
mainunit
,
JsonUnit
):
return
True
return
self
.
mainunit
.
istranslatable
()
and
not
self
.
mainunit
.
isblank
()
return
self
.
mainunit
.
istranslatable
()
and
not
self
.
mainunit
.
isblank
()
def
set_target
(
self
,
target
):
def
set_target
(
self
,
target
):
...
@@ -344,7 +334,30 @@ class FileUnit(object):
...
@@ -344,7 +334,30 @@ class FileUnit(object):
self
.
unit
.
markfuzzy
(
fuzzy
)
self
.
unit
.
markfuzzy
(
fuzzy
)
class
JSONUnit
(
FileUnit
):
def
get_locations
(
self
):
return
''
def
get_source
(
self
):
if
self
.
template
is
None
:
return
self
.
mainunit
.
getid
().
lstrip
(
'.'
)
return
get_string
(
self
.
template
.
target
)
def
get_context
(
self
):
if
self
.
template
is
not
None
:
# Monolingual JSON files
return
self
.
template
.
getid
()
else
:
return
self
.
mainunit
.
getcontext
()
def
is_translatable
(
self
):
return
True
class
RESXUnit
(
FileUnit
):
class
RESXUnit
(
FileUnit
):
def
get_locations
(
self
):
return
''
def
get_context
(
self
):
def
get_context
(
self
):
return
self
.
unit
.
getid
()
return
self
.
unit
.
getid
()
...
@@ -894,6 +907,7 @@ class JSONFormat(FileFormat):
...
@@ -894,6 +907,7 @@ class JSONFormat(FileFormat):
name
=
_
(
'JSON file'
)
name
=
_
(
'JSON file'
)
format_id
=
'json'
format_id
=
'json'
loader
=
(
'weblate.trans.aresource'
,
'JsonFile'
)
loader
=
(
'weblate.trans.aresource'
,
'JsonFile'
)
unit_class
=
JSONUnit
@
classmethod
@
classmethod
def
supports_new_language
(
cls
):
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