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
b9994d99
Commit
b9994d99
authored
Mar 21, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include list of supported Apertium languages in js config
parent
74397296
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
html/config.js
html/config.js
+7
-0
trans/views.py
trans/views.py
+16
-1
No files found.
html/config.js
View file @
b9994d99
{
%
if
apertium_api_key
%
}
var
APERTIUM_API_KEY
=
'
{{ apertium_api_key }}
'
;
{
%
endif
%
}
{
%
if
apertium_langs
%
}
var
APERTIUM_LANGS
=
[
{
%
for
lang
in
apertium_langs
%
}
'
{{ lang }}
'
,
{
%
endfor
%
}
];
{
%
endif
%
}
{
%
if
microsoft_api_key
%
}
var
MICROSOFT_API_KEY
=
'
{{ microsoft_api_key }}
'
;
{
%
endif
%
}
trans/views.py
View file @
b9994d99
from
django.shortcuts
import
render_to_response
,
get_object_or_404
from
django.conf
import
settings
from
django.core.servers.basehttp
import
FileWrapper
from
django.utils.translation
import
ugettext_lazy
,
ugettext
as
_
from
django.template
import
RequestContext
,
loader
...
...
@@ -16,6 +17,8 @@ from accounts.models import Profile
from
whoosh.analysis
import
StandardAnalyzer
,
StemmingAnalyzer
import
logging
import
os.path
import
json
import
urllib2
# See https://code.djangoproject.com/ticket/6027
class
FixedFileWrapper
(
FileWrapper
):
...
...
@@ -464,4 +467,16 @@ def not_found(request):
})))
def
js_config
(
request
):
return
render_to_response
(
'config.js'
,
RequestContext
(
request
,
{}),
mimetype
=
'application/javascript'
)
if
settings
.
MT_APERTIUM_KEY
is
not
None
and
settings
.
MT_APERTIUM_KEY
!=
''
:
listpairs
=
urllib2
.
urlopen
(
'http://api.apertium.org/json/listPairs?key=%s'
%
settings
.
MT_APERTIUM_KEY
)
pairs
=
listpairs
.
read
()
print
pairs
parsed
=
json
.
loads
(
pairs
)
apertium_langs
=
[
p
[
'targetLanguage'
]
for
p
in
parsed
[
'responseData'
]
if
p
[
'sourceLanguage'
]
==
'en'
]
else
:
apertium_langs
=
None
return
render_to_response
(
'config.js'
,
RequestContext
(
request
,
{
'apertium_langs'
:
apertium_langs
,
}),
mimetype
=
'application/javascript'
)
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