aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorSven Fuchs <svenfuchs@artweb-design.de>2008-08-10 21:25:24 +0200
committerSven Fuchs <svenfuchs@artweb-design.de>2008-08-10 21:29:02 +0200
commitbdf783b5a8b83b1d565027130de4743fda336523 (patch)
tree8afa45d32b259962ed66b35aa255c604472a1887 /actionpack
parenteb4668b26ad4aacf79488d2bee553e9452971c35 (diff)
downloadrails-bdf783b5a8b83b1d565027130de4743fda336523.tar.gz
rails-bdf783b5a8b83b1d565027130de4743fda336523.tar.bz2
rails-bdf783b5a8b83b1d565027130de4743fda336523.zip
update i18n usage for pluralization hashes (api change)
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/locale/en-US.rb57
-rw-r--r--actionpack/test/template/date_helper_i18n_test.rb22
2 files changed, 67 insertions, 12 deletions
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:"
}
}
diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionpack/test/template/date_helper_i18n_test.rb
index 2b40074498..bf3b2588c8 100644
--- a/actionpack/test/template/date_helper_i18n_test.rb
+++ b/actionpack/test/template/date_helper_i18n_test.rb
@@ -47,6 +47,28 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase
I18n.expects(:t).with(key, options)
distance_of_time_in_words(@from, to, include_seconds, :locale => 'en-US')
end
+
+ def test_distance_of_time_pluralizations
+ { [:'less_than_x_seconds', 1] => 'less than 1 second',
+ [:'less_than_x_seconds', 2] => 'less than 2 seconds',
+ [:'less_than_x_minutes', 1] => 'less than a minute',
+ [:'less_than_x_minutes', 2] => 'less than 2 minutes',
+ [:'x_minutes', 1] => '1 minute',
+ [:'x_minutes', 2] => '2 minutes',
+ [:'about_x_hours', 1] => 'about 1 hour',
+ [:'about_x_hours', 2] => 'about 2 hours',
+ [:'x_days', 1] => '1 day',
+ [:'x_days', 2] => '2 days',
+ [:'about_x_years', 1] => 'about 1 year',
+ [:'about_x_years', 2] => 'about 2 years',
+ [:'over_x_years', 1] => 'over 1 year',
+ [:'over_x_years', 2] => 'over 2 years'
+
+ }.each do |args, expected|
+ key, count = *args
+ assert_equal expected, I18n.t(key, :count => count, :scope => 'datetime.distance_in_words')
+ end
+ end
end
end