sishen-rtranslate 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ V1.3 Dec 18th, 2009
2
+ * Enable the translation for the long string which is supposed to be more than 500 characters. The lib will split the text into several groups 500 by 500 and then join the response translated text together.
3
+
1
4
  V1.2 Sep 17th, 2009
2
5
  * Enable the auto-detect source features of google translate api
3
6
 
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
3
 
4
- Hoe.new('rtranslate', '1.1') do |p|
5
- p.rubyforge_name = 'rtranslate'
4
+ Hoe.new('sishen-rtranslate', '1.3') do |p|
5
+ p.rubyforge_name = 'sishen-rtranslate'
6
6
  p.author = 'Ye Dingding'
7
7
  p.email = 'yedingding@gmail.com'
8
8
  p.url = 'http://github.com/sishen/rtranslate'
@@ -65,11 +65,14 @@ module Translate
65
65
  from = from ? Google::Language.abbrev(from) : nil
66
66
  to = Google::Language.abbrev(to)
67
67
  langpair = "#{from}|#{to}"
68
- url = "#{GOOGLE_TRANSLATE_URL}?q=#{text}&langpair=#{langpair}&v=#{@version}"
69
- if @key
70
- url << "&key=#{@key}"
68
+
69
+ text.mb_chars.scan(/(.{1,500})/).inject("") do |result, st|
70
+ url = "#{GOOGLE_TRANSLATE_URL}?q=#{st}&langpair=#{langpair}&v=#{@version}"
71
+ if @key
72
+ url << "&key=#{@key}"
73
+ end
74
+ result += do_translate(url)
71
75
  end
72
- do_translate(url)
73
76
  else
74
77
  raise UnsupportedLanguagePair, "Translation from '#{from}' to '#{to}' isn't supported yet!"
75
78
  end
data/lib/rtranslate.rb CHANGED
@@ -11,6 +11,10 @@ rescue LoadError
11
11
  require 'json'
12
12
  end
13
13
 
14
+ unless defined?(ActiveSupport)
15
+ require 'activesupport'
16
+ end
17
+
14
18
  $KCODE = 'u'
15
19
 
16
20
  include Translate
data/rtranslate.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{rtranslate}
3
- s.version = "1.2"
3
+ s.version = "1.3"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Ye Dingding"]
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  "bin/rtranslate", "lib/rtranslate.rb", "lib/rtranslate/language.rb",
14
14
  "lib/rtranslate/rtranslate.rb", "lib/rtranslate/detection.rb", "tests/ts_detection.rb"]
15
15
  s.has_rdoc = true
16
- s.homepage = %q{http://sishen.lifegoo.com}
16
+ s.homepage = %q{http://github.com/sishen}
17
17
  s.rdoc_options = ["--main", "README.txt"]
18
18
  s.require_paths = ["lib"]
19
19
  s.rubygems_version = %q{1.2.0}
@@ -27,14 +27,17 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
28
28
  s.add_development_dependency(%q<rspec>, [">= 1.1.4"])
29
29
  s.add_development_dependency(%q<json>, [">= 1.1.3"])
30
+ s.add_development_dependency(%q<activesupprt>, [">= 2.2.0"])
30
31
  else
31
32
  s.add_dependency(%q<hoe>, [">= 1.7.0"])
32
33
  s.add_dependency(%q<rspec>, [">= 1.1.4"])
33
34
  s.add_dependency(%q<json>, [">= 1.1.3"])
35
+ s.add_dependency(%q<activesupport>, [">= 2.2.0"])
34
36
  end
35
37
  else
36
38
  s.add_dependency(%q<hoe>, [">= 1.7.0"])
37
39
  s.add_dependency(%q<rspec>, [">= 1.1.4"])
38
40
  s.add_dependency(%q<json>, [">= 1.1.3"])
41
+ s.add_dependency(%q<activesupport>, [">= 2.2.0"])
39
42
  end
40
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sishen-rtranslate
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.2"
4
+ version: "1.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ye Dingding
@@ -9,43 +9,33 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-11 00:00:00 -07:00
12
+ date: 2009-12-18 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hoe
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.7.0
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: rspec
16
+ name: json
27
17
  type: :runtime
28
18
  version_requirement:
29
19
  version_requirements: !ruby/object:Gem::Requirement
30
20
  requirements:
31
21
  - - ">="
32
22
  - !ruby/object:Gem::Version
33
- version: 1.1.4
23
+ version: 1.1.3
34
24
  version:
35
25
  - !ruby/object:Gem::Dependency
36
- name: json
37
- type: :runtime
26
+ name: hoe
27
+ type: :development
38
28
  version_requirement:
39
29
  version_requirements: !ruby/object:Gem::Requirement
40
30
  requirements:
41
31
  - - ">="
42
32
  - !ruby/object:Gem::Version
43
- version: 1.1.3
33
+ version: 2.3.3
44
34
  version:
45
- description: rtranslate is a simple, unofficial, ruby client API for using Google Translate.
35
+ description: A simple, unofficial, ruby client API for using Google Translate.
46
36
  email: yedingding@gmail.com
47
- executables: []
48
-
37
+ executables:
38
+ - rtranslate
49
39
  extensions: []
50
40
 
51
41
  extra_rdoc_files:
@@ -58,17 +48,18 @@ files:
58
48
  - Manifest.txt
59
49
  - README.txt
60
50
  - Rakefile
61
- - rtranslate.gemspec
62
51
  - bin/rtranslate
63
52
  - lib/rtranslate.rb
64
53
  - lib/rtranslate/language.rb
65
54
  - lib/rtranslate/rtranslate.rb
66
- - tests/ts_translate.rb
67
55
  - lib/rtranslate/detection.rb
56
+ - rtranslate.gemspec
57
+ - tests/ts_translate.rb
68
58
  - tests/ts_detection.rb
69
59
  has_rdoc: true
70
- homepage: http://sishen.lifegoo.com
71
- licenses:
60
+ homepage: http://github.com/sishen/rtranslate
61
+ licenses: []
62
+
72
63
  post_install_message:
73
64
  rdoc_options:
74
65
  - --main
@@ -89,10 +80,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
80
  version:
90
81
  requirements: []
91
82
 
92
- rubyforge_project:
83
+ rubyforge_project: sishen-rtranslate
93
84
  rubygems_version: 1.3.5
94
85
  signing_key:
95
- specification_version: 2
96
- summary: a simple, unofficial, ruby client API for using Google Translate
86
+ specification_version: 3
87
+ summary: Google translate ruby client api
97
88
  test_files: []
98
89