Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
e7641909
Commit
e7641909
authored
Apr 17, 2013
by
Steve Strassmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uncommit unneeded files
parent
6e34c668
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
73 deletions
+3
-73
cms/urls.py
+1
-1
create-dev-env.sh
+2
-4
i18n/googleTranslate.py
+0
-68
No files found.
cms/urls.py
View file @
e7641909
...
...
@@ -94,7 +94,7 @@ urlpatterns = ('',
# noop to squelch ajax errors
url
(
r'^event$'
,
'contentstore.views.event'
,
name
=
'event'
),
url
(
r'^heartbeat$'
,
include
(
'heartbeat.urls'
))
url
(
r'^heartbeat$'
,
include
(
'heartbeat.urls'
))
,
)
# User creation and updating views
...
...
create-dev-env.sh
View file @
e7641909
...
...
@@ -93,7 +93,7 @@ clone_repos() {
### START
PROG
=
${
0
##*/
}
BASE
=
"
$HOME
/
src/
mitx_all"
BASE
=
"
$HOME
/mitx_all"
PYTHON_DIR
=
"
$BASE
/python"
RUBY_DIR
=
"
$BASE
/ruby"
RUBY_VER
=
"1.9.3"
...
...
@@ -290,8 +290,7 @@ source $PYTHON_DIR/bin/activate
NUMPY_VER
=
"1.6.2"
SCIPY_VER
=
"0.10.1"
if
[
-z
"false"
]
;
then
if
[[
-n
$compile
]]
;
then
if
[[
-n
$compile
]]
;
then
output
"Downloading numpy and scipy"
curl
-sL
-o
numpy.tar.gz http://downloads.sourceforge.net/project/numpy/NumPy/
${
NUMPY_VER
}
/numpy-
${
NUMPY_VER
}
.tar.gz
curl
-sL
-o
scipy.tar.gz http://downloads.sourceforge.net/project/scipy/scipy/
${
SCIPY_VER
}
/scipy-
${
SCIPY_VER
}
.tar.gz
...
...
@@ -306,7 +305,6 @@ if [-z "false"]; then
python setup.py install
cd
"
$BASE
"
rm
-rf
numpy-
${
NUMPY_VER
}
scipy-
${
SCIPY_VER
}
fi
fi
case
`
uname
-s
`
in
...
...
i18n/googleTranslate.py
deleted
100644 → 0
View file @
6e34c668
import
urllib
,
urllib2
,
json
# Google Translate API
# see https://code.google.com/apis/language/translate/v2/getting_started.html
#
#
# usage: translate('flower', 'fr') => 'fleur'
# --------------------------------------------
# Translation limit = 100,000 chars/day (request submitted for more)
# Limit of 5,000 characters per request
# This key is personally registered to Steve Strassmann
#
#KEY = 'AIzaSyCDapmXdBtIYw3ofsvgm6gIYDNwiVmSm7g'
KEY
=
'AIzaSyDOhTQokSOqqO-8ZJqUNgn12C83g-muIqA'
URL
=
'https://www.googleapis.com/language/translate/v2'
SOURCE
=
'en'
# source: English
TARGETS
=
[
'zh-CN'
,
'ja'
,
'fr'
,
'de'
,
# tier 1: Simplified Chinese, Japanese, French, German
'es'
,
'it'
,
# tier 2: Spanish, Italian
'ru'
]
# extra credit: Russian
def
translate
(
string
,
target
):
return
extract
(
fetch
(
string
,
target
))
# Ask Google to translate string to target language
# string: English string
# target: lang (e.g. 'fr', 'cn')
# Returns JSON object
def
fetch
(
string
,
target
,
url
=
URL
,
key
=
KEY
,
source
=
SOURCE
):
data
=
{
'key'
:
key
,
'q'
:
string
,
'source'
:
source
,
'target'
:
target
}
fullUrl
=
'
%
s?
%
s'
%
(
url
,
urllib
.
urlencode
(
data
))
try
:
response
=
urllib2
.
urlopen
(
fullUrl
)
return
json
.
loads
(
response
.
read
())
except
urllib2
.
HTTPError
as
err
:
if
err
.
code
==
403
:
print
"***"
print
"*** Possible daily limit exceeded for Google Translate:"
print
"***"
print
"***"
,
json
.
loads
(
""
.
join
(
err
.
readlines
()))
print
"***"
raise
# Extracts a translated result from a json object returned from Google
def
extract
(
response
):
data
=
response
[
'data'
]
translations
=
data
[
'translations'
]
first
=
translations
[
0
]
result
=
first
.
get
(
'translated_text'
,
None
)
if
result
!=
None
:
return
result
else
:
result
=
first
.
get
(
'translatedText'
,
None
)
if
result
!=
None
:
return
result
else
:
raise
Exception
(
"Could not read translation from:
%
s"
%
translations
)
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