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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
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.