rufregle 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/helper/webhelper.rb +12 -0
- data/lib/rufregle.rb +25 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f06e6e84f18a7567e132b714c4aab615f092a4e1
|
4
|
+
data.tar.gz: d6a2225db918656a25fccb30578d69eb781d9666
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e9bcc4ec84f830b1cdc15af251a4424988e8eb81387977c8d41391816bb24c5eff1a22addbaca6979986d79907614d9b9429d9ee18080444560482176c71ee2
|
7
|
+
data.tar.gz: 9f086559b60b75a04e73b89f2575f4d9e1444d443056718419943eb7a7a2535cfaa92e175c0a8e57e23fca4416792d0bb0473f5af1e3175742a5004247a397ef
|
data/lib/rufregle.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
class Rufregle
|
4
|
+
|
5
|
+
GOOGLE_URL_API = "http://translate.google.com/translate_a/"
|
6
|
+
GOOGLE_PARAMS = "t?client=t&text=%s&hl=%s&sl=%s&tl=%s&ie=UTF-8&oe=UTF-8&multires=1&otf=1&ssel=3&tsel=3&sc=1"
|
7
|
+
|
8
|
+
def self.translate(text_to_translate, language_from, language_to)
|
9
|
+
|
10
|
+
text_encoded = URI::encode(text_to_translate)
|
11
|
+
|
12
|
+
parameters = GOOGLE_PARAMS % [ text_encoded , language_from, language_from, language_to ]
|
13
|
+
url = GOOGLE_URL_API << parameters
|
14
|
+
|
15
|
+
raw_translated = WebHelper.acess_url(url)
|
16
|
+
|
17
|
+
raw_translated = raw_translated.force_encoding('utf-8')
|
18
|
+
|
19
|
+
text_hash = raw_translated.scan(/\"(.*?)\"/).to_a
|
20
|
+
|
21
|
+
text_hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
require_relative 'helper/webhelper.rb'
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rufregle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cristian Oliveira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Simple Free google translate.
|
14
|
+
email: contato@cristianoliveira.com.br
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/helper/webhelper.rb
|
20
|
+
- lib/rufregle.rb
|
21
|
+
homepage: https://github.com/CristianOliveiraDaRosa/rufregle-translate
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.2.2
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Free google translate!
|
45
|
+
test_files: []
|