has_many_translations 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/History.txt +3 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/has_many_translations.gemspec +6 -5
- data/lib/has_many_translations/creation.rb +8 -9
- metadata +8 -7
data/.gitignore
CHANGED
data/History.txt
ADDED
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ begin
|
|
16
16
|
g.add_dependency 'activerecord', '>= 2.1.0'
|
17
17
|
g.add_development_dependency 'shoulda'
|
18
18
|
g.add_development_dependency 'mocha'
|
19
|
-
g.add_runtime_dependency 'artforge-rtranslate', '>=1.3.
|
19
|
+
g.add_runtime_dependency 'artforge-rtranslate', '>=1.3.3'
|
20
20
|
g.add_runtime_dependency 'activequeue'
|
21
21
|
g.add_runtime_dependency 'settingslogic'
|
22
22
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{has_many_translations}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["opengotham", "Artforge"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-08-02}
|
13
13
|
s.description = %q{Keep a DRY multilingual translation of your ActiveRecord models' textual attributes}
|
14
14
|
s.email = %q{adam@artforge.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
".gitignore",
|
20
|
+
"History.txt",
|
20
21
|
"README.rdoc",
|
21
22
|
"Rakefile",
|
22
23
|
"VERSION",
|
@@ -52,14 +53,14 @@ Gem::Specification.new do |s|
|
|
52
53
|
s.add_runtime_dependency(%q<activerecord>, [">= 2.1.0"])
|
53
54
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
54
55
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
55
|
-
s.add_runtime_dependency(%q<artforge-rtranslate>, [">= 1.3.
|
56
|
+
s.add_runtime_dependency(%q<artforge-rtranslate>, [">= 1.3.3"])
|
56
57
|
s.add_runtime_dependency(%q<activequeue>, [">= 0"])
|
57
58
|
s.add_runtime_dependency(%q<settingslogic>, [">= 0"])
|
58
59
|
else
|
59
60
|
s.add_dependency(%q<activerecord>, [">= 2.1.0"])
|
60
61
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
61
62
|
s.add_dependency(%q<mocha>, [">= 0"])
|
62
|
-
s.add_dependency(%q<artforge-rtranslate>, [">= 1.3.
|
63
|
+
s.add_dependency(%q<artforge-rtranslate>, [">= 1.3.3"])
|
63
64
|
s.add_dependency(%q<activequeue>, [">= 0"])
|
64
65
|
s.add_dependency(%q<settingslogic>, [">= 0"])
|
65
66
|
end
|
@@ -67,7 +68,7 @@ Gem::Specification.new do |s|
|
|
67
68
|
s.add_dependency(%q<activerecord>, [">= 2.1.0"])
|
68
69
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
69
70
|
s.add_dependency(%q<mocha>, [">= 0"])
|
70
|
-
s.add_dependency(%q<artforge-rtranslate>, [">= 1.3.
|
71
|
+
s.add_dependency(%q<artforge-rtranslate>, [">= 1.3.3"])
|
71
72
|
s.add_dependency(%q<activequeue>, [">= 0"])
|
72
73
|
s.add_dependency(%q<settingslogic>, [">= 0"])
|
73
74
|
end
|
@@ -62,10 +62,12 @@ module HasManyTranslations
|
|
62
62
|
if defined? Settings
|
63
63
|
@translator.key = Settings.google_api_key
|
64
64
|
end
|
65
|
+
|
65
66
|
def allowed_locales
|
66
67
|
t = TranslationSpec.first(:conditions => {:translated_id => self.id, :translated_type => self.class.to_s})
|
67
68
|
t.blank? ? nil : t.codes.split(',').map{|c| c.to_sym}
|
68
69
|
end
|
70
|
+
|
69
71
|
def locales=(codes)
|
70
72
|
t = TranslationSpec.first(:conditions => {:translated_id => self.id, :translated_type => self.class.to_s})
|
71
73
|
unless t.blank?
|
@@ -74,6 +76,7 @@ module HasManyTranslations
|
|
74
76
|
TranslationSpec.create(:translated_id => self.id, :translated_type => self.class.to_s, :codes => codes.map{|c|c.to_s}.join(','))
|
75
77
|
end
|
76
78
|
end
|
79
|
+
|
77
80
|
def localize=(loc)
|
78
81
|
@locale = loc
|
79
82
|
end
|
@@ -98,6 +101,7 @@ module HasManyTranslations
|
|
98
101
|
#!translation_changes.blank?
|
99
102
|
true
|
100
103
|
end
|
104
|
+
|
101
105
|
def create_translation_for_locale?(locale)
|
102
106
|
#determine if locale parameter is supported by this translated
|
103
107
|
# find out if we have a table created for all locales
|
@@ -109,7 +113,6 @@ module HasManyTranslations
|
|
109
113
|
|
110
114
|
# Creates a new translation upon updating the parent record.
|
111
115
|
def create_translation
|
112
|
-
|
113
116
|
translation.create(translation_attributes)
|
114
117
|
#reset_translation_changes
|
115
118
|
#reset_translation
|
@@ -145,6 +148,7 @@ module HasManyTranslations
|
|
145
148
|
update_translation(attrib, loc, origin_locale)
|
146
149
|
end
|
147
150
|
end
|
151
|
+
|
148
152
|
# Updates the last translation's changes by appending the current translation changes.
|
149
153
|
def update_translation(attrib, loc, origin_locale)
|
150
154
|
unless translations.first(:conditions => {:attribute => attrib, :locale_code => loc.to_s})
|
@@ -175,24 +179,19 @@ module HasManyTranslations
|
|
175
179
|
textual_columns = self.has_many_translations_options[:only] ? textual_columns & self.has_many_translations_options[:only] : textual_columns
|
176
180
|
textual_columns = self.has_many_translations_options[:except] ? textual_columns - self.has_many_translations_options[:except] : textual_columns
|
177
181
|
return textual_columns
|
178
|
-
|
179
182
|
end
|
183
|
+
|
180
184
|
def queue_translation(loc)
|
181
|
-
#ActiveQueue::Queue.enqueue(TranslationJobs::AutoTranslateJob,{ :translated_id => self.id, :translated_type => self.class.to_s, :origin_locale => self.hmt_locale, :destination_locale => loc })
|
182
185
|
ActiveQueue::Job.new(:val => { :translated_id => self.id, :translated_type => self.class.to_s, :origin_locale => self.hmt_locale, :destination_locale => loc },:job_klass => "TranslationJobs::AutoTranslateJob",:adapter => "resque").enqueue
|
183
|
-
#ActiveQueue::Job.new(:value => TranslationJobs::AutoTranslateJob.new(:translated_id => self.id, :translated_type => self.class.to_s, :origin_locale => self.hmt_locale, :destination_locale => loc), :adapter => "resque", :queue_name => :file_queue).enqueue
|
184
186
|
end
|
187
|
+
|
185
188
|
def queue_translations
|
186
189
|
self.locales.each do |loc|
|
187
190
|
queue_translation(loc)
|
188
191
|
end
|
189
|
-
# Resque.enqueue(TranslationJobs::MachineTranslationJob.new(self.id, self.type))
|
190
|
-
#ActiveQueue::Queue.enqueue(TranslationJobs::MachineTranslationJob,{:translated_id => self.id,:translated_type => self.type, :origin_locale => self.hmt_locale})
|
191
|
-
#Delayed::Job.enqueue(TranslationJobs::MachineTranslationJob.new({ :translated_id => self.id,:translated_type => self.class.to_s, :origin_locale => self.hmt_locale.to_s })
|
192
|
-
#job = TranslationJobs::MachineTranslationJob.new(self.id, self.type, self.hmt_locale)
|
193
192
|
end
|
193
|
+
|
194
194
|
def locales
|
195
|
-
|
196
195
|
if allowed_locales
|
197
196
|
retloc = allowed_locales.map{|l|l.to_s}
|
198
197
|
elsif super_locales.present?
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_many_translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 6
|
10
|
+
version: 0.3.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- opengotham
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-08-02 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -71,12 +71,12 @@ dependencies:
|
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
hash:
|
74
|
+
hash: 29
|
75
75
|
segments:
|
76
76
|
- 1
|
77
77
|
- 3
|
78
|
-
-
|
79
|
-
version: 1.3.
|
78
|
+
- 3
|
79
|
+
version: 1.3.3
|
80
80
|
type: :runtime
|
81
81
|
version_requirements: *id004
|
82
82
|
- !ruby/object:Gem::Dependency
|
@@ -117,6 +117,7 @@ extra_rdoc_files:
|
|
117
117
|
- README.rdoc
|
118
118
|
files:
|
119
119
|
- .gitignore
|
120
|
+
- History.txt
|
120
121
|
- README.rdoc
|
121
122
|
- Rakefile
|
122
123
|
- VERSION
|