acts_as_translatable 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/acts_as_translatable/active_record.rb +17 -2
- metadata +4 -4
@@ -40,8 +40,23 @@ class ActiveRecord::Base
|
|
40
40
|
fields.each do |field|
|
41
41
|
eval "class ::#{name}
|
42
42
|
def #{field}
|
43
|
-
|
44
|
-
|
43
|
+
# get I18n fallbacks
|
44
|
+
if I18n.respond_to?(:fallbacks)
|
45
|
+
locales = I18n.fallbacks[I18n.locale]
|
46
|
+
else
|
47
|
+
locales = [I18n.locale]
|
48
|
+
end
|
49
|
+
|
50
|
+
# fallbacks
|
51
|
+
locales.each do |locale|
|
52
|
+
if fields = translations[locale]
|
53
|
+
content = fields[\"#{field}\"]
|
54
|
+
return content if content
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# none found
|
59
|
+
return nil
|
45
60
|
end
|
46
61
|
|
47
62
|
def #{field}?
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_translatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lasse Bunk
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-16 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Ruby on Rails plugin for easy translation of database fields.
|