google-translate 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/translate +16 -17
- data/google-translate.gemspec +1 -1
- data/lib/google_translate.rb +4 -3
- data/spec/translate_spec.rb +5 -5
- metadata +15 -15
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.1
|
data/bin/translate
CHANGED
@@ -12,7 +12,6 @@ class Translate
|
|
12
12
|
USAGE= <<-TEXT
|
13
13
|
Usage:
|
14
14
|
translate list - displays the list of supported languages
|
15
|
-
translate detect "hello world" - detects language of text
|
16
15
|
translate en:ru "hello world" - translates from en to ru
|
17
16
|
translate ru "hello world" - translated from auto-detected language to ru
|
18
17
|
TEXT
|
@@ -49,28 +48,28 @@ class Translate
|
|
49
48
|
|
50
49
|
print_languages hash[:from_languages], "From Languages:"
|
51
50
|
print_languages hash[:to_languages], "To Languages:"
|
52
|
-
when 'detect' then
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
#when 'detect' then
|
52
|
+
# language = @translator.detect_language(ARGV.shift)
|
53
|
+
#
|
54
|
+
# puts "Language: #{language.inspect}"
|
56
55
|
when /(.*):(.*)/ then
|
57
56
|
from_text = ARGV.join(' ')
|
58
57
|
from = $1
|
59
58
|
to = $2
|
60
59
|
|
61
60
|
display(@translator.translate(from.to_sym, to.to_sym, from_text))
|
62
|
-
when /(.*)/ then
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
61
|
+
#when /(.*)/ then
|
62
|
+
# from_text = ARGV.join(' ')
|
63
|
+
#
|
64
|
+
# from = @translator.detect_language(from_text)['language']
|
65
|
+
# to = $1
|
66
|
+
#
|
67
|
+
# begin
|
68
|
+
# display(@translator.translate(from.to_sym, to.to_sym, from_text))
|
69
|
+
# rescue Exception => e
|
70
|
+
# puts "Error: " + e.message
|
71
|
+
# end
|
72
|
+
#end
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
data/google-translate.gemspec
CHANGED
data/lib/google_translate.rb
CHANGED
@@ -43,9 +43,10 @@ module Google
|
|
43
43
|
|
44
44
|
# raise(InvalidResponse, result["responseDetails"]) if response.code.to_i != 200 # success
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
r1 = result[0][0][0]
|
47
|
+
r2 = result[0][0][2]
|
48
|
+
to_text = r2.empty? ? r1 : r2
|
49
|
+
(options[:html]) ? CGI.unescapeHTML(to_text) : to_text
|
49
50
|
end
|
50
51
|
rescue Exception => e
|
51
52
|
raise(TranslateServerIsDown)
|
data/spec/translate_spec.rb
CHANGED
@@ -35,11 +35,11 @@ module Google
|
|
35
35
|
# @translator.detect_language("bonjour tout le monde")['language'].should be == "fr"
|
36
36
|
#end
|
37
37
|
|
38
|
-
it "should raise an error if no string" do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
38
|
+
#it "should raise an error if no string" do
|
39
|
+
# lambda {
|
40
|
+
# @translator.detect_language(nil)
|
41
|
+
# }.should raise_error
|
42
|
+
#end
|
43
43
|
|
44
44
|
#it "should return unreliable flag if language is not recognized" do
|
45
45
|
# @translator.detect_language("azafretmkldt")['isReliable'].should be_false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-12 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157992000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157992000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157991520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157991520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: gemcutter
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157991040 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157991040
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: json_pure
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157990560 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.1.4
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157990560
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: json_pure
|
60
|
-
requirement: &
|
60
|
+
requirement: &2157990080 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2157990080
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &2157989600 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2157989600
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: gemcutter
|
82
|
-
requirement: &
|
82
|
+
requirement: &2157989120 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2157989120
|
91
91
|
description: Simple client for Google Translate API.
|
92
92
|
email: alexander.shvets@gmail.com
|
93
93
|
executables:
|