-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get list of available accessors? #356
Comments
of course I can use something like
or
but it look ugly :( |
Unfortunately there is no clean way to do this right now. The accessors are defined here:
There's nothing actually tracking their names once the methods have been defined. |
That is something that I extensively use, I would love to see that implemented |
Hmm I'm not sure. You can do this with something like: module I18nLocaleAccessors
def locale_accessor_names
mobility_attributes.flat_map do |name|
Mobility.available_locales.map do |locale|
"#{name}_#{Mobility.normalize_locale(locale)}"
end
end
end
end Then just class ApplicationRecord < ActiveRecord::Base
# ...
extend I18nLocaleAccessors
end Since it's quite simple to implement, I'm not really inclined to add it to the plugin unless there are others asking for it. That said, the way of calculating the names above is a bit inefficient... 🤔 |
We use it too at MaMpf and came here migrating from If anyone wonders how this change could look like in production-code, here are the changes I just made to our codebase. |
Hi!
Is there any method to get list of all available translation accessors, something like globalize_attribute_names from globalize gem?
The text was updated successfully, but these errors were encountered: