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 +3 -0
- data/bin/rtranslate +1 -1
- data/lib/rtranslate/rtranslate.rb +2 -2
- data/rtranslate.gemspec +1 -1
- data/tests/ts_translate.rb +18 -5
- metadata +3 -2
data/History.txt
CHANGED
data/bin/rtranslate
CHANGED
@@ -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
data/tests/ts_translate.rb
CHANGED
@@ -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
|
15
|
-
assert_equal("
|
16
|
-
assert_equal("
|
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.
|
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.
|
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
|