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
c004ac1e
Commit
c004ac1e
authored
Aug 13, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Not finished support for adding translations
parent
0fc74a71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
trans/formats.py
trans/formats.py
+41
-0
trans/tests/__init__.py
trans/tests/__init__.py
+1
-0
No files found.
trans/formats.py
View file @
c004ac1e
...
...
@@ -30,6 +30,7 @@ from translate.storage import mo
from
translate.storage
import
factory
from
trans.util
import
get_string
from
translate.misc
import
quote
import
subprocess
import
os.path
import
re
import
hashlib
...
...
@@ -494,6 +495,20 @@ class FileFormat(object):
return
True
@
staticmethod
def
supports_new_language
(
base
):
'''
Whether it supports creating new translation.
'''
return
False
@
staticmethod
def
add_language
(
filename
,
code
,
base
):
'''
Adds new language file.
'''
raise
ValueError
(
'Not supported'
)
class
AutoFormat
(
FileFormat
):
name
=
_
(
'Automatic detection'
)
...
...
@@ -547,6 +562,32 @@ class PoFormat(FileFormat):
'application/x-gettext-catalog'
)
@
staticmethod
def
supports_new_language
(
base
):
'''
Checks whether we can create new language file.
'''
try
:
ret
=
subprocess
.
check_call
([
'msginit'
,
'--help'
])
if
ret
!=
0
:
return
False
return
os
.
path
.
exists
(
base
)
except
:
return
False
@
staticmethod
def
add_language
(
filename
,
code
,
base
):
'''
Adds new language file.
'''
subprocess
.
check_call
([
'msginit'
,
'-i'
,
base
,
'-o'
,
filename
,
'--no-translator'
,
'-l'
,
code
])
register_fileformat
(
PoFormat
)
...
...
trans/tests/__init__.py
View file @
c004ac1e
...
...
@@ -48,3 +48,4 @@ from trans.tests.admin import *
from
trans.tests.requirements
import
*
from
trans.tests.autofix
import
*
from
trans.tests.lock
import
*
from
trans.tests.formats
import
*
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