Skip to content
Browse files

Favor %{} in all code instead of (deprecated) {{}} as interpolation s…

…yntax for I18n

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 8ae9b05 commit 9bd91b00b85c77bc294ae2a99beae203cc163227 @lawrencepit lawrencepit committed with josevalim May 3, 2010
View
2 actionpack/lib/action_view/helpers/form_helper.rb
@@ -1179,7 +1179,7 @@ def hidden_field(method, options = {})
# helpers:
# submit:
# post:
- # create: "Add {{model}}"
+ # create: "Add %{model}"
#
def submit(value=nil, options={})
value, options = nil, value if value.is_a?(Hash)
View
6 actionpack/test/template/form_helper_test.rb
@@ -33,11 +33,11 @@ def setup
I18n.backend.store_translations 'submit', {
:helpers => {
:submit => {
- :create => 'Create {{model}}',
- :update => 'Confirm {{model}} changes',
+ :create => 'Create %{model}',
+ :update => 'Confirm %{model} changes',
:submit => 'Save changes',
:another_post => {
- :update => 'Update your {{model}}'
+ :update => 'Update your %{model}'
}
}
}
View
2 activemodel/lib/active_model/validations/exclusion.rb
@@ -18,7 +18,7 @@ module ClassMethods
# class Person < ActiveRecord::Base
# validates_exclusion_of :username, :in => %w( admin superuser ), :message => "You don't belong here"
# validates_exclusion_of :age, :in => 30..60, :message => "This site is only for under 30 and over 60"
- # validates_exclusion_of :format, :in => %w( mov avi ), :message => "extension {{value}} is not allowed"
+ # validates_exclusion_of :format, :in => %w( mov avi ), :message => "extension %{value} is not allowed"
# end
#
# Configuration options:
View
2 activemodel/lib/active_model/validations/inclusion.rb
@@ -18,7 +18,7 @@ module ClassMethods
# class Person < ActiveRecord::Base
# validates_inclusion_of :gender, :in => %w( m f )
# validates_inclusion_of :age, :in => 0..99
- # validates_inclusion_of :format, :in => %w( jpg gif png ), :message => "extension {{value}} is not included in the list"
+ # validates_inclusion_of :format, :in => %w( jpg gif png ), :message => "extension %{value} is not included in the list"
# end
#
# Configuration options:
View
6 activemodel/lib/active_model/validations/length.rb
@@ -74,9 +74,9 @@ module ClassMethods
# * <tt>:in</tt> - A synonym(or alias) for <tt>:within</tt>.
# * <tt>:allow_nil</tt> - Attribute may be +nil+; skip validation.
# * <tt>:allow_blank</tt> - Attribute may be blank; skip validation.
- # * <tt>:too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (maximum is {{count}} characters)").
- # * <tt>:too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is {{count}} characters)").
- # * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt> method and the attribute is the wrong size (default is: "is the wrong length (should be {{count}} characters)").
+ # * <tt>:too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (maximum is %{count} characters)").
+ # * <tt>:too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is %{count} characters)").
+ # * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt> method and the attribute is the wrong size (default is: "is the wrong length (should be %{count} characters)").
# * <tt>:message</tt> - The error message to use for a <tt>:minimum</tt>, <tt>:maximum</tt>, or <tt>:is</tt> violation. An alias of the appropriate <tt>too_long</tt>/<tt>too_short</tt>/<tt>wrong_length</tt> message.
# * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
# * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should
View
24 activemodel/test/cases/validations/conditional_validation_test.rb
@@ -13,7 +13,7 @@ def teardown
def test_if_validation_using_method_true
# When the method returns true
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => :condition_is_true )
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => :condition_is_true )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
@@ -22,23 +22,23 @@ def test_if_validation_using_method_true
def test_unless_validation_using_method_true
# When the method returns true
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => :condition_is_true )
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => :condition_is_true )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert t.valid?
assert !t.errors[:title].any?
end
def test_if_validation_using_method_false
# When the method returns false
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => :condition_is_true_but_its_not )
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => :condition_is_true_but_its_not )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert t.valid?
assert t.errors[:title].empty?
end
def test_unless_validation_using_method_false
# When the method returns false
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => :condition_is_true_but_its_not )
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => :condition_is_true_but_its_not )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
@@ -47,7 +47,7 @@ def test_unless_validation_using_method_false
def test_if_validation_using_string_true
# When the evaluated string returns true
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => "a = 1; a == 1" )
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => "a = 1; a == 1" )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
@@ -56,23 +56,23 @@ def test_if_validation_using_string_true
def test_unless_validation_using_string_true
# When the evaluated string returns true
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => "a = 1; a == 1" )
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => "a = 1; a == 1" )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert t.valid?
assert t.errors[:title].empty?
end
def test_if_validation_using_string_false
# When the evaluated string returns false
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :if => "false")
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :if => "false")
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert t.valid?
assert t.errors[:title].empty?
end
def test_unless_validation_using_string_false
# When the evaluated string returns false
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}", :unless => "false")
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}", :unless => "false")
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
@@ -81,7 +81,7 @@ def test_unless_validation_using_string_false
def test_if_validation_using_block_true
# When the block returns true
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}",
:if => Proc.new { |r| r.content.size > 4 } )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
@@ -91,7 +91,7 @@ def test_if_validation_using_block_true
def test_unless_validation_using_block_true
# When the block returns true
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}",
:unless => Proc.new { |r| r.content.size > 4 } )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert t.valid?
@@ -100,7 +100,7 @@ def test_unless_validation_using_block_true
def test_if_validation_using_block_false
# When the block returns false
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}",
:if => Proc.new { |r| r.title != "uhohuhoh"} )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert t.valid?
@@ -109,7 +109,7 @@ def test_if_validation_using_block_false
def test_unless_validation_using_block_false
# When the block returns false
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}",
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}",
:unless => Proc.new { |r| r.title != "uhohuhoh"} )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
View
2 activemodel/test/cases/validations/exclusion_validation_test.rb
@@ -20,7 +20,7 @@ def test_validates_exclusion_of
end
def test_validates_exclusion_of_with_formatted_message
- Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => "option {{value}} is restricted" )
+ Topic.validates_exclusion_of( :title, :in => %w( abe monkey ), :message => "option %{value} is restricted" )
assert Topic.create("title" => "something", "content" => "abc")
View
2 activemodel/test/cases/validations/format_validation_test.rb
@@ -67,7 +67,7 @@ def test_validate_format_numeric
end
def test_validate_format_with_formatted_message
- Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => "can't be {{value}}")
+ Topic.validates_format_of(:title, :with => /^Valid Title$/, :message => "can't be %{value}")
t = Topic.create(:title => 'Invalid title')
assert_equal ["can't be Invalid title"], t.errors[:title]
end
View
14 activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
@@ -15,7 +15,7 @@ def test_generate_message_inclusion_with_default_message
end
def test_generate_message_inclusion_with_custom_message
- assert_equal 'custom message title', @person.errors.generate_message(:title, :inclusion, :default => 'custom message {{value}}', :value => 'title')
+ assert_equal 'custom message title', @person.errors.generate_message(:title, :inclusion, :default => 'custom message %{value}', :value => 'title')
end
# validates_exclusion_of: generate_message(attr_name, :exclusion, :default => configuration[:message], :value => value)
@@ -24,7 +24,7 @@ def test_generate_message_exclusion_with_default_message
end
def test_generate_message_exclusion_with_custom_message
- assert_equal 'custom message title', @person.errors.generate_message(:title, :exclusion, :default => 'custom message {{value}}', :value => 'title')
+ assert_equal 'custom message title', @person.errors.generate_message(:title, :exclusion, :default => 'custom message %{value}', :value => 'title')
end
# validates_format_of: generate_message(attr_name, :invalid, :default => configuration[:message], :value => value)
@@ -33,7 +33,7 @@ def test_generate_message_invalid_with_default_message
end
def test_generate_message_invalid_with_custom_message
- assert_equal 'custom message title', @person.errors.generate_message(:title, :invalid, :default => 'custom message {{value}}', :value => 'title')
+ assert_equal 'custom message title', @person.errors.generate_message(:title, :invalid, :default => 'custom message %{value}', :value => 'title')
end
# validates_confirmation_of: generate_message(attr_name, :confirmation, :default => configuration[:message])
@@ -78,7 +78,7 @@ def test_generate_message_too_long_with_default_message
end
def test_generate_message_too_long_with_custom_message
- assert_equal 'custom message 10', @person.errors.generate_message(:title, :too_long, :default => 'custom message {{count}}', :count => 10)
+ assert_equal 'custom message 10', @person.errors.generate_message(:title, :too_long, :default => 'custom message %{count}', :count => 10)
end
# validates_length_of: generate_message(attr, :too_short, :default => options[:too_short], :count => option_value.begin)
@@ -87,7 +87,7 @@ def test_generate_message_too_short_with_default_message
end
def test_generate_message_too_short_with_custom_message
- assert_equal 'custom message 10', @person.errors.generate_message(:title, :too_short, :default => 'custom message {{count}}', :count => 10)
+ assert_equal 'custom message 10', @person.errors.generate_message(:title, :too_short, :default => 'custom message %{count}', :count => 10)
end
# validates_length_of: generate_message(attr, key, :default => custom_message, :count => option_value)
@@ -96,7 +96,7 @@ def test_generate_message_wrong_length_with_default_message
end
def test_generate_message_wrong_length_with_custom_message
- assert_equal 'custom message 10', @person.errors.generate_message(:title, :wrong_length, :default => 'custom message {{count}}', :count => 10)
+ assert_equal 'custom message 10', @person.errors.generate_message(:title, :wrong_length, :default => 'custom message %{count}', :count => 10)
end
# validates_numericality_of: generate_message(attr_name, :not_a_number, :value => raw_value, :default => configuration[:message])
@@ -105,7 +105,7 @@ def test_generate_message_not_a_number_with_default_message
end
def test_generate_message_not_a_number_with_custom_message
- assert_equal 'custom message title', @person.errors.generate_message(:title, :not_a_number, :default => 'custom message {{value}}', :value => 'title')
+ assert_equal 'custom message title', @person.errors.generate_message(:title, :not_a_number, :default => 'custom message %{value}', :value => 'title')
end
# validates_numericality_of: generate_message(attr_name, option, :value => raw_value, :default => configuration[:message])
View
2 activemodel/test/cases/validations/i18n_validation_test.rb
@@ -58,7 +58,7 @@ def test_errors_full_messages_translates_human_attribute_name_for_model_attribut
end
def test_errors_full_messages_uses_format
- I18n.backend.store_translations('en', :errors => {:format => "Field {{attribute}} {{message}}"})
+ I18n.backend.store_translations('en', :errors => {:format => "Field %{attribute} %{message}"})
@person.errors.add('name', 'empty')
assert_equal ["Field Name empty"], @person.errors.full_messages
end
View
2 activemodel/test/cases/validations/inclusion_validation_test.rb
@@ -44,7 +44,7 @@ def test_validates_inclusion_of_with_allow_nil
end
def test_validates_inclusion_of_with_formatted_message
- Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => "option {{value}} is not in the list" )
+ Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ), :message => "option %{value} is not in the list" )
assert Topic.create("title" => "a", "content" => "abc").valid?
View
24 activemodel/test/cases/validations/length_validation_test.rb
@@ -138,7 +138,7 @@ def test_optionally_validates_length_of_using_within
end
def test_optionally_validates_length_of_using_within_on_create
- Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "my string is too long: {{count}}"
+ Topic.validates_length_of :title, :content, :within => 5..10, :on => :create, :too_long => "my string is too long: %{count}"
t = Topic.create("title" => "thisisnotvalid", "content" => "whatever")
assert !t.save
@@ -159,7 +159,7 @@ def test_optionally_validates_length_of_using_within_on_create
end
def test_optionally_validates_length_of_using_within_on_update
- Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "my string is too short: {{count}}"
+ Topic.validates_length_of :title, :content, :within => 5..10, :on => :update, :too_short => "my string is too short: %{count}"
t = Topic.create("title" => "vali", "content" => "whatever")
assert !t.save
@@ -230,31 +230,31 @@ def test_validates_length_of_nasty_params
end
def test_validates_length_of_custom_errors_for_minimum_with_message
- Topic.validates_length_of( :title, :minimum=>5, :message=>"boo {{count}}" )
+ Topic.validates_length_of( :title, :minimum=>5, :message=>"boo %{count}" )
t = Topic.create("title" => "uhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
assert_equal ["boo 5"], t.errors[:title]
end
def test_validates_length_of_custom_errors_for_minimum_with_too_short
- Topic.validates_length_of( :title, :minimum=>5, :too_short=>"hoo {{count}}" )
+ Topic.validates_length_of( :title, :minimum=>5, :too_short=>"hoo %{count}" )
t = Topic.create("title" => "uhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
assert_equal ["hoo 5"], t.errors[:title]
end
def test_validates_length_of_custom_errors_for_maximum_with_message
- Topic.validates_length_of( :title, :maximum=>5, :message=>"boo {{count}}" )
+ Topic.validates_length_of( :title, :maximum=>5, :message=>"boo %{count}" )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
assert_equal ["boo 5"], t.errors[:title]
end
def test_validates_length_of_custom_errors_for_in
- Topic.validates_length_of(:title, :in => 10..20, :message => "hoo {{count}}")
+ Topic.validates_length_of(:title, :in => 10..20, :message => "hoo %{count}")
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
@@ -267,23 +267,23 @@ def test_validates_length_of_custom_errors_for_in
end
def test_validates_length_of_custom_errors_for_maximum_with_too_long
- Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}" )
+ Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo %{count}" )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
assert_equal ["hoo 5"], t.errors["title"]
end
def test_validates_length_of_custom_errors_for_is_with_message
- Topic.validates_length_of( :title, :is=>5, :message=>"boo {{count}}" )
+ Topic.validates_length_of( :title, :is=>5, :message=>"boo %{count}" )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
assert_equal ["boo 5"], t.errors["title"]
end
def test_validates_length_of_custom_errors_for_is_with_wrong_length
- Topic.validates_length_of( :title, :is=>5, :wrong_length=>"hoo {{count}}" )
+ Topic.validates_length_of( :title, :is=>5, :wrong_length=>"hoo %{count}" )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
assert !t.valid?
assert t.errors[:title].any?
@@ -349,7 +349,7 @@ def test_optionally_validates_length_of_using_within_utf8
def test_optionally_validates_length_of_using_within_on_create_utf8
with_kcode('UTF8') do
- Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎます: {{count}}"
+ Topic.validates_length_of :title, :within => 5..10, :on => :create, :too_long => "長すぎます: %{count}"
t = Topic.create("title" => "一二三四五六七八九十A", "content" => "whatever")
assert !t.save
@@ -372,7 +372,7 @@ def test_optionally_validates_length_of_using_within_on_create_utf8
def test_optionally_validates_length_of_using_within_on_update_utf8
with_kcode('UTF8') do
- Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎます: {{count}}"
+ Topic.validates_length_of :title, :within => 5..10, :on => :update, :too_short => "短すぎます: %{count}"
t = Topic.create("title" => "一二三4", "content" => "whatever")
assert !t.save
@@ -407,7 +407,7 @@ def test_validates_length_of_using_is_utf8
end
def test_validates_length_of_with_block
- Topic.validates_length_of :content, :minimum => 5, :too_short=>"Your essay must be at least {{count}} words.",
+ Topic.validates_length_of :content, :minimum => 5, :too_short=>"Your essay must be at least %{count} words.",
:tokenizer => lambda {|str| str.scan(/\w+/) }
t = Topic.create!(:content => "this content should be long enough")
assert t.valid?
View
4 activemodel/test/cases/validations/numericality_validation_test.rb
@@ -126,13 +126,13 @@ def test_validates_numericality_with_symbol
end
def test_validates_numericality_with_numeric_message
- Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than {{count}}"
+ Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than %{count}"
topic = Topic.new("title" => "numeric test", "approved" => 10)
assert !topic.valid?
assert_equal ["smaller than 4"], topic.errors[:approved]
- Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than {{count}}"
+ Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than %{count}"
topic = Topic.new("title" => "numeric test", "approved" => 1)
assert !topic.valid?
View
4 activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
@@ -15,7 +15,7 @@ def test_generate_message_invalid_with_default_message
end
def test_generate_message_invalid_with_custom_message
- assert_equal 'custom message title', @topic.errors.generate_message(:title, :invalid, :default => 'custom message {{value}}', :value => 'title')
+ assert_equal 'custom message title', @topic.errors.generate_message(:title, :invalid, :default => 'custom message %{value}', :value => 'title')
end
# validates_uniqueness_of: generate_message(attr_name, :taken, :default => configuration[:message])
@@ -24,7 +24,7 @@ def test_generate_message_taken_with_default_message
end
def test_generate_message_taken_with_custom_message
- assert_equal 'custom message title', @topic.errors.generate_message(:title, :taken, :default => 'custom message {{value}}', :value => 'title')
+ assert_equal 'custom message title', @topic.errors.generate_message(:title, :taken, :default => 'custom message %{value}', :value => 'title')
end
# ActiveRecord#RecordInvalid exception
View
24 railties/guides/source/activerecord_validations_callbacks.textile
@@ -234,7 +234,7 @@ This helper validates that the attributes' values are not included in a given se
<ruby>
class Account < ActiveRecord::Base
validates_exclusion_of :subdomain, :in => %w(www),
- :message => "Subdomain {{value}} is reserved."
+ :message => "Subdomain %{value} is reserved."
end
</ruby>
@@ -262,7 +262,7 @@ This helper validates that the attributes' values are included in a given set. I
<ruby>
class Coffee < ActiveRecord::Base
validates_inclusion_of :size, :in => %w(small medium large),
- :message => "{{value}} is not a valid size"
+ :message => "%{value} is not a valid size"
end
</ruby>
@@ -290,12 +290,12 @@ The possible length constraint options are:
* +:in+ (or +:within+) - The attribute length must be included in a given interval. The value for this option must be a range.
* +:is+ - The attribute length must be equal to the given value.
-The default error messages depend on the type of length validation being performed. You can personalize these messages using the +:wrong_length+, +:too_long+, and +:too_short+ options and <tt>{{count}}</tt> as a placeholder for the number corresponding to the length constraint being used. You can still use the +:message+ option to specify an error message.
+The default error messages depend on the type of length validation being performed. You can personalize these messages using the +:wrong_length+, +:too_long+, and +:too_short+ options and <tt>%{count}</tt> as a placeholder for the number corresponding to the length constraint being used. You can still use the +:message+ option to specify an error message.
<ruby>
class Person < ActiveRecord::Base
validates_length_of :bio, :maximum => 1000,
- :too_long => "{{count}} characters is the maximum allowed"
+ :too_long => "%{count} characters is the maximum allowed"
end
</ruby>
@@ -307,8 +307,8 @@ class Essay < ActiveRecord::Base
:minimum => 300,
:maximum => 400,
:tokenizer => lambda { |str| str.scan(/\w+/) },
- :too_short => "must have at least {{count}} words",
- :too_long => "must have at most {{count}} words"
+ :too_short => "must have at least %{count} words",
+ :too_long => "must have at most %{count} words"
end
</ruby>
@@ -337,11 +337,11 @@ end
Besides +:only_integer+, the +validates_numericality_of+ helper also accepts the following options to add constraints to acceptable values:
-* +:greater_than+ - Specifies the value must be greater than the supplied value. The default error message for this option is "_must be greater than {{count}}_".
-* +:greater_than_or_equal_to+ - Specifies the value must be greater than or equal to the supplied value. The default error message for this option is "_must be greater than or equal to {{count}}_".
-* +:equal_to+ - Specifies the value must be equal to the supplied value. The default error message for this option is "_must be equal to {{count}}_".
-* +:less_than+ - Specifies the value must be less than the supplied value. The default error message for this option is "_must be less than {{count}}_".
-* +:less_than_or_equal_to+ - Specifies the value must be less than or equal the supplied value. The default error message for this option is "_must be less or equal to {{count}}_".
+* +:greater_than+ - Specifies the value must be greater than the supplied value. The default error message for this option is "_must be greater than %{count}_".
+* +:greater_than_or_equal_to+ - Specifies the value must be greater than or equal to the supplied value. The default error message for this option is "_must be greater than or equal to %{count}_".
+* +:equal_to+ - Specifies the value must be equal to the supplied value. The default error message for this option is "_must be equal to %{count}_".
+* +:less_than+ - Specifies the value must be less than the supplied value. The default error message for this option is "_must be less than %{count}_".
+* +:less_than_or_equal_to+ - Specifies the value must be less than or equal the supplied value. The default error message for this option is "_must be less or equal to %{count}_".
* +:odd+ - Specifies the value must be an odd number if set to true. The default error message for this option is "_must be odd_".
* +:even+ - Specifies the value must be an even number if set to true. The default error message for this option is "_must be even_".
@@ -469,7 +469,7 @@ The +:allow_nil+ option skips the validation when the value being validated is +
<ruby>
class Coffee < ActiveRecord::Base
validates_inclusion_of :size, :in => %w(small medium large),
- :message => "{{value}} is not a valid size", :allow_nil => true
+ :message => "%{value} is not a valid size", :allow_nil => true
end
</ruby>
View
10 railties/guides/source/i18n.textile
@@ -531,7 +531,7 @@ In many cases you want to abstract your translations so that *variables can be i
All options besides +:default+ and +:scope+ that are passed to +#translate+ will be interpolated to the translation:
<ruby>
-I18n.backend.store_translations :en, :thanks => 'Thanks {{name}}!'
+I18n.backend.store_translations :en, :thanks => 'Thanks %{name}!'
I18n.translate :thanks, :name => 'Jeremy'
# => 'Thanks Jeremy!'
</ruby>
@@ -547,7 +547,7 @@ The +:count+ interpolation variable has a special role in that it both is interp
<ruby>
I18n.backend.store_translations :en, :inbox => {
:one => '1 message',
- :other => '{{count}} messages'
+ :other => '%{count} messages'
}
I18n.translate :inbox, :count => 2
# => '2 messages'
@@ -711,7 +711,7 @@ h5. Error Message Interpolation
The translated model name, translated attribute name, and value are always available for interpolation.
-So, for example, instead of the default error message +"can not be blank"+ you could use the attribute name like this : +"Please fill in your {{attribute}}"+.
+So, for example, instead of the default error message +"can not be blank"+ you could use the attribute name like this : +"Please fill in your %{attribute}"+.
* +count+, where available, can be used for pluralization if present:
@@ -750,8 +750,8 @@ en:
errors:
template:
header:
- one: "1 error prohibited this {{model}} from being saved"
- other: "{{count}} errors prohibited this {{model}} from being saved"
+ one: "1 error prohibited this %{model} from being saved"
+ other: "%{count} errors prohibited this %{model} from being saved"
body: "There were problems with the following fields:"
</yaml>

0 comments on commit 9bd91b0

Please sign in to comment.
Something went wrong with that request. Please try again.