Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Month, Day etc. names in other languages other than English

Reply
Thread Tools

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

 
 
Diego
Guest
Posts: n/a
 
      08-15-2008
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
 
Reply With Quote
 
 
 
 
Siep Korteling
Guest
Posts: n/a
 
      08-15-2008
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/libdo...sses/Date.html
for the other constants like MONTHNAMES, ABBR_MONTHNAMES, and
ABBR_DAYNAMES.

hth,

Siep


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Stefan Rusterholz
Guest
Posts: n/a
 
      08-16-2008
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/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Now.day and day(now) returning the wrong day! Andy ASP .Net 1 11-06-2008 12:20 PM
Does Eclipse support languages other than English ? John Java 0 08-12-2007 01:06 AM
HTMLEncode works only in English chars, but not in other UTF-8 languages Gabriella Javascript 4 09-19-2006 05:08 AM
Latent semantic indexing, but for other languages than English ? Nuralanur@aol.com Ruby 0 03-12-2006 10:49 AM
UK Only - Courses in ESOL (English forSpeakers of Other Languages). M Computer Support 1 09-04-2005 11:01 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57