hey, i tried to follow your instructions:

<% form_for ContactFormPresenter.new, :url => contact_path do |f| %>
  <%= f.label :email %>
  <%= f.text_field :email %>
<% end %>

but it is not translated.
OUTPUT:

<form id="edit_contact_form_presenter_55524240"
class="edit_contact_form_presenter" method="post" action="/contact">
<div style="margin: 0pt; padding: 0pt;">
</div>
<label for="contact_form_presenter_email">Email</label>
<input id="contact_form_presenter_email" type="text" size="30"
name="contact_form_presenter[email]"/>
</form>

what am i doing wrong?

thx, florian

On Sep 30, 12:30 pm, "Iain Hecker" <[EMAIL PROTECTED]> wrote:
> Wow, you're about to use all of my plugins ;)
>
> About the labels:http://iain.nl/2008/09/form-labels-in-rails-22/
> Make sure you pass the instance variable to the form though:
>
> <% form_for(@mail_contact) do |f| %>
>   <%= f.label :name %>
> etc...
>
> On Tue, Sep 30, 2008 at 12:21, fwalter <[EMAIL PROTECTED]> wrote:
>
> > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to