Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

number_to_human_size only working properly when :precision and :separator given

#3201

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"

Reported by Smeevil · September 14th, 2009 @ 09:27 PM

State: invalid
Milestone: 2.3.6
Importance: Low

Activity

  1. CancelProfileIsBroken
  2. Dmitry Maksimov
    Dmitry Maksimov

    +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...

    September 26th, 2009 @ 05:57 PM

  3. Blue Box Chris
    Blue Box Chris

    -1 for Ruby 1.8.6 with Rails 2.0.5

    number_to_human_size(10000000000)
    NoMethodError: undefined method number_to_human_size' for #<Object:0x2af485abb338><br/>

    from (irb):1
    

    include ActionView::Helpers::NumberHelper => Object number_to_human_size(10000000000) => "9.3 GB"

    September 26th, 2009 @ 10:09 PM

  4. Matías Flores
    Matías Flores

    verified in 2-3-stable

    steps to reproduce:

    1. create a custom locale file (e.g. es.yml) on config/locales
    2. make sure you are not defining any number[:human][:format] nor number[:format] settings as kolo mentioned
    3. 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.

    September 27th, 2009 @ 03:39 AM

  5. Rizwan Reza
    Rizwan Reza
    • State changed from new to open
    • Tag changed from bugmash to actionview, i18n, locale
    • Milestone set to 2.3.6

    January 21st, 2010 @ 07:31 AM

  6. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • Assigned user set to Prem Sichanugrist (sikachu)

    January 24th, 2010 @ 09:45 AM

  7. Sven Fuchs
    Sven Fuchs

    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)

    January 25th, 2010 @ 12:52 PM

  8. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from open to invalid

    As said by Sevn Fuchs, I think you should complete it or use fallback backend.

    January 25th, 2010 @ 01:01 PM