hey,
i tried that plugin, you mentioned before.
when i run script/console and Model.human_attribute_name i get the
translated attribute name, i configured in one of my yml files.
but in my form
>>>>>>>>>>>>>>>>
<% form_for(:mail_contact, :url => contact_path) do |f| %>
<div class="question_form_info">
<p>
<%= label_tag 'mail_contact_name', t(:"info.name") + ":" %>
<%= f.text_field(:name, { :size => 25}) %>
</p>
<p>
<%= f.label :email %>
<%= f.text_field(:email, { :size => 15}) %>
</p>
<p>
<%= label_tag 'mail_contact_name', t(:"info.subject") + ":" %>
<%= f.text_field(:subject, { :size => 15}) %>
</p>
<p>
<%= label_tag 'mail_contact_comment', t(:"info.your_request") +
":" %>
<%= f.text_area(:comment, { :size => 15}) %>
</p>
</div>
<div class="question_form_submit">
<%= submit_tag t(:"common.send") %>
</div>
<% end %>
<<<<<<<<<<<<<<<<
my contact_form_presenter.rb
class ContactFormPresenter
include Validatable
acts_as_translatable_model
ATTRIBUTES = %w(name email subject comment)
ATTRIBUTES.each { |name| attr_accessor name }
ATTRIBUTES.each { |name| validates_presence_of name }
validates_format_of :email, :with => RegexCollection::EMAIL_REGEX
def initialize(attributes = nil)
ATTRIBUTES.each { |name| self.send("#{name}=",
attributes[name.to_sym]) } if attributes.is_a?(Hash)
end
end
<<<<<<<<<<<<<<
my yml:
de:
activerecord:
attributes:
contact_form_presenter:
name: "Name_de"
subject: "Subject_de"
email: "Email_de"
comment: "Comment_de"
en:
activerecord:
attributes:
contact_form_presenter:
name: "Name_en"
subject: "Subject_en"
email: "Email_en"
comment: "Comment_en"
<<<<<<<<<<<<<<
script/console:
>> I18n.locale
=> :"en-US"
>> ContactFormPresenter.human_attribute_name("subject")
=> "Subject_en"
>> I18n.locale=:"de-DE"
=> :"de-DE"
>> ContactFormPresenter.human_attribute_name("subject")
=> "Subject_de"
<<<<<<<<<<<<<<
i have set @mail_contact = ContactFormPresenter.new in my controller
but the email label is not translated,
and when i display the error_messages_for :mail_contact
but the attributes are not translated.
did i do something wrong?
thx, florian
On Sep 30, 11:52 am, fwalter <[EMAIL PROTECTED]> wrote:
> thx,
>
> ill try it
>
> thanx
>
> On Sep 30, 11:44 am, iain hecker <[EMAIL PROTECTED]> wrote:
>
> > Hi again florian,
>
> > I have made a plugin to do what you
> > wanted:http://iain.nl/2008/09/acts_as_translatable_model-plugin/
>
> > I don't know if that "include Validatable" uses the official Rails
> > validation, but you can include the official Rails validation too (it
> > requires some more work though)
>
> > I already mentioned how to use translations for activerecord in my
> > other reply ;)
>
> > --
> > Iain Heckerhttp://iain.nl/
>
> > On Sep 30, 11:31 am, fwalter <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I am using a model which is not an ActiveRecord.
>
> > > class ContactFormPresenter
> > > include Validatable
>
> > > ATTRIBUTES = %w(name email subject comment)
> > > ATTRIBUTES.each { |name| attr_accessor name }
>
> > > ATTRIBUTES.each { |name| validates_presence_of name }
> > > validates_format_of :email, :with => RegexCollection::EMAIL_REGEX
>
> > > def initialize(attributes = nil)
> > > ATTRIBUTES.each { |name| self.send("#{name}=",
> > > attributes[name.to_sym]) } if attributes.is_a?(Hash)
> > > end
> > > end
>
> > > <<<<<<<<<<<<<<
>
> > > if i don't put the :message =>
> > > I18n.t(:'activerecord.errors.messages.blank') , I only get the
> > > base_locale translation.
>
> > > btw. I would like to translate these attributes like ActiveRecords
> > > Attributes. how are the keys for that? active records are:
>
> > > de:
> > > activerecord:
> > > attributes:
> > > <modelname>:
> > > <attributename>:
>
> > > do you have any hints for me, solving that?
>
> > > thanks for help.
>
> > > florian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rails-i18n" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en
-~----------~----~----~----~------~----~------~--~---