calebhearth / formulaic

Simplify form filling with Capybara
MIT License
552 stars 29 forks source link

Object namespaces don't seem to lookup i18n keys appropriately #19

Closed derekprior closed 10 years ago

derekprior commented 10 years ago

The following name-spaced class:

class Admin::Reservation
  # some stuff
end

requires i18n keys such as:

activemodel:
  attributes:
    admin/reservation:
      field: 'Name'

But it seems like formulaic is dropping the namespace.

calebhearth commented 10 years ago

Yup. Because Formulaic isn't a part of action_pack or action_view, it doesn't know where you are defining your translations except for where you tell it when you pass fill_form(model_name, ...). This will probably work if you pass :"admin/reservation" or :"admin.reservation" to fill_form as the first argument.

calebhearth commented 10 years ago

Oh, and it's not looking for activemodel field names, it's looking for simple_form ones. https://github.com/thoughtbot/formulaic/blob/master/lib/formulaic/label.rb#L23

derekprior commented 10 years ago

Oh, and it's not looking for activemodel field names, it's looking for simple_form ones.

I'm usually interested in changing the way a field is represented application-wide (not just in a specific label). In that case, I use the i18n location for human_attribute_name, which formulaic does seem to (try to?) support. No problems there.

https://github.com/thoughtbot/formulaic/blob/master/lib/formulaic/label.rb#L26

Because Formulaic isn't a part of action_pack or action_view, it doesn't know where you are defining your translations except for where you tell it when you pass fill_form(model_name, ...). This will probably work if you pass :"admin/reservation"

This makes sense. Thanks.