From dave at csinitiative.com Wed Nov 4 11:01:48 2009 From: dave at csinitiative.com (Dave Christiansen) Date: Wed, 4 Nov 2009 10:01:48 -0600 (CST) Subject: [Rails I18n] Error trying to translate a model name in a validation message Message-ID: <1125763113.768061257350508229.JavaMail.root@mail-2.01.com> 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) dave at csinitiative.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From wojtekb82_23 at tlen.pl Tue Nov 17 08:47:11 2009 From: wojtekb82_23 at tlen.pl (Michal Burak) Date: Tue, 17 Nov 2009 14:47:11 +0100 Subject: [Rails I18n] i18n full_message testing problem Message-ID: <3e0a768a62f040b72a2241e936c26a55@ruby-forum.com> Hi. Rails version 2.3.4 ----------- Running a functional test: -------------- Exception: translation missing: pl, activerecord, errors, models, user, attributes, email, email_short app/views/users/new.pl.html.erb:3 1:

Rejestracja nowego u?ytkownika

2: 3: <%= error_messages_for :user %> 4: <% form_for :user, :url => users_path do |f| -%> 5: 6:


app/views/users/new.pl.html.erb:3 app/controllers/users_controller.rb:59:in `create' /test/functional/users_controller_test.rb:91:in `create_user' /test/functional/users_controller_test.rb:53:in `test_should_require_email_on_signup' /test/functional/users_controller_test.rb:52:in `test_should_require_email_on_signup' /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' /usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run' /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each' /usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run' /usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite' /home/wojtek/workspace_galileo/.metadata/.plugins/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb:117:in `start_mediator' /home/wojtek/workspace_galileo/.metadata/.plugins/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb:62:in `start' /home/wojtek/workspace_galileo/.metadata/.plugins/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb:328 -------------- My model users.rb ------------------ validates_length_of :email, :within => 3..100, :too_short => :email_short, :too_long => :email_long --------- My translations in pl.yml ------------- The below works when I use the application the standard way through WWW. This does not get read only within test environment. pl: (...) activerecord: (...) errors: (...) full_messages: email_short: "my message 1 {{count}}" email_long: "my message 2 {{count}}" (...) ---------------- QUESTION ------------------------- How do I avoid this testing error? I am not using this translation node " pl, activerecord, errors, models, user, attributes, email, email_short" but a full_mesage instead (cos I need a specific message, not a {attribute} {message} pair, it will not work in my language). Any help appreciated. -- Posted via http://www.ruby-forum.com/.