OK. After much trial and error, here is the code that works:
t("date.month_names")[8]
Basically, call the I18n.translate method passing the date.month_names
key which return an array of month names, then access the index for
the desired month. (The first slot in the array is nil so indexes
match names correctly).
OK. After much trial and error, here is the code that works:
t("date.month_names")[8]
Basically, call the I18n.translate method passing the date.month_names
key which return an array of month names, then access the index for
the desired month. (The first slot in the array is nil so indexes
match names correctly).
Interesting. Note that with Gettext-type I18n (e.g. with fast_gettext),
this would be much simpler, just _(Date::MONTHNAMES[8]), since Gettext
uses the translatable string itself as a key rather than Rails' weird
symbolic keys. In general, I highly recommend using Gettext rather than
Rails' default backend.
Interesting. Note that with Gettext-type I18n (e.g. with fast_gettext),
this would be much simpler, just _(Date::MONTHNAMES[8]), since Gettext
uses the translatable string itself as a key rather than Rails' weird
symbolic keys. In general, I highly recommend using Gettext rather than
Rails' default backend.
I had translatable strings as keys (a long time ago in a completely
different software environment) and it ended up causing quite a
hassle, when one word (or phrase) in the english text needed to be
mapped to two (or more) different words for some languages
Interesting. Note that with Gettext-type I18n (e.g. with fast_gettext),
this would be much simpler, just _(Date::MONTHNAMES[8]), since Gettext
uses the translatable string itself as a key rather than Rails' weird
symbolic keys. In general, I highly recommend using Gettext rather than
Rails' default backend.
I had translatable strings as keys (a long time ago in a completely
different software environment) and it ended up causing quite a
hassle, when one word (or phrase) in the english text needed to be
mapped to two (or more) different words for some languages
Gettext has ways to disambiguate. Anyway, if you structure your
translatable strings properly (e.g. by using entire phrases as units),
this shouldn't be an issue. Rails' symbolic keys are IMHO a mistake.