diff options
author | Yaroslav Markin <yaroslav@markin.net> | 2009-01-01 21:29:11 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-01-27 09:22:00 -0800 |
commit | 17db28f1ca0597fa1e9abdcacd934ca27d589fb9 (patch) | |
tree | 6c0ff06c86450d4f9cb0224a7786dc80c60b6a50 /actionpack/test | |
parent | a1ac635d9655cd26f86593263c3e9b956d330141 (diff) | |
download | rails-17db28f1ca0597fa1e9abdcacd934ca27d589fb9.tar.gz rails-17db28f1ca0597fa1e9abdcacd934ca27d589fb9.tar.bz2 rails-17db28f1ca0597fa1e9abdcacd934ca27d589fb9.zip |
Improve i18n support for number_to_human_size helper:
* now using pluralization properly
* storage unit translations moved to number.human.storage_units.units
* introduced number.human.storage_units.format for languages that do not follow "{{number}} {{unit}}" format (Japanese)
NOTE: I18n table changed, you will need to update your translations.
[#1634 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/number_helper_i18n_test.rb | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/actionpack/test/template/number_helper_i18n_test.rb b/actionpack/test/template/number_helper_i18n_test.rb index 2528bead36..3fdf991a44 100644 --- a/actionpack/test/template/number_helper_i18n_test.rb +++ b/actionpack/test/template/number_helper_i18n_test.rb @@ -10,7 +10,9 @@ class NumberHelperI18nTests < Test::Unit::TestCase @number_defaults = { :precision => 3, :delimiter => ',', :separator => '.' } @currency_defaults = { :unit => '$', :format => '%u%n', :precision => 2 } @human_defaults = { :precision => 1 } - @human_storage_units_defaults = %w(Bytes KB MB GB TB) + @human_storage_units_format_default = "%n %u" + @human_storage_units_units_byte_other = "Bytes" + @human_storage_units_units_kb_other = "KB" @percentage_defaults = { :delimiter => '' } @precision_defaults = { :delimiter => '' } @@ -48,10 +50,22 @@ class NumberHelperI18nTests < Test::Unit::TestCase I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) I18n.expects(:translate).with(:'number.human.format', :locale => 'en', :raise => true).returns(@human_defaults) - I18n.expects(:translate).with(:'number.human.storage_units', :locale => 'en', - :raise => true).returns(@human_storage_units_defaults) - # can't be called with 1 because this directly returns without calling I18n.translate - number_to_human_size(1025, :locale => 'en') + I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en', + :raise => true).returns(@human_storage_units_format_default) + I18n.expects(:translate).with(:'number.human.storage_units.units.kb', :locale => 'en', :count => 2, + :raise => true).returns(@human_storage_units_units_kb_other) + # 2KB + number_to_human_size(2048, :locale => 'en') + + I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults) + I18n.expects(:translate).with(:'number.human.format', :locale => 'en', + :raise => true).returns(@human_defaults) + I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en', + :raise => true).returns(@human_storage_units_format_default) + I18n.expects(:translate).with(:'number.human.storage_units.units.byte', :locale => 'en', :count => 42, + :raise => true).returns(@human_storage_units_units_byte_other) + # 42 Bytes + number_to_human_size(42, :locale => 'en') end end end |