Luca Romagnoli
Luca Romagnoli

Reputation: 12455

i18n and Date::ABBR_DAYNAMES

hi i want translate the names in Date::ABBR_DAYNAMES in ita and so i've put in locales/it.yml this:

 date:
formats:
  default: "%d-%m-%Y"
  short: "%d %b"
  long: "%d %B %Y"

day_names: [Domenica, Lunedì, Martedì, Mercoledì, Giovedì, Venerdì, Sabato]
abbr_day_names: [Dom, Lun, Mar, Mer, Gio, Ven, Sab]

in my view i try to translate a day but doesn't work:

<%=t Date::ABBR_DAYNAMES %> 

How can i do?

Thanks

Upvotes: 4

Views: 6053

Answers (1)

Veger
Veger

Reputation: 37905

I do not know if the formatting is corrupted due to pasting it to your question or not, but the spacing/level in front of the lines is important and broken in your question.
Also, at the top your locale is required (and missing in your example).

it:
  date:
    formats:
      default: "%d-%m-%Y"
      short: "%d %b"
      long: "%d %B %Y"

    # Note that the spaces are reduced again
    day_names: [Domenica, Lunedì, Martedì, Mercoledì, Giovedì, Venerdì, Sabato]
    abbr_day_names: [Dom, Lun, Mar, Mer, Gio, Ven, Sab]

For more information about I18n and Date/Time formatting, see this article (Edit: from archive, as the original is not available anymore). The en.yml shows all available fields you could translate into Italian.

On script/console you can try the Italian locale:

>> I18n.t 'date.abbr_day_names'
=> ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
>> I18n.locale = "it"
>> I18n.t 'date.abbr_day_names'
=> ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"]

Upvotes: 6

Related Questions