sferik/rails_admin — pull request #1304 by vala (2012-09-04 14:05:26+00:00)
Title: Add i18n to filters labels

Hi,

I was missing the ability to cleanly translate the filter options in my application.
What I call filter options is the HTML options hardcoded in the ra.filter-box.js that are proposed depending on the field type that you're trying to filter.

This pull request is made so it can be criticized and solutions can be given because, while the hack works, it's quite ugly in some places.

The things to note that I'd like to discuss :
* I had to rename `ra.filter-box.js` to `ra.filter-box.js.erb` so I can dynamically insert the I18n names. I could have loaded them through Ajax, or even worst made a JS translation file, but I thought it was a cleaner way.
* I coded an erb inlined helper inside the `ra.filter-box.js.erb` because, as we don't have access to ActionView helpers in this file, I didn't want to make every call to the translate helper method too long so it keeps readable.
* Should I test this kind of code ? I suppose it can be done, but if it can be I'll be glad someone gives me a clue on how to proceed here.

The patch lets you translate those filter options directly in the locale file