sishen-rtranslate 1.1 → 1.2

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.2 Sep 17th, 2009
2
+ * Enable the auto-detect source features of google translate api
3
+
1
4
  V1.1 July 11th, 2009
2
5
  * Add Google AJAX Language Dection support
3
6
 
data/bin/rtranslate CHANGED
@@ -34,7 +34,7 @@ end
34
34
  opts.parse!(ARGV)
35
35
  text = ARGV.shift
36
36
 
37
- unless (options[:detect] || (options[:from] && options[:to]) ) && text
37
+ unless (options[:detect] || options[:to] ) && text
38
38
  puts opts
39
39
  exit
40
40
  end
@@ -61,8 +61,8 @@ module Translate
61
61
  def translate(text, options = { })
62
62
  from = options[:from] || @default_from
63
63
  to = options[:to] || @default_to
64
- if Google::Language.supported?(from) && Google::Language.supported?(to)
65
- from = Google::Language.abbrev(from)
64
+ if (from.nil? || Google::Language.supported?(from)) && Google::Language.supported?(to)
65
+ from = from ? Google::Language.abbrev(from) : nil
66
66
  to = Google::Language.abbrev(to)
67
67
  langpair = "#{from}|#{to}"
68
68
  url = "#{GOOGLE_TRANSLATE_URL}?q=#{text}&langpair=#{langpair}&v=#{@version}"
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.1"
3
+ s.version = "1.2"
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"]
@@ -9,14 +9,27 @@ class Translate::TranslateTest < Test::Unit::TestCase
9
9
  def test_english_translate
10
10
  assert_equal("مرحبا العالم", Translate.t("Hello world", "ENGLISH", "ARABIC"));
11
11
  assert_equal("世界您好", Translate.t("Hello world", "ENGLISH", "CHINESE_SIMPLIFIED"));
12
- assert_equal("Bonjour le monde", Translate.t("Hello world", "ENGLISH", "FRENCH"));
12
+ assert_equal("Bonjour tout le monde", Translate.t("Hello world", "ENGLISH", "FRENCH"));
13
13
  assert_equal("Hallo Welt", Translate.t("Hello world", "ENGLISH", "GERMAN"));
14
- assert_equal("Ciao mondo", Translate.t("Hello world", "ENGLISH", "ITALIAN"));
15
- assert_equal("こんにちは世界", Translate.t("Hello world", "ENGLISH", "JAPANESE"));
16
- assert_equal("여보세요 세계", Translate.t("Hello world", "ENGLISH", "KOREAN"));
14
+ assert_equal("Ciao a tutti", Translate.t("Hello world", "ENGLISH", "ITALIAN"));
15
+ assert_equal("こんにちは、世界", Translate.t("Hello world", "ENGLISH", "JAPANESE"));
16
+ assert_equal("안녕하세요 세상", Translate.t("Hello world", "ENGLISH", "KOREAN"));
17
17
  assert_equal("Olá mundo", Translate.t("Hello world", "ENGLISH", "PORTUGUESE"));
18
18
  assert_equal("Привет мир", Translate.t("Hello world", "ENGLISH", "RUSSIAN"));
19
- assert_equal("Hola mundo", Translate.t("Hello world", "ENGLISH", "SPANISH"));
19
+ assert_equal("¡Hola, mundo", Translate.t("Hello world", "ENGLISH", "SPANISH"));
20
+ end
21
+
22
+ def test_auto_detect_translate
23
+ assert_equal("مرحبا العالم", Translate.t("Hello world", nil, "ARABIC"));
24
+ assert_equal("世界您好", Translate.t("Hello world", nil, "CHINESE_SIMPLIFIED"));
25
+ assert_equal("Bonjour tout le monde", Translate.t("Hello world", nil, "FRENCH"));
26
+ assert_equal("Hallo Welt", Translate.t("Hello world", nil, "GERMAN"));
27
+ assert_equal("Ciao a tutti", Translate.t("Hello world", nil, "ITALIAN"));
28
+ assert_equal("こんにちは、世界", Translate.t("Hello world", nil, "JAPANESE"));
29
+ assert_equal("안녕하세요 세상", Translate.t("Hello world", nil, "KOREAN"));
30
+ assert_equal("Olá mundo", Translate.t("Hello world", nil, "PORTUGUESE"));
31
+ assert_equal("Привет мир", Translate.t("Hello world", nil, "RUSSIAN"));
32
+ assert_equal("¡Hola, mundo", Translate.t("Hello world", nil, "SPANISH"));
20
33
  end
21
34
 
22
35
  def test_chinese_translate
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.1"
4
+ version: "1.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ye Dingding
@@ -68,6 +68,7 @@ files:
68
68
  - tests/ts_detection.rb
69
69
  has_rdoc: true
70
70
  homepage: http://sishen.lifegoo.com
71
+ licenses:
71
72
  post_install_message:
72
73
  rdoc_options:
73
74
  - --main
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  requirements: []
90
91
 
91
92
  rubyforge_project:
92
- rubygems_version: 1.2.0
93
+ rubygems_version: 1.3.5
93
94
  signing_key:
94
95
  specification_version: 2
95
96
  summary: a simple, unofficial, ruby client API for using Google Translate