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 broken if current locale doesn't define number.format.separator or number.human.format.separator

#820

number_to_human_size kinda breaks, if neither precision/separator/delimiter are passed in options[] nor is there a corresponding translation for number.format.separator or number.human.format.separator in the current translation.

Example:


I18n.locale = 'en-US'
helper.number_to_human_size(1024**3) #=> "1 GB"
I18n.locale = 'KLINGON'
helper.number_to_human_size(1024**3) #=> 1.0

For the sake of backward compatibility with code that calls number_to_human_size with a single numeric argument when no translations for the aforementioned are available in the current locale, I think providing hardcoded fallback default for precision/separator/delimiter is reasonable.

Reported by Mihai Târnovan · August 14th, 2008 @ 07:07 AM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Mihai Târnovan
    Mihai Târnovan

    Here's a patch. Sorry, but I don't use git (yes), so I'll attach a diff. This patch also allows storage units to be translated.

    August 13th, 2008 @ 06:47 PM

  2. josh
    josh
    • State changed from new to incomplete

    Can you please add some unit tests to the patch.

    Also, I'd keep the STORAGE_UNITS constant.

    November 22nd, 2008 @ 07:21 PM

  3. Mihai Târnovan
  4. josh
    josh
    • State changed from incomplete to committed

    November 24th, 2008 @ 07:24 PM