idiom 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/idiom.gemspec +1 -1
- data/lib/idiom/microsoft_translator.rb +9 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/idiom.gemspec
CHANGED
@@ -7,12 +7,19 @@ class MicrosoftTranslator
|
|
7
7
|
# "http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{}&appId=2CEF8B6B9CA38C6C8355B154C760C28A66E4339F"
|
8
8
|
|
9
9
|
appId = CONFIG["appId"]
|
10
|
-
|
10
|
+
url = "http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{value}&appId=#{appId}"
|
11
|
+
result = Net::HTTP.get(URI.parse(url))
|
11
12
|
|
12
13
|
if result =~ /<string xmlns=\"http:\/\/schemas.microsoft.com\/2003\/10\/Serialization\/\">(.*)<\/string>/
|
13
14
|
output = $1
|
14
15
|
end
|
16
|
+
if result =~ /Message: (.*)/
|
17
|
+
$stdout.puts(result)
|
18
|
+
end
|
19
|
+
if result =~ /AppId is over the quota/
|
20
|
+
raise "AppId is over the quota"
|
21
|
+
end
|
15
22
|
output.to_s
|
16
23
|
end
|
17
24
|
end
|
18
|
-
end
|
25
|
+
end
|
metadata
CHANGED