Month, Day etc. names in other languages other than English

Discussion in 'Ruby' started by Diego, Aug 15, 2008.

  1. Diego

    Diego Guest

    Hi all,

    I was wondering if it was possible to internationalize the constant
    month and day names, used by DateTime class (for example), in to
    something other than English?

    I'm using gettext in a Rails application where I am able to
    internationalize most of the application. But in some cases where I
    take something like a Time class and represent it with a string, I see
    the English names for days and months. "Thu", "Aug" etc.

    I /think/ this goes all the way down to Ruby and not Rails, hence my
    post here. Any help would be appreciated as to how I can
    internationalize this area of my application.

    Thanks.

    Cheers,
    Diego
     
    Diego, Aug 15, 2008
    #1
    1. Advertising

  2. Diego wrote:
    > Hi all,
    >
    > I was wondering if it was possible to internationalize the constant
    > month and day names, used by DateTime class (for example), in to
    > something other than English?
    >
    > I'm using gettext in a Rails application where I am able to
    > internationalize most of the application. But in some cases where I
    > take something like a Time class and represent it with a string, I see
    > the English names for days and months. "Thu", "Aug" etc.
    >
    > I /think/ this goes all the way down to Ruby and not Rails, hence my
    > post here. Any help would be appreciated as to how I can
    > internationalize this area of my application.
    >
    > Thanks.
    >
    > Cheers,
    > Diego


    If it is a ruby issue, you can override the constants defined in the
    Date class. It will earn you a warning: already initialized constant,
    but that's just what we mean to do. Using Dutch daynames:

    require 'Date'
    Date.const_set("DAYNAMES",%w(zondag maandag dinsdag woensdag donderdag
    vrijdag zaterdag))
    p Date.today.strftime("%A")

    Check http://www.ruby-doc.org/stdlib/libdoc/date/rdoc/classes/Date.html
    for the other constants like MONTHNAMES, ABBR_MONTHNAMES, and
    ABBR_DAYNAMES.

    hth,

    Siep


    --
    Posted via http://www.ruby-forum.com/.
     
    Siep Korteling, Aug 15, 2008
    #2
    1. Advertising

  3. Re: Month, Day etc. names in other languages other than Engl

    Siep Korteling wrote:
    > If it is a ruby issue, you can override the constants defined in the
    > Date class. It will earn you a warning: already initialized constant,
    > but that's just what we mean to do. Using Dutch daynames:


    Doing so breaks DateTime. E.g. parsing will fail afair. There's probably
    more issues.

    > require 'Date'


    Don't require 'Date', require 'date' instead. Otherwise your apps/libs
    will break on case sensitive file systems.

    Regards
    Stefan Rusterholz ("apeiros")
    --
    Posted via http://www.ruby-forum.com/.
     
    Stefan Rusterholz, Aug 16, 2008
    #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. Replies:
    1
    Views:
    453
    Steve W. Jackson
    Dec 22, 2006
  2. John
    Replies:
    0
    Views:
    324
  3. Andy
    Replies:
    1
    Views:
    721
  4. Replies:
    0
    Views:
    131
  5. Rob Redmon

    Convert day of year to month, day

    Rob Redmon, Apr 4, 2008, in forum: Ruby
    Replies:
    7
    Views:
    307
    Alex Wayne
    Apr 4, 2008
Loading...

Share This Page