Koke’s

My English alter-ego

Translating dates in ruby (on rails)

Posted by Jorge Bernal January 17, 2007

Update: month names list has nil at the beginning

Based on Localization for Ruby’s Time#strftime, I’ve come across a simple solution when you are developing a non-multilanguage app in a non-English language.

If it’s for rails, we put this on lib/environment.rb. In any other cases, put this code at the initialisation stage

  Date::MONTHNAMES.replace [nil] + %w(Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre)
  Date::DAYNAMES.replace = %w(Domingo Lunes Martes Miércoles Jueves Viernes Sábado)
  Date::ABBR_MONTHNAMES.replace [nil] + %w(Ene Feb Mar Abr May Jun Jul Ago Sep Oct Nov Dic)
  Date::ABBR_DAYNAMES.replace %w(Dom Lun Mar Mié Jue Vie Sab)

Of course, you should translate it to your language if it’s not Spanish.

The result:

  >> Date.today.strftime("%A, %d de %B de %Y")
  => "Miércoles, 17 de Febrero de 2007"

AddThis Social Bookmark Button   AddThis Feed Button

Typo sentenced to death

Posted by Jorge Bernal January 16, 2007

That’s it. I’m tired of error 500 all the time. I’m not sure if I should blame typo or Dreamhost, but the thing is I’ll migrate this blog back to Wordpress one of these days.

Just to have it at hand when that day comes: Automatic migration from typo to Wordpress

Update: It’s done

AddThis Social Bookmark Button   AddThis Feed Button

PHP pearls

Posted by Jorge Bernal January 11, 2007

Found this in the PHP manual:

Note: Also note that if you are embedding PHP within XML or XHTML you will need to use the <?php ?> tags to remain compliant with standards.

What?? Who cares?? I mean, this embedded PHP code is meant to be seen only by the PHP interpreter, parsed and sent back to the client as XML or XHTML, so what’s the point here?

AddThis Social Bookmark Button   AddThis Feed Button

The power of Apple brand

Posted by Jorge Bernal January 09, 2007

I think this resumes all the strength of the Apple brand:

The biggest letdown is the fact that the iPhone won’t be available until June 2007 in the U.S. They have so much horsepower and untested software packed into this tiny device that the first version will almost certainly have problems – overheating, bugs, etc. That won’t stop millions from buying it as soon as it is available. And it won’t stop me, either.

(Via: TechCrunch)

AddThis Social Bookmark Button   AddThis Feed Button

Ninja turtles

Posted by Jorge Bernal January 03, 2007

I love xkcd comics

AddThis Social Bookmark Button   AddThis Feed Button

The Youngest Grocer In America

Posted by Jorge Bernal January 02, 2007

Not really sure if he’s the youngest, but it’s definitely a great story

[Via SvN]

AddThis Social Bookmark Button   AddThis Feed Button