Skip to content

Commit

Permalink
switch to using I18n.load_translations instead of requiring plain rub…
Browse files Browse the repository at this point in the history
…y files
  • Loading branch information
Sven Fuchs committed Aug 13, 2008
1 parent bfa143f commit f26380b
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 128 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
require 'action_view/template_error'

I18n.backend.populate do
require 'action_view/locale/en-US.rb'
I18n.load_translations File.dirname(__FILE__) + '/action_view/locale/en-US.rb'
end

ActionView::Base.class_eval do
Expand Down
155 changes: 78 additions & 77 deletions actionpack/lib/action_view/locale/en-US.rb
Original file line number Diff line number Diff line change
@@ -1,86 +1,87 @@
I18n.backend.store_translations :'en-US', {
:datetime => {
:distance_in_words => {
:half_a_minute => 'half a minute',
:less_than_x_seconds => {
:one => 'less than 1 second',
:many => 'less than {{count}} seconds'
},
:x_seconds => {
:one => '1 second',
:many => '{{count}} seconds'
},
:less_than_x_minutes => {
:one => 'less than a minute',
:many => 'less than {{count}} minutes'
},
:x_minutes => {
:one => '1 minute',
:many => '{{count}} minutes'
},
:about_x_hours => {
:one => 'about 1 hour',
:many => 'about {{count}} hours'
},
:x_days => {
:one => '1 day',
:many => '{{count}} days'
{ :'en-US' => {
:datetime => {
:distance_in_words => {
:half_a_minute => 'half a minute',
:less_than_x_seconds => {
:one => 'less than 1 second',
:many => 'less than {{count}} seconds'
},
:x_seconds => {
:one => '1 second',
:many => '{{count}} seconds'
},
:less_than_x_minutes => {
:one => 'less than a minute',
:many => 'less than {{count}} minutes'
},
:x_minutes => {
:one => '1 minute',
:many => '{{count}} minutes'
},
:about_x_hours => {
:one => 'about 1 hour',
:many => 'about {{count}} hours'
},
:x_days => {
:one => '1 day',
:many => '{{count}} days'
},
:about_x_months => {
:one => 'about 1 month',
:many => 'about {{count}} months'
},
:x_months => {
:one => '1 month',
:many => '{{count}} months'
},
:about_x_years => {
:one => 'about 1 year',
:many => 'about {{count}} years'
},
:over_x_years => {
:one => 'over 1 year',
:many => 'over {{count}} years'
}
}
},
:number => {
:format => {
:precision => 3,
:separator => '.',
:delimiter => ','
},
:about_x_months => {
:one => 'about 1 month',
:many => 'about {{count}} months'
:currency => {
:format => {
:unit => '$',
:precision => 2,
:format => '%u%n'
}
},
:x_months => {
:one => '1 month',
:many => '{{count}} months'
:human => {
:format => {
:precision => 1,
:delimiter => ''
}
},
:about_x_years => {
:one => 'about 1 year',
:many => 'about {{count}} years'
:percentage => {
:format => {
:delimiter => ''
}
},
:over_x_years => {
:one => 'over 1 year',
:many => 'over {{count}} years'
:precision => {
:format => {
:delimiter => ''
}
}
}
},
:number => {
:format => {
:precision => 3,
:separator => '.',
:delimiter => ','
},
:currency => {
:format => {
:unit => '$',
:precision => 2,
:format => '%u%n'
:active_record => {
:error => {
:header_message => {
:one => "1 error prohibited this {{object_name}} from being saved",
:many => "{{count}} errors prohibited this {{object_name}} from being saved"
},
:message => "There were problems with the following fields:"
}
},
:human => {
:format => {
:precision => 1,
:delimiter => ''
}
},
:percentage => {
:format => {
:delimiter => ''
}
},
:precision => {
:format => {
:delimiter => ''
}
}
},
:active_record => {
:error => {
:header_message => {
:one => "1 error prohibited this {{object_name}} from being saved",
:many => "{{count}} errors prohibited this {{object_name}} from being saved"
},
:message => "There were problems with the following fields:"
}
}
}
}
2 changes: 1 addition & 1 deletion activerecord/lib/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@
require 'active_record/schema_dumper'

I18n.backend.populate do
require 'active_record/locale/en-US.rb'
I18n.load_translations File.dirname(__FILE__) + '/active_record/locale/en-US.rb'
end

47 changes: 24 additions & 23 deletions activerecord/lib/active_record/locale/en-US.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
I18n.backend.store_translations :'en-US', {
:active_record => {
:error_messages => {
:inclusion => "is not included in the list",
:exclusion => "is reserved",
:invalid => "is invalid",
:confirmation => "doesn't match confirmation",
: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)",
:taken => "has already been taken",
:not_a_number => "is not a number",
: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"
}
{ :'en-US' => {
:active_record => {
:error_messages => {
:inclusion => "is not included in the list",
:exclusion => "is reserved",
:invalid => "is invalid",
:confirmation => "doesn't match confirmation",
: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)",
:taken => "has already been taken",
:not_a_number => "is not a number",
: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"
}
}
}
}
4 changes: 2 additions & 2 deletions activesupport/lib/active_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@

require 'active_support/time_with_zone'

I18n.backend.populate do
require 'active_support/locale/en-US.rb'
I18n.populate do
I18n.load_translations File.dirname(__FILE__) + '/active_support/locale/en-US.rb'
end

Inflector = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Inflector', 'ActiveSupport::Inflector')
Expand Down
49 changes: 25 additions & 24 deletions activesupport/lib/active_support/locale/en-US.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
I18n.backend.store_translations :'en-US', {
:support => {
:array => {
:sentence_connector => 'and'
}
},
:date => {
:formats => {
:default => "%Y-%m-%d",
:short => "%b %d",
:long => "%B %d, %Y",
{ :'en-US' => {
:support => {
:array => {
:sentence_connector => 'and'
}
},
:day_names => Date::DAYNAMES,
:abbr_day_names => Date::ABBR_DAYNAMES,
:month_names => Date::MONTHNAMES,
:abbr_month_names => Date::ABBR_MONTHNAMES,
:order => [:year, :month, :day]
},
:time => {
:formats => {
:default => "%a, %d %b %Y %H:%M:%S %z",
:short => "%d %b %H:%M",
:long => "%B %d, %Y %H:%M",
:date => {
:formats => {
:default => "%Y-%m-%d",
:short => "%b %d",
:long => "%B %d, %Y",
},
:day_names => Date::DAYNAMES,
:abbr_day_names => Date::ABBR_DAYNAMES,
:month_names => Date::MONTHNAMES,
:abbr_month_names => Date::ABBR_MONTHNAMES,
:order => [:year, :month, :day]
},
:am => 'am',
:pm => 'pm'
:time => {
:formats => {
:default => "%a, %d %b %Y %H:%M:%S %z",
:short => "%d %b %H:%M",
:long => "%B %d, %Y %H:%M",
},
:am => 'am',
:pm => 'pm'
}
}
}

0 comments on commit f26380b

Please sign in to comment.