gtranslate-two 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.rdoc +118 -0
  2. data/VERSION +1 -1
  3. data/gtranslate-two.gemspec +3 -3
  4. metadata +5 -5
  5. data/README +0 -103
data/README.rdoc ADDED
@@ -0,0 +1,118 @@
1
+ = gtranslate-two
2
+
3
+ This is a simple Ruby gem designed to use Google Translate API v2 - unlike other gems which use the first version of the API.
4
+
5
+ Also unlike other available gems, this one requires the use of an API key, which you can get from the {Google APIs console} [https://code.google.com/apis/console/].
6
+
7
+ == Usage
8
+
9
+ === First, require the gem
10
+ require 'gtranslate-two'
11
+
12
+ === Second, set your API key
13
+ GTranslator.key = 'YOUR_GOOGLE_TRANSLATE_KEY'
14
+
15
+ === Example - translation with known language
16
+ Now, let's try translating something from English to Icelandic
17
+
18
+ GTranslator.translate('Hello world', GLanguage::Icelandic, GLanguage::English)
19
+
20
+ The result (in irb console) should look something like this:
21
+ <GTranslatorResult:0x1013e8558 @original="Hello world", @source="en", @translation="Hall\303\263 heimur", @target="is">
22
+
23
+ As you can see, the result is a GTranslatorResult object with properties:
24
+ * original (the original query)
25
+ * source (source language)
26
+ * translation (translated query)
27
+ * target (target language)
28
+
29
+ === Example - translation without known language
30
+ The gem also supports Google Translate language detection mechanism. Let's imagine we did not know the source language but still wanted to translate the phrase to, say, Irish.
31
+
32
+ To do that, we'll basically leave out the third argument in the translate method, falling back on automatic language detection:
33
+
34
+ GTranslator.translate('Hello world', GLanguage::Irish)
35
+
36
+ The result (in irb console) should look somewhat like this:
37
+
38
+ #<GTranslatorResult:0x1013dced8 @original="Hello world", @source="en", @translation="Dia duit ar domhan", @target="ga">
39
+
40
+ As you can see, the result is a GTranslatorResult object with the same set of properties, only this time the source is determined automatically.
41
+
42
+ === Example - simple language detection
43
+ Last but not least the gem supports language detection operation (without translation)
44
+
45
+ GTranslator.detect_language('Mam na imie Marcin')
46
+
47
+ The result should be "pl"
48
+
49
+ The gem supports all languages supported by Google Translate API. They are implemented in the GLanguage module as constants:
50
+
51
+ GLanguage::Afrikaans = 'af'
52
+ GLanguage::Albanian = 'sq'
53
+ GLanguage::Arabic = 'ar'
54
+ GLanguage::Belarusian = 'be'
55
+ GLanguage::Bulgarian = 'bg'
56
+ GLanguage::Catalan = 'ca'
57
+ GLanguage::Chinese_Simplified = 'zh-CN'
58
+ GLanguage::Chinese_Traditional = 'zh-TW'
59
+ GLanguage::Croatian = 'hr'
60
+ GLanguage::Czech = 'cs'
61
+ GLanguage::Danish = 'da'
62
+ GLanguage::Dutch = 'nl'
63
+ GLanguage::English = 'en'
64
+ GLanguage::Estonian = 'et'
65
+ GLanguage::Filipino = 'tl'
66
+ GLanguage::Finnish = 'fi'
67
+ GLanguage::French = 'fr'
68
+ GLanguage::Galician = 'gl'
69
+ GLanguage::German = 'de'
70
+ GLanguage::Greek = 'el'
71
+ GLanguage::Haitian_Creole = 'ht'
72
+ GLanguage::Hebrew = 'iw'
73
+ GLanguage::Hindi = 'hi'
74
+ GLanguage::Hungarian = 'hu'
75
+ GLanguage::Icelandic = 'is'
76
+ GLanguage::Indonesian = 'id'
77
+ GLanguage::Irish = 'ga'
78
+ GLanguage::Italian = 'it'
79
+ GLanguage::Japanese = 'ja'
80
+ GLanguage::Latvian = 'lv'
81
+ GLanguage::Lithuanian = 'lt'
82
+ GLanguage::Macedonian = 'mk'
83
+ GLanguage::Malay = 'ms'
84
+ GLanguage::Maltese = 'mt'
85
+ GLanguage::Norwegian = 'no'
86
+ GLanguage::Persian = 'fa'
87
+ GLanguage::Polish = 'pl'
88
+ GLanguage::Portuguese = 'pt'
89
+ GLanguage::Romanian = 'ro'
90
+ GLanguage::Russian = 'ru'
91
+ GLanguage::Serbian = 'sr'
92
+ GLanguage::Slovak = 'sk'
93
+ GLanguage::Slovenian = 'sl'
94
+ GLanguage::Spanish = 'es'
95
+ GLanguage::Swahili = 'sw'
96
+ GLanguage::Swedish = 'sv'
97
+ GLanguage::Thai = 'th'
98
+ GLanguage::Turkish = 'tr'
99
+ GLanguage::Ukrainian = 'uk'
100
+ GLanguage::Vietnamese = 'vi'
101
+ GLanguage::Welsh = 'cy'
102
+ GLanguage::Yiddish = 'yi'
103
+
104
+ == Contributing to gtranslate-two
105
+
106
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
107
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
108
+ * Fork the project
109
+ * Start a feature/bugfix branch
110
+ * Commit and push until you are happy with your contribution
111
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
112
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
113
+
114
+ == Copyright
115
+
116
+ Copyright (c) 2011 Marcin Wyszynski. See LICENSE.txt for
117
+ further details.
118
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gtranslate-two}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcin Wyszynski"]
@@ -14,14 +14,14 @@ Gem::Specification.new do |s|
14
14
  s.email = %q{marcin.pixie@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  "Gemfile",
22
22
  "Gemfile.lock",
23
23
  "LICENSE.txt",
24
- "README",
24
+ "README.rdoc",
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "gtranslate-two.gemspec",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtranslate-two
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcin Wyszynski
@@ -86,13 +86,13 @@ extensions: []
86
86
 
87
87
  extra_rdoc_files:
88
88
  - LICENSE.txt
89
- - README
89
+ - README.rdoc
90
90
  files:
91
91
  - .document
92
92
  - Gemfile
93
93
  - Gemfile.lock
94
94
  - LICENSE.txt
95
- - README
95
+ - README.rdoc
96
96
  - Rakefile
97
97
  - VERSION
98
98
  - gtranslate-two.gemspec
data/README DELETED
@@ -1,103 +0,0 @@
1
- = gtranslate-two
2
-
3
- This is a simple Ruby gem designed to use Google Translate API v2 - unlike other gems which use the first version of the API. Also unlike other available gems, this one requires the use of an API key, which you can get from the Google APIs console (https://code.google.com/apis/console/).
4
-
5
- Basic use:
6
-
7
- # First, require the gem:
8
- require 'gtranslate-two'
9
-
10
- # Second, set your API key
11
- GTranslator.key = 'YOUR_GOOGLE_TRANSLATE_KEY'
12
-
13
- # Now, let's try translating something from English to Icelandic
14
- GTranslator.translate('Hello world', GLanguage::Icelandic, GLanguage::English)
15
- # The result (in irb console) should look something like this:
16
- #<GTranslatorResult:0x1013e8558 @original="Hello world", @source="en", @translation="Hall\303\263 heimur", @target="is">
17
- # As you can see, the result is a GTranslatorResult object with properties:
18
- # - original (the original query)
19
- # - source (source language)
20
- # - translation (translated query)
21
- # - target (target language)
22
-
23
- # The gem also supports Google Translate language detection mechanism. Let's imagine we did not know the source language but still wanted to translate the phrase to, say, Irish.
24
- # To do that, we'll basically leave out the third argument in the translate method, falling back on automatic language detection:
25
- GTranslator.translate('Hello world', GLanguage::Irish)
26
- # The result (in irb console) should look somewhat like this:
27
- #<GTranslatorResult:0x1013dced8 @original="Hello world", @source="en", @translation="Dia duit ar domhan", @target="ga">
28
- # As you can see, the result is a GTranslatorResult object with the same set of properties, only this time the source is determined automatically.
29
-
30
- # Last but not least the gem supports language detection operation (without translation)
31
- GTranslator.detect_language('Mam na imie Marcin')
32
- # The result should be "pl"
33
-
34
- # The gem supports all languages supported by Google Translate API. They are implemented in the GLanguage module as constants:
35
-
36
- GLanguage::Afrikaans = 'af'
37
- GLanguage::Albanian = 'sq'
38
- GLanguage::Arabic = 'ar'
39
- GLanguage::Belarusian = 'be'
40
- GLanguage::Bulgarian = 'bg'
41
- GLanguage::Catalan = 'ca'
42
- GLanguage::Chinese_Simplified = 'zh-CN'
43
- GLanguage::Chinese_Traditional = 'zh-TW'
44
- GLanguage::Croatian = 'hr'
45
- GLanguage::Czech = 'cs'
46
- GLanguage::Danish = 'da'
47
- GLanguage::Dutch = 'nl'
48
- GLanguage::English = 'en'
49
- GLanguage::Estonian = 'et'
50
- GLanguage::Filipino = 'tl'
51
- GLanguage::Finnish = 'fi'
52
- GLanguage::French = 'fr'
53
- GLanguage::Galician = 'gl'
54
- GLanguage::German = 'de'
55
- GLanguage::Greek = 'el'
56
- GLanguage::Haitian_Creole = 'ht'
57
- GLanguage::Hebrew = 'iw'
58
- GLanguage::Hindi = 'hi'
59
- GLanguage::Hungarian = 'hu'
60
- GLanguage::Icelandic = 'is'
61
- GLanguage::Indonesian = 'id'
62
- GLanguage::Irish = 'ga'
63
- GLanguage::Italian = 'it'
64
- GLanguage::Japanese = 'ja'
65
- GLanguage::Latvian = 'lv'
66
- GLanguage::Lithuanian = 'lt'
67
- GLanguage::Macedonian = 'mk'
68
- GLanguage::Malay = 'ms'
69
- GLanguage::Maltese = 'mt'
70
- GLanguage::Norwegian = 'no'
71
- GLanguage::Persian = 'fa'
72
- GLanguage::Polish = 'pl'
73
- GLanguage::Portuguese = 'pt'
74
- GLanguage::Romanian = 'ro'
75
- GLanguage::Russian = 'ru'
76
- GLanguage::Serbian = 'sr'
77
- GLanguage::Slovak = 'sk'
78
- GLanguage::Slovenian = 'sl'
79
- GLanguage::Spanish = 'es'
80
- GLanguage::Swahili = 'sw'
81
- GLanguage::Swedish = 'sv'
82
- GLanguage::Thai = 'th'
83
- GLanguage::Turkish = 'tr'
84
- GLanguage::Ukrainian = 'uk'
85
- GLanguage::Vietnamese = 'vi'
86
- GLanguage::Welsh = 'cy'
87
- GLanguage::Yiddish = 'yi'
88
-
89
- == Contributing to gtranslate-two
90
-
91
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
92
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
93
- * Fork the project
94
- * Start a feature/bugfix branch
95
- * Commit and push until you are happy with your contribution
96
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
97
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
98
-
99
- == Copyright
100
-
101
- Copyright (c) 2011 Marcin Wyszynski. See LICENSE.txt for
102
- further details.
103
-