Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use %{} syntax in I18n (faster) instead of {{}}.

  • Loading branch information...
commit 13867a3f5f3e2248660a942956985a4eacacb283 1 parent efba1d4
@josevalim josevalim authored
View
6 actionpack/lib/action_view/helpers/form_helper.rb
@@ -1165,13 +1165,13 @@ def hidden_field(method, options = {})
# submit button label, otherwise, it uses "Update Post".
#
# Those labels can be customized using I18n, under the helpers.submit key and accept
- # the {{model}} as translation interpolation:
+ # the %{model} as translation interpolation:
#
# en:
# helpers:
# submit:
- # create: "Create a {{model}}"
- # update: "Confirm changes to {{model}}"
+ # create: "Create a %{model}"
+ # update: "Confirm changes to %{model}"
#
# It also searches for a key specific for the given object:
#
View
28 actionpack/lib/action_view/locale/en.yml
@@ -102,37 +102,37 @@
half_a_minute: "half a minute"
less_than_x_seconds:
one: "less than 1 second"
- other: "less than {{count}} seconds"
+ other: "less than %{count} seconds"
x_seconds:
one: "1 second"
- other: "{{count}} seconds"
+ other: "%{count} seconds"
less_than_x_minutes:
one: "less than a minute"
- other: "less than {{count}} minutes"
+ other: "less than %{count} minutes"
x_minutes:
one: "1 minute"
- other: "{{count}} minutes"
+ other: "%{count} minutes"
about_x_hours:
one: "about 1 hour"
- other: "about {{count}} hours"
+ other: "about %{count} hours"
x_days:
one: "1 day"
- other: "{{count}} days"
+ other: "%{count} days"
about_x_months:
one: "about 1 month"
- other: "about {{count}} months"
+ other: "about %{count} months"
x_months:
one: "1 month"
- other: "{{count}} months"
+ other: "%{count} months"
about_x_years:
one: "about 1 year"
- other: "about {{count}} years"
+ other: "about %{count} years"
over_x_years:
one: "over 1 year"
- other: "over {{count}} years"
+ other: "over %{count} years"
almost_x_years:
one: "almost 1 year"
- other: "almost {{count}} years"
+ other: "almost %{count} years"
prompts:
year: "Year"
month: "Month"
@@ -148,7 +148,7 @@
# Default translation keys for submit FormHelper
submit:
- create: 'Create {{model}}'
- update: 'Update {{model}}'
- submit: 'Save {{model}}'
+ create: 'Create %{model}'
+ update: 'Update %{model}'
+ submit: 'Save %{model}'
View
2  activemodel/lib/active_model/errors.rb
@@ -223,7 +223,7 @@ def full_messages
else
attr_name = attribute.to_s.gsub('.', '_').humanize
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
- options = { :default => "{{attribute}} {{message}}", :attribute => attr_name }
+ options = { :default => "%{attribute} %{message}", :attribute => attr_name }
messages.each do |m|
full_messages << I18n.t(:"errors.format", options.merge(:message => m))
View
18 activemodel/lib/active_model/locale/en.yml
@@ -1,7 +1,7 @@
en:
errors:
# The default format use in full error messages.
- format: "{{attribute}} {{message}}"
+ format: "%{attribute} %{message}"
# The values :model, :attribute and :value are always available for interpolation
# The value :count is available when applicable. Can be used for pluralization.
@@ -13,15 +13,15 @@ en:
accepted: "must be accepted"
empty: "can't be empty"
blank: "can't be blank"
- too_long: "is too long (maximum is {{count}} characters)"
- too_short: "is too short (minimum is {{count}} characters)"
- wrong_length: "is the wrong length (should be {{count}} characters)"
+ too_long: "is too long (maximum is %{count} characters)"
+ too_short: "is too short (minimum is %{count} characters)"
+ wrong_length: "is the wrong length (should be %{count} characters)"
not_a_number: "is not a number"
not_an_integer: "must be an integer"
- greater_than: "must be greater than {{count}}"
- greater_than_or_equal_to: "must be greater than or equal to {{count}}"
- equal_to: "must be equal to {{count}}"
- less_than: "must be less than {{count}}"
- less_than_or_equal_to: "must be less than or equal to {{count}}"
+ greater_than: "must be greater than %{count}"
+ greater_than_or_equal_to: "must be greater than or equal to %{count}"
+ equal_to: "must be equal to %{count}"
+ less_than: "must be less than %{count}"
+ less_than_or_equal_to: "must be less than or equal to %{count}"
odd: "must be odd"
even: "must be even"
View
4 activerecord/lib/active_record/locale/en.yml
@@ -9,7 +9,7 @@ en:
errors:
messages:
taken: "has already been taken"
- record_invalid: "Validation failed: {{errors}}"
+ record_invalid: "Validation failed: %{errors}"
# Append your own errors here or at the model/attributes scope.
# You can define own errors for models or model attributes.
@@ -18,7 +18,7 @@ en:
# For example,
# models:
# user:
- # blank: "This is a custom blank message for {{model}}: {{attribute}}"
+ # blank: "This is a custom blank message for %{model}: %{attribute}"
# attributes:
# login:
# blank: "This is a custom blank message for User login"
Please sign in to comment.
Something went wrong with that request. Please try again.