has_many_translations 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -4
- data/Gemfile.lock +8 -4
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/has_many_translations.gemspec +1 -1
- data/lib/has_many_translations.rb +1 -1
- data/lib/has_many_translations/creation.rb +11 -6
- data/lib/has_many_translations/hmt_settings.rb +7 -0
- data/lib/has_many_translations/options.rb +3 -2
- metadata +1 -1
data/Gemfile
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'artforge-rtranslate', '>=1.3.4'
|
4
|
+
gem 'to_lang'
|
5
|
+
gem 'activequeue'
|
6
|
+
gem 'settingslogic'
|
7
|
+
|
2
8
|
group :development do
|
3
9
|
gem 'activesupport'
|
4
10
|
gem 'activerecord'
|
@@ -7,10 +13,7 @@ group :development do
|
|
7
13
|
gem 'rspec'
|
8
14
|
gem 'cucumber'
|
9
15
|
gem 'launchy'
|
10
|
-
gem 'pickler'
|
16
|
+
# gem 'pickler'
|
11
17
|
gem 'jeweler'
|
12
18
|
end
|
13
19
|
|
14
|
-
gem 'artforge-rtranslate', '>=1.3.4'
|
15
|
-
gem 'activequeue'
|
16
|
-
gem 'settingslogic'
|
data/Gemfile.lock
CHANGED
@@ -27,6 +27,9 @@ GEM
|
|
27
27
|
gherkin (2.3.3)
|
28
28
|
json (~> 1.4.6)
|
29
29
|
git (1.2.5)
|
30
|
+
httparty (0.8.1)
|
31
|
+
multi_json
|
32
|
+
multi_xml
|
30
33
|
i18n (0.5.0)
|
31
34
|
jeweler (1.5.2)
|
32
35
|
bundler (~> 1.0.0)
|
@@ -38,9 +41,8 @@ GEM
|
|
38
41
|
rake (>= 0.8.1)
|
39
42
|
mocha (0.9.10)
|
40
43
|
rake
|
41
|
-
|
42
|
-
|
43
|
-
cucumber (>= 0.8.0)
|
44
|
+
multi_json (1.0.3)
|
45
|
+
multi_xml (0.4.1)
|
44
46
|
rake (0.8.7)
|
45
47
|
rspec (2.4.0)
|
46
48
|
rspec-core (~> 2.4.0)
|
@@ -53,6 +55,8 @@ GEM
|
|
53
55
|
settingslogic (2.0.6)
|
54
56
|
shoulda (2.11.3)
|
55
57
|
term-ansicolor (1.0.5)
|
58
|
+
to_lang (0.3.1)
|
59
|
+
httparty (~> 0.8.0)
|
56
60
|
tzinfo (0.3.23)
|
57
61
|
|
58
62
|
PLATFORMS
|
@@ -67,7 +71,7 @@ DEPENDENCIES
|
|
67
71
|
jeweler
|
68
72
|
launchy
|
69
73
|
mocha
|
70
|
-
pickler
|
71
74
|
rspec
|
72
75
|
settingslogic
|
73
76
|
shoulda
|
77
|
+
to_lang
|
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.6
|
@@ -167,13 +167,18 @@ module HasManyTranslations
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def update_translation!(attrib, loc, origin_locale, options = {})
|
170
|
-
@translator ||=
|
171
|
-
if defined? HmtSettings
|
172
|
-
|
170
|
+
@translator ||= ToLang.start(HmtSettings.google_api_key)
|
171
|
+
# if defined? HmtSettings
|
172
|
+
# @translator.key = HmtSettings.google_api_key
|
173
|
+
# end
|
174
|
+
# translation_val = @translator.translate(try(attrib), :from => origin_locale.to_s, :to => loc.to_s)
|
175
|
+
unless (loc.to_s == origin_locale.to_s)
|
176
|
+
unless try(attrib).nil?
|
177
|
+
translation_val = try(attrib).translate(loc.to_s, :from => origin_locale.to_s)
|
178
|
+
# TODO: Should this be "find_or_create"?
|
179
|
+
translations.create(:model_attribute => attrib, :locale_code => loc.to_s, :value => translation_val, :locale_name => Google::Language::Languages[loc.to_s], :machine_translation => true, :origin_locale_code => origin_locale ) unless translation_val.nil? || translation_val.match('Error: ')
|
180
|
+
end
|
173
181
|
end
|
174
|
-
translation_val = @translator.translate(try(attrib), :from => origin_locale.to_s, :to => loc.to_s)
|
175
|
-
# TODO: Should this be "find_or_create"?
|
176
|
-
translations.create(:model_attribute => attrib, :locale_code => loc.to_s, :value => translation_val, :locale_name => Google::Language::Languages[loc.to_s], :machine_translation => true, :origin_locale_code => origin_locale ) unless translation_val.nil? || translation_val.match('Error: ')
|
177
182
|
end
|
178
183
|
|
179
184
|
|
@@ -2,6 +2,7 @@ class HmtSettings
|
|
2
2
|
@@google_api_key = ""
|
3
3
|
@@languages = []
|
4
4
|
@@default_languages = []
|
5
|
+
@@queue_type = "resque"
|
5
6
|
|
6
7
|
def self.google_api_key=(key)
|
7
8
|
@@google_api_key = key
|
@@ -21,4 +22,10 @@ class HmtSettings
|
|
21
22
|
def self.default_languages
|
22
23
|
@@default_languages
|
23
24
|
end
|
25
|
+
def self.queue_type=(queue)
|
26
|
+
@@queue_type = queue
|
27
|
+
end
|
28
|
+
def self.queue_type
|
29
|
+
@@queue_type
|
30
|
+
end
|
24
31
|
end
|
@@ -32,9 +32,10 @@ module HasManyTranslations
|
|
32
32
|
)
|
33
33
|
class_inheritable_accessor :has_many_translations_options
|
34
34
|
class_inheritable_accessor :translator
|
35
|
-
self.translator = Translate::RTranslate.new
|
35
|
+
# self.translator = Translate::RTranslate.new
|
36
36
|
if defined? HmtSettings
|
37
|
-
|
37
|
+
ToLang.start(HmtSettings.google_api_key)
|
38
|
+
# self.translator.key = HmtSettings.google_api_key
|
38
39
|
options[:default_languages] = HmtSettings.default_languages ? HmtSettings.default_languages : nil
|
39
40
|
options[:languages] = HmtSettings.languages ? HmtSettings.languages : nil
|
40
41
|
# options[:force_on_update] = HmtSettings.force_on_update ? HmtSettings.force_on_update : nil
|