acts_as_translatable 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/acts_as_translatable/class_methods.rb +11 -3
- metadata +39 -20
@@ -5,9 +5,13 @@ module ActsAsTranslatable
|
|
5
5
|
after_save :save_translations
|
6
6
|
has_many :record_translations, :foreign_key => :translatable_id, :conditions => { :translatable_type => name}, :dependent => :destroy
|
7
7
|
default_scope :include => :record_translations
|
8
|
-
|
9
|
-
# loop through fields to define methods such as "name" and "
|
8
|
+
|
9
|
+
# loop through fields to define methods such as "name", "description", and "find_by_name"
|
10
10
|
fields.each do |field|
|
11
|
+
self.class.send :define_method, "find_by_#{field}" do |content|
|
12
|
+
where(["record_translations.locale = ? AND record_translations.content = ?", I18n.locale, content])
|
13
|
+
end
|
14
|
+
|
11
15
|
define_method "#{field}" do
|
12
16
|
get_field_content(I18n.locale, field)
|
13
17
|
end
|
@@ -20,8 +24,12 @@ module ActsAsTranslatable
|
|
20
24
|
set_field_content(I18n.locale, field, content)
|
21
25
|
end
|
22
26
|
|
23
|
-
# loop through fields to define methods such as "name_en" and "
|
27
|
+
# loop through fields to define methods such as "name_en", "name_es", and "find_by_name_en"
|
24
28
|
I18n.available_locales.each do |locale|
|
29
|
+
self.class.send :define_method, "find_by_#{field}_#{locale}" do |content|
|
30
|
+
where(["record_translations.locale = ? AND record_translations.content = ?", locale, content])
|
31
|
+
end
|
32
|
+
|
25
33
|
define_method "#{field}_#{locale}" do
|
26
34
|
get_field_content(locale, field)
|
27
35
|
end
|
metadata
CHANGED
@@ -1,22 +1,32 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_translatable
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Lasse Bunk
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-06-23 00:00:00 Z
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description: Ruby on Rails plugin for easy translation of database fields.
|
15
22
|
email: lassebunk@gmail.com
|
16
23
|
executables: []
|
24
|
+
|
17
25
|
extensions: []
|
26
|
+
|
18
27
|
extra_rdoc_files: []
|
19
|
-
|
28
|
+
|
29
|
+
files:
|
20
30
|
- lib/acts_as_translatable/class_methods.rb
|
21
31
|
- lib/acts_as_translatable/record_translation.rb
|
22
32
|
- lib/acts_as_translatable.rb
|
@@ -24,27 +34,36 @@ files:
|
|
24
34
|
- lib/generators/acts_as_translatable/templates/migration.rb
|
25
35
|
homepage: http://github.com/lassebunk/acts_as_translatable
|
26
36
|
licenses: []
|
37
|
+
|
27
38
|
post_install_message:
|
28
39
|
rdoc_options: []
|
29
|
-
|
40
|
+
|
41
|
+
require_paths:
|
30
42
|
- lib
|
31
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
44
|
none: false
|
33
|
-
requirements:
|
34
|
-
- -
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
|
37
|
-
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: 3
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
53
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
43
61
|
requirements: []
|
62
|
+
|
44
63
|
rubyforge_project:
|
45
|
-
rubygems_version: 1.8.
|
64
|
+
rubygems_version: 1.8.24
|
46
65
|
signing_key:
|
47
66
|
specification_version: 3
|
48
|
-
summary: acts_as_translatable is a Ruby on Rails plugin for easy translation of database
|
49
|
-
fields.
|
67
|
+
summary: acts_as_translatable is a Ruby on Rails plugin for easy translation of database fields.
|
50
68
|
test_files: []
|
69
|
+
|