Erwin
2011-Feb-03 09:53 UTC
[Rails3] Model.model_name.human not working with ActiveModel::Translation
I am using ActiveModel::Translation, it''s working fine for attributes, but I cannot get the Model name translated in the console I get ..>Profile.i18n_scope => :mongoid ( I am using Mongodb) >I18n.locale => :en >Profile.human_attribute_name("first_name") => "First Name" >Profile.model_name.human => "Profile"now changing the locale>I18n.locale = :fr => :fr >Profile.human_attribute_name("first_name") => "Prénom" ( it works !) >Profile.model_name.human => "Profile" ( it doesn''t work.... I should get "Profil"==== Model Profile require ''active_model'' class Profile include ActiveModel::AttributeMethods include ActiveModel::Translation include ActiveModel::Validations extend ActiveModel::Naming ... ==== locale :en en: mongoid: model: profile: Profile attributes: profile: first_name: First Name ==== locale :fr fr: mongoid: model: profile: Profil << I should get it !!! attributes: profile: first_name: Prénom << I get it !! what could be wrong ? I could not find any similar errors in Google ... strange, if I ask Model.human_name in the console, I don''t get the deprecated message ....>Profile.human_name => "Profile"thanks for your suggestions -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Konstantin Shabanov
2011-Feb-03 11:27 UTC
Re: [Rails3] Model.model_name.human not working with ActiveModel::Translation
mongoid: models: profile: Profile model should be in plural form. On Thu, Feb 3, 2011 at 3:53 PM, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> wrote:> I am using ActiveModel::Translation, it''s working fine for attributes, > but I cannot get the Model name translated > > in the console I get .. > > >Profile.i18n_scope => :mongoid ( I am using Mongodb) > >I18n.locale => :en > >Profile.human_attribute_name("first_name") => "First Name" > >Profile.model_name.human => "Profile" > > now changing the locale > >I18n.locale = :fr => :fr > >Profile.human_attribute_name("first_name") => "Prénom" ( it works !) > >Profile.model_name.human => "Profile" ( it doesn''t work.... I should > get "Profil" > > ==== Model Profile > require ''active_model'' > class Profile > include ActiveModel::AttributeMethods > include ActiveModel::Translation > include ActiveModel::Validations > extend ActiveModel::Naming > ... > > ==== locale :en > en: > mongoid: > model: > profile: Profile > attributes: > profile: > first_name: First Name > > ==== locale :fr > fr: > mongoid: > model: > profile: Profil << I should get it !!! > attributes: > profile: > first_name: Prénom << I get it !! > > > what could be wrong ? I could not find any similar errors in > Google ... > > strange, if I ask Model.human_name in the console, I don''t get the > deprecated message .... > >Profile.human_name => "Profile" > > thanks for your suggestions > > > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-Feb-03 11:36 UTC
Re: [Rails3] Model.model_name.human not working with ActiveModel::Translation
Thanks Konstantin ... you just confirmed what I finally found looking into lib/active_model/naming.rb => options.reverse_merge! :scope => [@klass.i18n_scope, :models], :count => 1, :default => defaults so I modified my locale files , and I was coming back here to mention it... and read your answer .. !! thanks again ... On 3 fév, 12:27, Konstantin Shabanov <eteht...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> mongoid: > models: > profile: Profile > > model should be in plural form. > > > > > > > > On Thu, Feb 3, 2011 at 3:53 PM, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > I am using ActiveModel::Translation, it''s working fine for attributes, > > but I cannot get the Model name translated > > > in the console I get .. > > > >Profile.i18n_scope => :mongoid ( I am using Mongodb) > > >I18n.locale => :en > > >Profile.human_attribute_name("first_name") => "First Name" > > >Profile.model_name.human => "Profile" > > > now changing the locale > > >I18n.locale = :fr => :fr > > >Profile.human_attribute_name("first_name") => "Prénom" ( it works !) > > >Profile.model_name.human => "Profile" ( it doesn''t work.... I should > > get "Profil" > > > ==== Model Profile > > require ''active_model'' > > class Profile > > include ActiveModel::AttributeMethods > > include ActiveModel::Translation > > include ActiveModel::Validations > > extend ActiveModel::Naming > > ... > > > ==== locale :en > > en: > > mongoid: > > model: > > profile: Profile > > attributes: > > profile: > > first_name: First Name > > > ==== locale :fr > > fr: > > mongoid: > > model: > > profile: Profil << I should get it !!! > > attributes: > > profile: > > first_name: Prénom << I get it !! > > > what could be wrong ? I could not find any similar errors in > > Google ... > > > strange, if I ask Model.human_name in the console, I don''t get the > > deprecated message .... > > >Profile.human_name => "Profile" > > > thanks for your suggestions > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscrib e@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.