aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorLawrence Pit <lawrence.pit@gmail.com>2010-05-03 16:44:32 +1000
committerJosé Valim <jose.valim@gmail.com>2010-05-03 13:37:32 +0200
commit9bd91b00b85c77bc294ae2a99beae203cc163227 (patch)
treeec5b8bc9d4d2053ebddfec174b9afa4e9c00239b /railties
parent8ae9b05fa0ca579ecabcd563e6ba75ea0f44f074 (diff)
downloadrails-9bd91b00b85c77bc294ae2a99beae203cc163227.tar.gz
rails-9bd91b00b85c77bc294ae2a99beae203cc163227.tar.bz2
rails-9bd91b00b85c77bc294ae2a99beae203cc163227.zip
Favor %{} in all code instead of (deprecated) {{}} as interpolation syntax for I18n
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/activerecord_validations_callbacks.textile24
-rw-r--r--railties/guides/source/i18n.textile10
2 files changed, 17 insertions, 17 deletions
diff --git a/railties/guides/source/activerecord_validations_callbacks.textile b/railties/guides/source/activerecord_validations_callbacks.textile
index 126a6efff5..97915d5d55 100644
--- a/railties/guides/source/activerecord_validations_callbacks.textile
+++ b/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>
diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile
index dcad451e23..bb383d3cf9 100644
--- a/railties/guides/source/i18n.textile
+++ b/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>