gtranslate-two 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +85 -1
  2. data/VERSION +1 -1
  3. data/gtranslate-two.gemspec +2 -2
  4. metadata +4 -4
data/README.rdoc CHANGED
@@ -1,6 +1,90 @@
1
1
  = gtranslate-two
2
2
 
3
- Something funny.
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'
4
88
 
5
89
  == Contributing to gtranslate-two
6
90
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gtranslate-two}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
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"]
12
- s.date = %q{2011-01-19}
12
+ s.date = %q{2011-01-23}
13
13
  s.description = %q{This is a super-simple Ruby client for Google Translate API v2. You will need the developer key to work with it.}
14
14
  s.email = %q{marcin.pixie@gmail.com}
15
15
  s.extra_rdoc_files = [
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcin Wyszynski
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-19 00:00:00 +00:00
18
+ date: 2011-01-23 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency