air18n 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -158,7 +158,7 @@ module Air18n
158
158
  # If it doesn't, we need to update the 'phrases' table so that
159
159
  # the 'value' column reflects the latest English default text.
160
160
  if result.present?
161
- LoggingHelper.info "Default English text for key '#{key}' changed! Old default '#{result}' != new default '#{default}'. Route context: #{options[:routes_context]}"
161
+ LoggingHelper.info "Default #{I18n.default_locale} text for key '#{key}' changed! Old default '#{result}' != new default '#{default}'. Route context: #{options[:routes_context]}"
162
162
  end
163
163
  phrase = Phrase.find_or_create_by_key(key)
164
164
  if phrase
@@ -247,6 +247,13 @@ module Air18n
247
247
  end
248
248
 
249
249
  def check_matching_variables
250
+ if /maxlength:(\d+)/ =~ key
251
+ max_length = $1.to_i
252
+ length = value.size
253
+ if length > max_length
254
+ self.errors.add(:value, "Translation has #{length} characters; maximum length #{max_length} characters.")
255
+ end
256
+ end
250
257
  unless variables_match?
251
258
  our_variables = self.variables
252
259
  their_variables = self.phrase.variables
@@ -1,3 +1,3 @@
1
1
  module Air18n
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/make_gem CHANGED
@@ -1,5 +1,5 @@
1
1
  # Run this to push the new version of the gem to rubygems!
2
- v=0.1.2
2
+ v=0.1.3
3
3
  gem build air18n.gemspec
4
4
  gem push air18n-${v}.gem
5
5
 
@@ -22,4 +22,18 @@ describe Air18n::PhraseTranslation do
22
22
  end
23
23
  end
24
24
 
25
+ context 'validations' do
26
+ it 'Should check maximum length' do
27
+ translation = FactoryGirl.create(:phrase_translation, :key => 'facebook description maxlength:10', :value => 'short')
28
+ validated = translation.save
29
+ validated.should == true
30
+ translation.value = 'too looooong'
31
+ translation.save.should be_false
32
+ translation.errors.should == { :value => ["Translation has 12 characters; maximum length 10 characters."] }
33
+
34
+ translation = FactoryGirl.create(:phrase_translation, :key => 'facebook description maxlength:0', :value => 'short')
35
+ validated = translation.save
36
+ end
37
+ end
38
+
25
39
  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.1.2
4
+ version: 0.1.3
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-07-20 00:00:00.000000000 Z
16
+ date: 2012-07-26 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: i18n