On Wed, Mar 31, 2010 at 11:55 AM, Marius Gedminas <[email protected]> wrote: > On Wed, Mar 31, 2010 at 08:26:57AM -0700, Mike Orr wrote: >> On Wed, Mar 31, 2010 at 6:45 AM, Marius Gedminas <[email protected]> wrote: >> > I was left wondering about one thing: what would this print: >> > >> > >>> format_byte_size(1, full_name=True) >> > >> > '1.0 bytes'? >> >> Actually it prints '1 bytes'. >> >> I tried to add a singular case but it made the functions significantly >> more complex for an excedingly rare case. It's almost easier to >> substitute the whole output. Actually, I guess that would be doable. > > I'm not sure the added complexity would be worth it (plus it probably > wouldn't handle i18n). > > I just noticed the emphasis on supplying the plural form of the unit to > format_data_size while reading the docs, and wondered if that implied it > would be trying to guess the singular or not. I think it would be worth > mentioning directly in the documentation.
That's what I plan to do. Add a 'singular=None' arg at the end. Then if the formatted number is "1" and a singular is not provided, chop off a trailing "s" on the unit if it's longer than one character. That would cover bit/byte/gram/meter/metre, etc. I can't think of any common measurement that has a plural 'es', and dropping 'es' would screw up metre. I could make it smarter for 'en' (boxen/box), but that's way out in trivia-land. It has an English bias, but the SI/metric units have an English (actually French) bias anyway. We can't guess plurals that don't end in 's', or languages that have special forms for 2, 3, and 4 (as Russian does). -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
