air18n 0.4.12 → 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,7 +30,10 @@ module Air18n
30
30
  def store_translations locale, data, options = {}
31
31
  @translation_data ||= {}
32
32
  @translation_data[locale.to_sym] = data
33
- ChunkCache::set(I18n.cache, T_DATA % locale, data, 1.day) if I18n.cache
33
+ # We pass in nil for the expiry because we do not want the translations to
34
+ # be expired. Rather we prefer to explicitily overwrite them when reload
35
+ # translations is called.
36
+ ChunkCache::set(I18n.cache, T_DATA % locale, data, nil) if I18n.cache
34
37
  end
35
38
 
36
39
  def available_locales
@@ -128,8 +131,6 @@ module Air18n
128
131
  if (translation_last_loaded_at.nil?) || (last_updated_at && last_updated_at.to_i >= translation_last_loaded_at.to_i)
129
132
  I18n.cache.write(T_LAST_LOADED_AT % locale, Time.now + RACE_CONDITION_TTL) if I18n.cache
130
133
  reload_translations([locale])
131
- else
132
- get_from_cache_or_reload(locale)
133
134
  end
134
135
  end
135
136
  end
@@ -39,7 +39,12 @@ module Air18n
39
39
  existing_phrase = Phrase.
40
40
  where(:value => self.value).
41
41
  where('`phrases`.id < ?', self.id).
42
- last
42
+ order('id DESC').
43
+ all.
44
+ find { |p| p.value == self.value } # Make sure we don't copy from a phrase with different
45
+ # capitalization (that matched query because of DB
46
+ # collation)
47
+
43
48
  if existing_phrase.present?
44
49
  translations = PhraseTranslation.
45
50
  where(:phrase_id => existing_phrase.id).
@@ -1,3 +1,3 @@
1
1
  module Air18n
2
- VERSION = "0.4.12"
2
+ VERSION = "0.4.13"
3
3
  end
@@ -56,6 +56,9 @@ describe Air18n::Phrase do
56
56
  @phrase2.phrase_translations.first.user_id.should == 0
57
57
 
58
58
  @phrase2.latest_translation(:"zh-TW").id.should < @phrase2.latest_translation(:zh).id
59
+
60
+ @phrase3 = FactoryGirl.create(:phrase, :key => 'copying, key 3', :value => 'Copying, Value 1')
61
+ @phrase3.phrase_translations.size.should == 0
59
62
  end
60
63
  end
61
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: air18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-05-30 00:00:00.000000000 Z
16
+ date: 2013-06-19 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: i18n
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
- rubygems_version: 1.8.24
224
+ rubygems_version: 1.8.23
225
225
  signing_key:
226
226
  specification_version: 3
227
227
  summary: Dynamic I18n backend