yatran 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,8 +18,6 @@ Examples
18
18
  => "Ciao, mondo!"
19
19
  1.9.2p320 :007 > "Hello world".en_ru.ru_it.language
20
20
  => "it"
21
- 1.9.2p320 :008 > Yatran::LANGUAGES_TRANSLATIONS
22
- => ["ru-en", "ru-pl", "ru-uk", "ru-de", "ru-fr", "ru-es", "ru-it", "ru-tr", "en-ru", "en-uk", "en-tr", "pl-ru", "uk-ru", "uk-en", "de-ru", "fr-ru", "es-ru", "it-ru", "tr-ru", "tr-en"]
23
21
  1.9.2p320 :009 > "Hello world".respond_to?("en_ru")
24
22
  => true
25
23
  1.9.2p320 :010 > "Hello world".respond_to?("from_en_to_ru")
@@ -29,6 +27,33 @@ Examples
29
27
 
30
28
 
31
29
 
30
+ Arrays also includes Yatran::Translatable module
31
+
32
+ 1.9.3p125 :015 > ["hello", "goodbye"].en_tr
33
+ => ["merhaba", "elveda"]
34
+ 1.9.3p125 :017 > ["hello", "goodbye"].from_en_to_ru
35
+ => ["Привет", "до свидания"]
36
+
37
+
38
+ Direct translate method
39
+
40
+ 1.9.3p125 :008 > ["hello", "goodbye"].translate('en-tr')
41
+ => ["merhaba", "elveda"]
42
+ 1.9.3p125 :009 > "hello".translate("en-tr")
43
+ => "merhaba"
44
+
45
+
46
+ Avaliable directions
47
+
48
+ 1.9.3p125 :031 > String.translation_directions
49
+ => ["ru-en", "ru-pl", "ru-uk", "ru-de", "ru-fr", "ru-es", "ru-it", "ru-tr", "en-ru", "en-uk", "en-tr", "pl-ru", "uk-ru", "uk-en", "de-ru", "fr-ru", "es-ru", "it-ru", "tr-ru", "tr-en"]
50
+ 1.9.3p125 :032 > Array.translation_directions
51
+ => ["ru-en", "ru-pl", "ru-uk", "ru-de", "ru-fr", "ru-es", "ru-it", "ru-tr", "en-ru", "en-uk", "en-tr", "pl-ru", "uk-ru", "uk-en", "de-ru", "fr-ru", "es-ru", "it-ru", "tr-ru", "tr-en"]
52
+ 1.9.3p125 :033 > Yatran::LANGUAGES_TRANSLATIONS
53
+ => ["ru-en", "ru-pl", "ru-uk", "ru-de", "ru-fr", "ru-es", "ru-it", "ru-tr", "en-ru", "en-uk", "en-tr", "pl-ru", "uk-ru", "uk-en", "de-ru", "fr-ru", "es-ru", "it-ru", "tr-ru", "tr-en"]
54
+
55
+
56
+
32
57
 
33
58
  ## Installation
34
59
 
data/bin/yatran CHANGED
@@ -7,14 +7,8 @@ require 'yatran'
7
7
  require "yatran/cli"
8
8
  require 'optparse'
9
9
 
10
-
11
-
12
-
13
-
14
-
15
10
  tranlsator = Yatran::CLI.new
16
11
  options = tranlsator.instance_variable_get(:@options)
17
- #exit
18
12
 
19
13
  case ARGV[0]
20
14
  when "d"
@@ -32,10 +26,8 @@ when "t"
32
26
  p e.message
33
27
  end
34
28
  else
35
- puts "Undefined command #{ARGV[0]}"
36
- #
29
+ puts "Undefined command #{ARGV[0]}"
37
30
  exit
38
-
39
31
  end
40
32
 
41
33
 
@@ -26,10 +26,17 @@ module Yatran
26
26
  module Translatable
27
27
 
28
28
 
29
- def translate(translation_direction)
29
+ def self.included(base)
30
+
31
+ base.extend ClassMethods
32
+
33
+ end
30
34
 
31
- API.request('translate', {:lang=> translation_direction, :text=>self})['text'][0]
32
35
 
36
+ def translate(translation_direction)
37
+ response = API.request('translate', {:lang=> translation_direction, :text=>self})['text']
38
+ response = response[0] unless self.kind_of? Array
39
+ response
33
40
  end
34
41
 
35
42
 
@@ -82,5 +89,15 @@ module Yatran
82
89
  end
83
90
 
84
91
 
92
+
93
+ module ClassMethods
94
+
95
+ def translation_directions
96
+ LANGUAGES_TRANSLATIONS
97
+ end
98
+
99
+ end
100
+
101
+
85
102
  end
86
103
  end
@@ -21,5 +21,5 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
  module Yatran
24
- VERSION = "0.1.1"
24
+ VERSION = "0.1.2"
25
25
  end
data/lib/yatran.rb CHANGED
@@ -33,6 +33,11 @@ require "yatran/translatable"
33
33
  require "yatran/detectable"
34
34
 
35
35
 
36
- String.send :include, Yatran::Translatable
37
- String.send :include, Yatran::Detectable
36
+ String.class_eval do
37
+ include Yatran::Translatable
38
+ include Yatran::Detectable
39
+ end
38
40
 
41
+ Array.class_eval do
42
+ include Yatran::Translatable
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yatran
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70148916838960 !ruby/object:Gem::Requirement
16
+ requirement: &70329696019000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70148916838960
24
+ version_requirements: *70329696019000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70148916838000 !ruby/object:Gem::Requirement
27
+ requirement: &70329696018460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70148916838000
35
+ version_requirements: *70329696018460
36
36
  description: ! 'unofficial http://api.yandex.ru/translate API Client for ruby '
37
37
  email:
38
38
  - fedoronchuk@gmail.com