This project is archived and is in readonly mode.
number_to_human_size only working properly when :precision and :separator given
Reported by Smeevil | September 14th, 2009 @ 09:27 PM | in 2.3.6
number_to_human_size(10000000000)
returns : 9.31322574615479
whereas number_to_human_size(10000000000,:precision => 2,
:separator => '.')
returns : 9.31 GB
leaving out either precision or seperator returns the first result again.
using in the yml :
nl:
number:
human:
storage_units:
format: "%n %u"
units:
byte:
one: "byte"
other: "bytes"
kb: "KB"
mb: "MB"
gb: "GB"
Comments and changes to this ticket
-
CancelProfileIsBroken September 25th, 2009 @ 12:12 PM
- Tag set to bugmash
-
Dmitry Maksimov September 26th, 2009 @ 05:57 PM
+1 verified
The issue reproduce if user set his own locale and not define number[:human][:format] or number[:format] details.
Not sure that this is a bug... -
Blue Box Chris September 26th, 2009 @ 10:09 PM
-1 for Ruby 1.8.6 with Rails 2.0.5
number_to_human_size(10000000000)
NoMethodError: undefined methodnumber_to_human_size' for #<Object:0x2af485abb338><br/>
from (irb):1
include ActionView::Helpers::NumberHelper => Object number_to_human_size(10000000000) => "9.3 GB"
-
Matías Flores September 27th, 2009 @ 03:39 AM
verified in 2-3-stable
steps to reproduce:
- create a custom locale file (e.g. es.yml) on
config/locales
- make sure you are not defining any number[:human][:format] nor
number[:format] settings as kolo mentioned
- call number_to_human_size specifying the locale you have just configured. E.g. helper.number_to_human_size(100000000, :locale => :es)
The wrong behavior gets fixed either by setting the number/human/format details in the locale file or by including :precision and :separator options in the call to number_to_human_size helper.
- create a custom locale file (e.g. es.yml) on
config/locales
-
Rizwan Reza January 21st, 2010 @ 07:31 AM
- State changed from new to open
- Tag changed from bugmash to actionview, i18n, locale
- Milestone set to 2.3.6
-
Prem Sichanugrist (sikachu) January 24th, 2010 @ 09:45 AM
- Assigned user set to Prem Sichanugrist (sikachu)
-
Sven Fuchs January 25th, 2010 @ 12:52 PM
TBH, i don't think this is a bug, so -1
It's an incomplete locale file. So far we don't do local fallbacks in Rails.
So, to fix this one could
- either complete the locale file
- or enable locale fallbacks in the I18n backend (e.g. include I18n::Backend::Fallbacks to I18n::Backend::Simple)
-
Prem Sichanugrist (sikachu) January 25th, 2010 @ 01:01 PM
- State changed from open to invalid
As said by Sevn Fuchs, I think you should complete it or use fallback backend.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>