translatable_ar 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,7 +40,11 @@ class TranslatableAR
40
40
  def define_translatable_ar_reader(attribute)
41
41
  define_method("#{attribute}") do
42
42
  if respond_to?("#{attribute}_i18n")
43
- send("#{attribute}_i18n")[I18n.locale.to_s]
43
+ if send("#{attribute}_i18n").has_key?(I18n.locale.to_s)
44
+ send("#{attribute}_i18n")[I18n.locale.to_s]
45
+ else
46
+ send("#{attribute}_i18n")[TranslatableAR.fallback_locale.to_s]
47
+ end
44
48
  else
45
49
  super()
46
50
  end
@@ -1,7 +1,7 @@
1
1
  class TranslatableAR
2
2
 
3
3
  class << self
4
- attr_accessor :models, :coder_or_default_object
4
+ attr_accessor :models, :coder_or_default_object, :fallback_locale
5
5
  def coder_or_default_object
6
6
  @coder_or_default_object ||= Hash
7
7
  end
@@ -14,6 +14,9 @@ class TranslatableAR
14
14
  def use_hstore!
15
15
  @coder_or_default_object = ActiveRecord::Coders::Hstore
16
16
  end
17
+ def fallback_locale=(locale)
18
+ @fallback_locale = locale
19
+ end
17
20
  end
18
21
 
19
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translatable_ar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-18 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord