From bdf783b5a8b83b1d565027130de4743fda336523 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 10 Aug 2008 21:25:24 +0200 Subject: update i18n usage for pluralization hashes (api change) --- actionpack/lib/action_view/locale/en-US.rb | 57 +++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 12 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/locale/en-US.rb b/actionpack/lib/action_view/locale/en-US.rb index 2c3676dca8..0119b3d9c1 100644 --- a/actionpack/lib/action_view/locale/en-US.rb +++ b/actionpack/lib/action_view/locale/en-US.rb @@ -1,17 +1,47 @@ 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'] + :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 => { @@ -46,7 +76,10 @@ I18n.backend.store_translations :'en-US', { }, :active_record => { :error => { - :header_message => ["1 error prohibited this {{object_name}} from being saved", "{{count}} errors prohibited this {{object_name}} from being saved"], + :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:" } } -- cgit v1.2.3 From f26380b7757666fa793c150538e8444a640d29aa Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 13 Aug 2008 09:53:25 +0200 Subject: switch to using I18n.load_translations instead of requiring plain ruby files --- actionpack/lib/action_view/locale/en-US.rb | 155 +++++++++++++++-------------- 1 file changed, 78 insertions(+), 77 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/locale/en-US.rb b/actionpack/lib/action_view/locale/en-US.rb index 0119b3d9c1..8cce874700 100644 --- a/actionpack/lib/action_view/locale/en-US.rb +++ b/actionpack/lib/action_view/locale/en-US.rb @@ -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:" } } -} +} \ No newline at end of file -- cgit v1.2.3 From ffeab4e0c171aecced4ddbe29b82aed064be9bdb Mon Sep 17 00:00:00 2001 From: Iain Hecker Date: Thu, 14 Aug 2008 01:28:31 +0200 Subject: Cleaned up ActiveRecord i18n scoping --- .../lib/action_view/helpers/active_record_helper.rb | 8 ++++---- actionpack/lib/action_view/locale/en-US.rb | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'actionpack/lib/action_view') 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 index 8cce874700..d4647b5a48 100644 --- a/actionpack/lib/action_view/locale/en-US.rb +++ b/actionpack/lib/action_view/locale/en-US.rb @@ -74,14 +74,16 @@ } } }, - :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:" + :activerecord => { + :errors => { + :template => { + :header => { + :one => "1 error prohibited this {{model}} from being saved", + :many => "{{count}} errors prohibited this {{model}} from being saved" + }, + :body => "There were problems with the following fields:" + } } } } -} \ No newline at end of file +} -- cgit v1.2.3 From 7ee01c8c5415579a68fe4bf073f69cf5796bf7c9 Mon Sep 17 00:00:00 2001 From: Iain Hecker Date: Tue, 19 Aug 2008 23:33:39 +0200 Subject: Changed locale file to yml for actionpack, but still broken --- actionpack/lib/action_view/locale/en-US.rb | 89 ----------------------------- actionpack/lib/action_view/locale/en-US.yml | 89 +++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 89 deletions(-) delete mode 100644 actionpack/lib/action_view/locale/en-US.rb create mode 100644 actionpack/lib/action_view/locale/en-US.yml (limited to 'actionpack/lib/action_view') 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 d4647b5a48..0000000000 --- a/actionpack/lib/action_view/locale/en-US.rb +++ /dev/null @@ -1,89 +0,0 @@ -{ :'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 => ',' - }, - :currency => { - :format => { - :unit => '$', - :precision => 2, - :format => '%u%n' - } - }, - :human => { - :format => { - :precision => 1, - :delimiter => '' - } - }, - :percentage => { - :format => { - :delimiter => '' - } - }, - :precision => { - :format => { - :delimiter => '' - } - } - }, - :activerecord => { - :errors => { - :template => { - :header => { - :one => "1 error prohibited this {{model}} from being saved", - :many => "{{count}} errors prohibited this {{model}} from being saved" - }, - :body => "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..d4039e9b12 --- /dev/null +++ b/actionpack/lib/action_view/locale/en-US.yml @@ -0,0 +1,89 @@ +"en-US": + number: + # Used in number_with_delimiter() + # These are also the defaults for 'currency', 'percentage', 'precision', and 'human' + format: + # Sets the seperator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5) + seperator: "." + # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three) + delimeter: "," + # Number of decimals, behind the seperator (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 + seperator: "." + delimiter: "," + precision: 2 + + # Used in number_to_percentage() + percentage: + format: + # These three are to override number.format and are optional + seperator: "." + delimiter: "," + precision: 3 + + # Used in number_to_precision() + precision: + format: + # These three are to override number.format and are optional + seperator: "." + delimiter: "," + precision: 3 + + # Used in number_to_human_size() + human: + format: + # These three are to override number.format and are optional + seperator: "." + delimiter: "," + + # 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 a second" + many: "less than {{count}} seconds" + x_seconds: + one: "1 second" + many: "{{count}} seconds" + less_than_x_minutes: + one: "less than 1 minutes" + 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 a 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: + 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 + message: "There were problems with the following fields:" + -- cgit v1.2.3 From 950b9792baae14e42b894f113ae8dfc95df34da9 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 20 Aug 2008 18:44:18 +0200 Subject: fixing actionpack yml translations --- actionpack/lib/action_view/locale/en-US.yml | 44 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/locale/en-US.yml b/actionpack/lib/action_view/locale/en-US.yml index d4039e9b12..57987f4e02 100644 --- a/actionpack/lib/action_view/locale/en-US.yml +++ b/actionpack/lib/action_view/locale/en-US.yml @@ -3,11 +3,11 @@ # Used in number_with_delimiter() # These are also the defaults for 'currency', 'percentage', 'precision', and 'human' format: - # Sets the seperator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5) - seperator: "." + # 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) - delimeter: "," - # Number of decimals, behind the seperator (the number 1 with a precision of 2 gives: 1.00) + 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() @@ -17,7 +17,7 @@ format: "%u%n" unit: "$" # These three are to override number.format and are optional - seperator: "." + separator: "." delimiter: "," precision: 2 @@ -25,37 +25,38 @@ percentage: format: # These three are to override number.format and are optional - seperator: "." - delimiter: "," - precision: 3 + # separator: + delimiter: "" + # precision: # Used in number_to_precision() precision: format: # These three are to override number.format and are optional - seperator: "." - delimiter: "," - precision: 3 + # separator: + delimiter: "" + # precision: # Used in number_to_human_size() human: format: # These three are to override number.format and are optional - seperator: "." - delimiter: "," + # 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 a second" + 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 1 minutes" + one: "less than a minute" many: "less than {{count}} minutes" x_minutes: one: "1 minute" @@ -67,7 +68,7 @@ one: "1 day" many: "{{count}} days" about_x_months: - one: "about a month" + one: "about 1 month" many: "about {{count}} months" x_months: one: "1 month" @@ -81,9 +82,10 @@ activerecord: errors: - 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 - message: "There were problems with the following fields:" + 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:" -- cgit v1.2.3