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
bf40ef08
Commit
bf40ef08
authored
Mar 21, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List Microsoft translator languages in js config
parent
e1f7ec96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
html/config.js
html/config.js
+3
-0
trans/views.py
trans/views.py
+14
-0
No files found.
html/config.js
View file @
bf40ef08
...
...
@@ -11,3 +11,6 @@ var APERTIUM_LANGS = [
{
%
if
microsoft_api_key
%
}
var
MICROSOFT_API_KEY
=
'
{{ microsoft_api_key }}
'
;
{
%
endif
%
}
{
%
if
microsoft_langs
%
}
var
MICROSOFT_LANGS
=
[{
%
for
lang
in
microsoft_langs
%
}
'
{{ lang }}
'
,{
%
endfor
%
}];
{
%
endif
%
}
trans/views.py
View file @
bf40ef08
...
...
@@ -18,6 +18,7 @@ from whoosh.analysis import StandardAnalyzer, StemmingAnalyzer
import
logging
import
os.path
import
json
from
xml.etree
import
ElementTree
import
urllib2
# See https://code.djangoproject.com/ticket/6027
...
...
@@ -479,7 +480,20 @@ def js_config(request):
else
:
apertium_langs
=
None
if
settings
.
MT_MICROSOFT_KEY
is
not
None
and
settings
.
MT_MICROSOFT_KEY
!=
''
:
try
:
listpairs
=
urllib2
.
urlopen
(
'http://api.microsofttranslator.com/V2/Http.svc/GetLanguagesForTranslate?appID=%s'
%
settings
.
MT_MICROSOFT_KEY
)
data
=
listpairs
.
read
()
parsed
=
ElementTree
.
fromstring
(
data
)
microsoft_langs
=
[
p
.
text
for
p
in
parsed
.
getchildren
()]
except
Exception
,
e
:
logger
.
error
(
'failed to get supported languages from Microsoft, using defaults (%s)'
,
str
(
e
))
microsoft_langs
=
[
'ar'
,
'bg'
,
'ca'
,
'zh-CHS'
,
'zh-CHT'
,
'cs'
,
'da'
,
'nl'
,
'en'
,
'et'
,
'fi'
,
'fr'
,
'de'
,
'el'
,
'ht'
,
'he'
,
'hi'
,
'mww'
,
'hu'
,
'id'
,
'it'
,
'ja'
,
'ko'
,
'lv'
,
'lt'
,
'no'
,
'pl'
,
'pt'
,
'ro'
,
'ru'
,
'sk'
,
'sl'
,
'es'
,
'sv'
,
'th'
,
'tr'
,
'uk'
,
'vi'
]
else
:
microsoft_langs
=
None
return
render_to_response
(
'config.js'
,
RequestContext
(
request
,
{
'apertium_langs'
:
apertium_langs
,
'microsoft_langs'
:
microsoft_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