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 helper: fix/introduce pluralization, add 'format' property

#1634

number_to_human_size I18n:

FIXES

Now using pluralization properly (actually I18n did not work at all for Byte/Bytes). Had to move I18n key in translations table (number.human.storage_units.units).

FEATURES

Added number.human.storage_units.format for languages like Japanese where unit formatting is not "{{number}} {{unit}}" but rather "{{number}}{{unit}}".

NOTES

People will need to change translations for their language when using number_to_human_size. I'll try to update Sven's rails-i18n repo right after this gets commited.

Reported by Yaroslav Markin · December 25th, 2008 @ 08:39 PM

State: committed
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Yaroslav Markin
    Yaroslav Markin

    Needs more discussion.

    Since it fixes a bug anyway, in case we don't come up with a better solution, we should apply this to 2.3.

    December 26th, 2008 @ 12:22 PM

  2. Yaroslav Markin
    Yaroslav Markin

    Sven suggested that translations table should look different, so here we are.

    This way we don't do "random" lookups to translation table for getting max_exp, but a number of possible units is limited by a constant and values in translation table.

    January 1st, 2009 @ 06:32 PM

  3. Yaroslav Markin
    Yaroslav Markin
    • Assigned user changed from Jeremy Kemper to Sven Fuchs

    January 2nd, 2009 @ 08:57 AM

  4. Yaroslav Markin
    Yaroslav Markin
    • Tag changed from actionview, helpers, i18n, patch to 2.3, actionview, bug, helpers, i18n, patch

    Sven: ping

    January 18th, 2009 @ 12:30 PM

  5. Pratik
  6. Sven Fuchs
    Sven Fuchs

    Haven't run the tests, but yeah, I think this is the way to go (using pluralization, i.e. the second approach).

    Yaroslav, looking at the translation data - Byte/Bytes is the only pluralized bit. Will the code still work when one adds Kilobyte/Kilobytes?

    Also, should the key be renamed to : storage_units_abbrevations?

    January 18th, 2009 @ 10:31 PM

  7. Yaroslav Markin
    Yaroslav Markin

    Sven, yes, all keys are ready for pluralization, I pass :count all the time.

    Regarding @:storage_units_abbreviations@, that is exactly the reason I don't like to name the key "abbreviations" -- you actually may change "KB" to "Kilobyte"/"Kilobytes" anytime :)

    January 19th, 2009 @ 05:34 PM

  8. Sven Fuchs
    Sven Fuchs

    Alright, cool. Yeah, then I think we should go with this solution.

    +1 from me

    January 21st, 2009 @ 11:03 PM

  9. Sven Fuchs
    Sven Fuchs
    • Assigned user changed from Sven Fuchs to Jeremy Kemper

    Jeremy, I'll assign this to you, so you know there's something to apply :)

    January 21st, 2009 @ 11:08 PM

  10. Repository
    Repository
    • State changed from new to committed

    (from [17db28f1ca0597fa1e9abdcacd934ca27d589fb9]) 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 number_to_human_size helper: fix/introduce pluralization, add 'format' property state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...

    January 27th, 2009 @ 05:24 PM