This was filed as: <https://rails.lighthouseapp.com/projects/8994/tickets/6080-i18n-support-for-html5-placeholder-attribute> …and Aditya Sanghi suggsted I post to the list about it Currently, Rails'' I18n system automatically looks up localized text for <label> tags. It would be nice if it did something similar for the HTML5 placeholder attribute. Your en.yml file would like this: helpers: placeholder: person: first_name: "John" last_name: "Doe" Your ERB would look the same: <%= f.text_field :first_name %> Your HTML would look like this: <input id="person_first_name" name="person[first_name]" placeholder="John" type="text" /> Currently, you have to clutter up your markup like so: <%= f.text_field :first_name, :placeholder => t(''helpers.placeholder.person.first_name'') %> Paul -- 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.
On 29 Nov 2010, at 23:31, Paul Schreiber wrote:> This was filed as: > <https://rails.lighthouseapp.com/projects/8994/tickets/6080-i18n-support-for-html5-placeholder-attribute > > > …and Aditya Sanghi suggsted I post to the list about it > > Currently, Rails'' I18n system automatically looks up localized text > for <label> tags. It would be nice if it did something similar for > the HTML5 placeholder attribute. > > Your en.yml file would like this: > > helpers: > placeholder: > person: > first_name: "John" > last_name: "Doe" > > Your ERB would look the same: > <%= f.text_field :first_name %> > > Your HTML would look like this: > <input id="person_first_name" name="person[first_name]" > placeholder="John" type="text" /> > > Currently, you have to clutter up your markup like so: > <%= f.text_field :first_name, :placeholder => > t(''helpers.placeholder.person.first_name'') %>Should be fairly trivial to add this yourself: - alias the to_input_field_tag from Rails to to_input_field_tag_old (it''s in the InstanceTagMethods module of Rails if I recall correctly) - define your own to_input_field_tag - all that method needs to do is merge the I18n.t("helpers.placeholder.#{object_name}.#{method_name}") value into the options hash as :placeholder and then call the aliassed to_input_field_tag_old Best regards Peter De Berdt -- 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.
I would encourage you to implement it and submit a patch following the processes outlined in the contributors guide: https://rails.lighthouseapp.com/projects/8994/sending-patches It seems a good idea to me and creating a ticket and a patch for the feature is the best way to get the Rails Core team to consider it in detail. Cheers, Walter P.S. - plus if it gets accepted, you have a nice little bragging right for "I have contributed to the source code for Rails" On Wed, Dec 1, 2010 at 4:51 AM, Peter De Berdt <peter.de.berdt-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote:> > On 29 Nov 2010, at 23:31, Paul Schreiber wrote: > > This was filed as: > <https://rails.lighthouseapp.com/projects/8994/tickets/6080-i18n-support-for-html5-placeholder-attribute> > …and Aditya Sanghi suggsted I post to the list about it > > Currently, Rails'' I18n system automatically looks up localized text for > <label> tags. It would be nice if it did something similar for the HTML5 > placeholder attribute. > > Your en.yml file would like this: > > helpers: > placeholder: > person: > first_name: "John" > last_name: "Doe" > > Your ERB would look the same: > <%= f.text_field :first_name %> > > Your HTML would look like this: > <input id="person_first_name" name="person[first_name]" placeholder="John" > type="text" /> > > Currently, you have to clutter up your markup like so: > <%= f.text_field :first_name, :placeholder => > t(''helpers.placeholder.person.first_name'') %> > > Should be fairly trivial to add this yourself: > - alias the to_input_field_tag from Rails to to_input_field_tag_old (it''s in > the InstanceTagMethods module of Rails if I recall correctly) > - define your own to_input_field_tag > - all that method needs to do is merge the > I18n.t("helpers.placeholder.#{object_name}.#{method_name}") value into the > options hash as :placeholder and then call the aliassed > to_input_field_tag_old > > Best regards > > Peter De Berdt > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On Nov 30, 10:51 am, Peter De Berdt <peter.de.be...-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote:> Should be fairly trivial to add this yourself: > > - alias the to_input_field_tag from Rails to to_input_field_tag_old > (it''s in the InstanceTagMethods module of Rails if I recall correctly) > - define your own to_input_field_tag > - all that method needs to do is merge the > I18n.t("helpers.placeholder.#{object_name}.#{method_name}") value into > the options hash as :placeholder and then call the aliassed > to_input_field_tag_oldThanks for the pointer. I submitted a patch to to_input_field_tag and attached it to the ticket: <https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/ 6080> Paul -- 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.