Locales

Discussion in 'Ruby' started by Molitor, Stephen L, Apr 15, 2005.

  1. Does anyone know of a good library for doing locale sensitive formatting
    of numbers, money, and time? I.e.:

    require 'locale.rb'

    locale = Locale['fr_FRA']
    french_format = 10000.99.to_s(locale)
    #=> "10.000,99"

    default_locale_format = 10000.99.to_s
    #=> "10,000.99"

    Thanks!

    Steve
     
    Molitor, Stephen L, Apr 15, 2005
    #1
    1. Advertising

  2. On 4/15/05, Molitor, Stephen L <> wrote:
    > Does anyone know of a good library for doing locale sensitive formatting
    > of numbers, money, and time? I.e.:
    >
    > require 'locale.rb'
    >
    > locale = Locale['fr_FRA']
    > french_format = 10000.99.to_s(locale)
    > #=> "10.000,99"
    >
    > default_locale_format = 10000.99.to_s
    > #=> "10,000.99"


    Not that I know of. I know that the number formatting method I wrote
    many months ago and Gavin Sinclair included in his Extensions library
    does some locale-like formatting and is more configurable.

    It would be a good basis for a localization module if you want to use
    it, as well.

    -austin
    --
    Austin Ziegler *
    * Alternate:
     
    Austin Ziegler, Apr 16, 2005
    #2
    1. Advertising

  3. Hi,

    Am Samstag, 16. Apr 2005, 04:46:54 +0900 schrieb Molitor, Stephen L:
    > Does anyone know of a good library for doing locale sensitive formatting
    > of numbers, money, and time? I.e.:
    >
    > require 'locale.rb'
    >
    > locale = Locale['fr_FRA']
    > french_format = 10000.99.to_s(locale)
    > #=> "10.000,99"
    >
    > default_locale_format = 10000.99.to_s
    > #=> "10,000.99"


    Fixnum#to_s already has a parameter defined, the base:

    15.to_s 16 #=> f

    Bertram

    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
     
    Bertram Scharpf, Apr 16, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?YWxhbg==?=

    Datagrid sorting from different locales.

    =?Utf-8?B?YWxhbg==?=, Apr 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    432
    =?Utf-8?B?YWxhbg==?=
    Apr 21, 2005
  2. David List
    Replies:
    0
    Views:
    314
    David List
    Aug 6, 2003
  3. William Payne

    Correct use of locales?

    William Payne, Dec 13, 2003, in forum: C++
    Replies:
    3
    Views:
    415
    Morten Hanssen
    Dec 13, 2003
  4. Moof

    Python Locales under windows

    Moof, Oct 28, 2003, in forum: Python
    Replies:
    1
    Views:
    824
    =?UTF-8?B?0LTQsNC80ZjQsNC9INCzLg==?=
    Oct 28, 2003
  5. Ellen Herzfeld

    Bogus locales on Mac

    Ellen Herzfeld, Jul 14, 2004, in forum: Python
    Replies:
    3
    Views:
    404
    Ellen Herzfeld
    Jul 16, 2004
Loading...

Share This Page