air18n 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/air18n/phrase_translation.rb +7 -0
- data/lib/air18n/version.rb +1 -1
- data/make_gem +1 -1
- data/spec/lib/air18n/phrase_translation_spec.rb +8 -0
- metadata +2 -2
@@ -12,6 +12,7 @@ module Air18n
|
|
12
12
|
scope :up_to_date, lambda { where(:is_stale => false) }
|
13
13
|
|
14
14
|
before_create :set_latest
|
15
|
+
before_create :set_source_hash
|
15
16
|
|
16
17
|
validate :check_matching_variables
|
17
18
|
|
@@ -33,6 +34,12 @@ module Air18n
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
# Sets the source_word_count and source_hash fields.
|
38
|
+
def set_source_hash
|
39
|
+
self.source_word_count = PhraseTranslation.segment(phrase.value).size
|
40
|
+
self.source_hash = Digest::MD5.new.update(phrase.value).to_s
|
41
|
+
end
|
42
|
+
|
36
43
|
# Provides a complete set of latest translations for specified locales, in nested hash format.
|
37
44
|
# filter_opts are passed to keep_key? for optional filtering, like throwing
|
38
45
|
# away user-generated content.
|
data/lib/air18n/version.rb
CHANGED
data/make_gem
CHANGED
@@ -24,6 +24,14 @@ describe Air18n::PhraseTranslation do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
context 'source hash' do
|
28
|
+
it "PhraseTranslation Should get unset when a new translation is made" do
|
29
|
+
original_translation = FactoryGirl.create(:phrase_translation)
|
30
|
+
original_translation.source_word_count.should == 3
|
31
|
+
original_translation.source_hash.should == "e2c1628507c9d0dfd6469a9196370b84"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
27
35
|
context 'validations' do
|
28
36
|
it 'Should check maximum length' do
|
29
37
|
translation = FactoryGirl.create(:phrase_translation, :key => 'facebook description maxlength:10', :value => 'short')
|
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.1.
|
4
|
+
version: 0.1.9
|
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: 2012-09-
|
16
|
+
date: 2012-09-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: i18n
|