Translations for active record models not working here

74 views
Skip to first unread message

koichirose

unread,
Jan 22, 2011, 2:26:07 PM1/22/11
to rails-i18n
My setup:
Rails 3.0.3 with fast_gettext, I18n default locale set to 'it'.

I have config/locales/it.yml with general translations (time and date
stuff, numbers etc.)
Then I created config/locales/models_it.yml, which contains:
it:
activerecord:
models:
user: 'utente'
review: 'recensione'
attributes:
review:
comment: 'commento'

Then, I go and create a new review. This requires a comment. I submit
it without one and it says:
* Comment non può essere lasciato in bianco

'non può essere lasciato in bianco' means 'can't be blank' and it's
taken from the general it.yml file.

My review/new.html.erb has this at the top:
<% if @review.errors.any? %>
<div id="error_explanation">
<ul>
<% @review.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

I can print this: I18n.t('activerecord.attributes.review.comment') and
it works. ==> 'commento'
So the problem is that 'errors.full_messages' I guess.

Is there something I need to set to make it use translations for model
attributes?

قصص عربية

unread,
Dec 29, 2013, 12:52:41 PM12/29/13
to rails...@googlegroups.com

قصص عربية

unread,
Dec 29, 2013, 12:53:07 PM12/29/13
to rails...@googlegroups.com
hgjhlkjklj;lkjl
Reply all
Reply to author
Forward
0 new messages