Forum: Rails I18n What I put in is not what I get back

798fc1150a1fee627eca0c9c7f70d6b1?d=identicon&s=25 Johan (Guest)
on 2011-04-19 10:33
(Received via mailing list)

Rails date_select method takes an order argument, like this:
  date_select 'page', 'publish_at', :order => [:day, :month, :year]

The items in the order array *must* be symbols, so this does not work:
  date_select 'page', 'publish_at', :order => ['day', 'month', 'year']

Lets say we have this locale file:
      - :year
      - :month
      - :day

When using i18n's simple backend, I18n.t('date.order'), would return
exactly [:day, :month, :year] (an array of symbols).

However, if I change the backend to a key/value-store, such as a Hash
or Redis, the return value of I18n.t('date.order') would be exactly
['day', 'month', 'year'] (an array of strings).

Obiously this raises a problem in Rails since the date_select (an
friends) do not accept strings in the array.

So, who to blame?

 - Should all key/value stores support Ruby symbols?
 - Should Rails accept strings in the array?
 - Should i18n try to be clever (if even possible)?
 - ...

This topic is locked and can not be replied to.