I18n::InvalidPluralizationData Questions from an i18n Noob

871 views
Skip to first unread message

David Christiansen

unread,
Nov 4, 2009, 11:46:54 AM11/4/09
to rails-i18n
So far I've found internationalization with Rails to be a very
pleasant experience. But I've run into trouble trying to translate
model names and I need a little help.

Here's my fr.yml:
fr:
activerecord:
models:
person: Personne
attributes:
last_name: "Nom de Famille"

Please forgive me if the French is bad - I'm just using it as a
bootstrap example and it's not an official translation.

Last name is a required field and when I try to save I get this error:

translation data {:person=>"Personne"} can not be used with :count =>
1

And here's some more information from Rails:

Extracted source (around line #28):

25:
26: <% content_for :title do %>
27: Edit Morbidity Event: <%= h(patient_name) %>
28: <% end %>
29:
30: <% content_for :tools_two do %>
31: <%= save_buttons(@event) %>

RAILS_ROOT: /home/david/trisano-ee/webapp
Application Trace | Framework Trace | Full Trace

/home/david/trisano-ee/webapp/vendor/rails/activesupport/lib/
active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:139:in
`pluralize'
/home/david/trisano-ee/webapp/vendor/rails/activesupport/lib/
active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:40:in
`translate'
/home/david/trisano-ee/webapp/vendor/rails/activesupport/lib/
active_support/vendor/i18n-0.1.3/lib/i18n.rb:165:in `t'
/home/david/trisano-ee/webapp/vendor/rails/actionpack/lib/action_view/
helpers/active_record_helper.rb:197:in `error_messages_for'
/home/david/trisano-ee/webapp/vendor/rails/activesupport/lib/
active_support/core_ext/object/misc.rb:78:in `with_options'
/home/david/trisano-ee/webapp/vendor/rails/actionpack/lib/action_view/
helpers/active_record_helper.rb:192:in `error_messages_for'
/home/david/trisano-ee/webapp/app/views/morbidity_events/edit.html.erb:
28:in `_run_erb_app47views47morbidity_events47edit46html46erb'
/home/david/trisano-ee/webapp/app/controllers/
morbidity_events_controller.rb:141:in `update'
/home/david/trisano-ee/webapp/app/controllers/
morbidity_events_controller.rb:123:in `update'

Anybody have any ideas what's going on?

Thanks in advance for the help.


Dave Christiansen
Senior Developer
Collaborative Software Initiative
503-545-5350 (CSI TriSano™ Support)
317-966-6154 (personal)
da...@csinitiative.com

ricard.forniol

unread,
Nov 17, 2009, 8:50:40 PM11/17/09
to rails-i18n
I'm having the same trouble, does anyone know what happen?

ricard.forniol

unread,
Nov 18, 2009, 10:46:22 AM11/18/09
to rails-i18n
I found the answer myself. The wrong thing is the definition of the
fr.yml

activerecord:
attributes:
subscriber:
name: 'Nombre'
surname: 'Apellido'
email: 'Email'

Ricard

Dave Christiansen

unread,
Nov 18, 2009, 10:54:27 AM11/18/09
to rails...@googlegroups.com
So, my question is how would you get the translation of "subscriber" model name in this example?

Dave Christiansen
Senior Developer
Collaborative Software Initiative
503-545-5350 (CSI TriSano™ Support)
317-966-6154 (personal)
da...@csinitiative.com

--

You received this message because you are subscribed to the Google Groups "rails-i18n" group.
To post to this group, send email to rails...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-i18n?hl=.


ricard.forniol

unread,
Nov 18, 2009, 11:21:50 AM11/18/09
to rails-i18n
If you get the locale from url /fr/controller/action or by putting it
manually in the action controller I18n.locale = :es then rails helpers
will get all information from the fr.yml or es.yml depending on the
specified locale.

Then in the view Subscriber.human_attribute_name('email')

All rails helpers suport translations, so if you put for example
error_messages_for 'subscriber' all translated messages will appear
and the missing ones will be notified with an inline error.

Ricard
On 18 Nov, 16:54, Dave Christiansen <d...@csinitiative.com> wrote:
> So, my question is how would you get the translation of "subscriber" model name in this example?
>
> Dave Christiansen
> Senior Developer
> Collaborative Software Initiative
> 503-545-5350 (CSI TriSano™ Support)
> 317-966-6154 (personal)
> d...@csinitiative.com

Dave Christiansen

unread,
Nov 18, 2009, 12:24:07 PM11/18/09
to rails...@googlegroups.com
Thanks Ricard. I've got that part figured out - translating attributes is working. What's not working is translating model names. For example, let's say I have a model named "User" with attributes "Name" and "Email". I can translate "Name" and "Email" easily, but I also need to translate the classname "User" to its equivalent in other languages, but I keep getting the I18n::InvalidPluralizationData exception.

Have you got that part working?

Thanks,

Dave Christiansen
Senior Developer
Collaborative Software Initiative
503-545-5350 (CSI TriSano™ Support)
317-966-6154 (personal)
da...@csinitiative.com

ricard.forniol

unread,
Nov 18, 2009, 3:08:56 PM11/18/09
to rails-i18n
I don't know the rails way for translating models, I haven't needed
yet.

On 18 Nov, 18:24, Dave Christiansen <d...@csinitiative.com> wrote:
> Thanks Ricard. I've got that part figured out - translating attributes is working. What's not working is translating model names. For example, let's say I have a model named "User" with attributes "Name" and "Email". I can translate "Name" and "Email" easily, but I also need to translate the classname "User" to its equivalent in other languages, but I keep getting the I18n::InvalidPluralizationData exception.
>
> Have you got that part working?
>
> Thanks,
>
> Dave Christiansen
> Senior Developer
> Collaborative Software Initiative
> 503-545-5350 (CSI TriSano™ Support)
> 317-966-6154 (personal)
Reply all
Reply to author
Forward
0 new messages