t2etranslator 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +5 -1
- data/lib/t2etranslator.rb +7 -3
- metadata +1 -1
data/README
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
English to tamil translator:
|
2
2
|
Usage:
|
3
|
-
|
3
|
+
|
4
|
+
gem "t2etranslator" #include gem
|
4
5
|
|
5
6
|
This will print "love" in tamil as "அன்பு"
|
6
7
|
|
@@ -15,3 +16,6 @@ puts T2etranslator.translate("Love", "hi");
|
|
15
16
|
|
16
17
|
This will print as "प्यार" (pyar)
|
17
18
|
|
19
|
+
Note: This code translates with use of google translate. Feel free to give suggestion and change code.
|
20
|
+
|
21
|
+
Email me at: sathia2704@gmail.com
|
data/lib/t2etranslator.rb
CHANGED
@@ -3,9 +3,13 @@ require 'nokogiri'
|
|
3
3
|
require 'open-uri'
|
4
4
|
class Translator
|
5
5
|
def self.translate(context, default = "ta")
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
begin
|
7
|
+
page = Nokogiri::HTML(open(URI.parse(URI.encode("http://translate.google.com/?langpair=en|#{default}&text=#{context}"))))
|
8
|
+
result = page.search("#result_box")
|
9
|
+
result.text
|
10
|
+
rescue SocketError
|
11
|
+
context
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|