aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-08-22 12:44:14 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-08-22 12:44:14 -0700
commita6e05b18d65d07a157ee09d54167c81f3d1440f8 (patch)
treeb19158cbc1ede41fc5db61bb3877e0407457e22b /actionpack/lib/action_view
parentab33b27947864d94be667db836e0ad7497575d13 (diff)
parentaad429a46e3017fa7ca73f58428693e821be42b6 (diff)
downloadrails-a6e05b18d65d07a157ee09d54167c81f3d1440f8.tar.gz
rails-a6e05b18d65d07a157ee09d54167c81f3d1440f8.tar.bz2
rails-a6e05b18d65d07a157ee09d54167c81f3d1440f8.zip
Merge commit 'sven/i18n' into i18n
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb8
-rw-r--r--actionpack/lib/action_view/locale/en-US.rb53
-rw-r--r--actionpack/lib/action_view/locale/en-US.yml91
3 files changed, 95 insertions, 57 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index fce03ff605..c339e10701 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -189,15 +189,15 @@ module ActionView
end
options[:object_name] ||= params.first
- I18n.with_options :locale => options[:locale], :scope => [:active_record, :error] do |locale|
+ I18n.with_options :locale => options[:locale], :scope => [:activerecord, :errors, :template] do |locale|
header_message = if options.include?(:header_message)
options[:header_message]
else
object_name = options[:object_name].to_s.gsub('_', ' ')
- object_name = I18n.t(object_name, :default => object_name)
- locale.t :header_message, :count => count, :object_name => object_name
+ object_name = I18n.t(object_name, :default => object_name, :scope => [:activerecord, :models], :count => 1)
+ locale.t :header, :count => count, :model => object_name
end
- message = options.include?(:message) ? options[:message] : locale.t(:message)
+ message = options.include?(:message) ? options[:message] : locale.t(:body)
error_messages = objects.sum {|object| object.errors.full_messages.map {|msg| content_tag(:li, msg) } }.join
contents = ''
diff --git a/actionpack/lib/action_view/locale/en-US.rb b/actionpack/lib/action_view/locale/en-US.rb
deleted file mode 100644
index 2c3676dca8..0000000000
--- a/actionpack/lib/action_view/locale/en-US.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-I18n.backend.store_translations :'en-US', {
- :datetime => {
- :distance_in_words => {
- :half_a_minute => 'half a minute',
- :less_than_x_seconds => ['less than 1 second', 'less than {{count}} seconds'],
- :x_seconds => ['1 second', '{{count}} seconds'],
- :less_than_x_minutes => ['less than a minute', 'less than {{count}} minutes'],
- :x_minutes => ['1 minute', '{{count}} minutes'],
- :about_x_hours => ['about 1 hour', 'about {{count}} hours'],
- :x_days => ['1 day', '{{count}} days'],
- :about_x_months => ['about 1 month', 'about {{count}} months'],
- :x_months => ['1 month', '{{count}} months'],
- :about_x_years => ['about 1 year', 'about {{count}} year'],
- :over_x_years => ['over 1 year', 'over {{count}} years']
- }
- },
- :number => {
- :format => {
- :precision => 3,
- :separator => '.',
- :delimiter => ','
- },
- :currency => {
- :format => {
- :unit => '$',
- :precision => 2,
- :format => '%u%n'
- }
- },
- :human => {
- :format => {
- :precision => 1,
- :delimiter => ''
- }
- },
- :percentage => {
- :format => {
- :delimiter => ''
- }
- },
- :precision => {
- :format => {
- :delimiter => ''
- }
- }
- },
- :active_record => {
- :error => {
- :header_message => ["1 error prohibited this {{object_name}} from being saved", "{{count}} errors prohibited this {{object_name}} from being saved"],
- :message => "There were problems with the following fields:"
- }
- }
-}
diff --git a/actionpack/lib/action_view/locale/en-US.yml b/actionpack/lib/action_view/locale/en-US.yml
new file mode 100644
index 0000000000..57987f4e02
--- /dev/null
+++ b/actionpack/lib/action_view/locale/en-US.yml
@@ -0,0 +1,91 @@
+"en-US":
+ number:
+ # Used in number_with_delimiter()
+ # These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
+ format:
+ # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
+ separator: "."
+ # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
+ delimiter: ","
+ # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
+ precision: 3
+
+ # Used in number_to_currency()
+ currency:
+ format:
+ # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
+ format: "%u%n"
+ unit: "$"
+ # These three are to override number.format and are optional
+ separator: "."
+ delimiter: ","
+ precision: 2
+
+ # Used in number_to_percentage()
+ percentage:
+ format:
+ # These three are to override number.format and are optional
+ # separator:
+ delimiter: ""
+ # precision:
+
+ # Used in number_to_precision()
+ precision:
+ format:
+ # These three are to override number.format and are optional
+ # separator:
+ delimiter: ""
+ # precision:
+
+ # Used in number_to_human_size()
+ human:
+ format:
+ # These three are to override number.format and are optional
+ # separator:
+ delimiter: ""
+ precision: 1
+
+ # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
+ 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"
+
+ activerecord:
+ errors:
+ template:
+ header:
+ one: "1 error prohibited this {{model}} from being saved"
+ many: "{{count}} errors prohibited this {{model}} from being saved"
+ # The variable :count is also available
+ body: "There were problems with the following fields:"
+