Form Labels in Rails 2.2
- September 12th, 2008
- Posted in Rails Plugins . Ruby on Rails
- Write comment
Shamelessly copy-pasted from the README file of the new plugin I released today:
Since form labels don’t use I18n in Rails 2.2 (I was too late in submitting the patch), we’d have to make due with a plugin.
Installation and configuration consists of 1 easy steps:
- Run: ./script/plugin install git://github.com/iain/i18n_label.git
Example
In your translation file:
en-US:
activerecord:
attributes:
topic:
name: 'A nice name'In your view:
<% form_for Topic.new do |f| %> <%= f.label :name %> <% end %>
The result is:
<label for="topic_name">A nice name</label>
For more information about where to put your translations, read my post about translating ActiveRecord.
Excellent! Just what I was waiting for to finally release my first rails website. Thank you so much!
Great stuff, will vendorize it in http://github.com/yaroslav/russian if you dont have anything against
Will use in all my 2.2 apps.
You have a typo in README.
It is not
Crap, formatting lost
see here http://github.com/iain/i18n_label/commit/44b1004ff7bd4e5d5c4cfcf236e15e3974ab11c9#comment_5595
Yaroslav, rookie mistake
fixed it! Of course you can use it however you like, I’d be pleased!
Is i18n_label broken with rails 2.2.2?
No, not that I’m aware of… I am using it with success…
I recently began using Rails, and this is the first plugin I’ve installed. It works great for me with Rails 2.2.2. Thanks!
Using this from now %) Any information on when this will be merged with rails?
Thanx anyway!
Still not in Rails because they’re discussing over capitalization…
https://rails.lighthouseapp.com/projects/8994/tickets/745-form-label-should-use-i18n
The plugin seems to ignore an empty/blank string in the label text:
form.label(:myfield, ' ')should render
<label ...> </label>but it renders
<label ...>My Field</label>(or whatever the translation is)which differs from the normal FormHelper behavior.