-
Notifications
You must be signed in to change notification settings - Fork 265
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
Allow relative keys in any Ruby object #381
Conversation
The approach currently taken in this pull request isn't compatible with existing applications which might assume the method name will be part of the generated translation key. Any advice about how to handle this scenario? |
Perhaps we could make the regexp for including the method name a setting, e.g. For backwards compatibility, it can default to |
Rather than a regex settings, a list of directories would probably be better, as we already have |
Ah but there we have |
When using relative keys in controllers and mailers, it usually makes sense to assume the name of the method (such as "index" or "new") should be part of the absolute key, since they generally follow the "one method == one action" pattern and there's a view file associated with this action. However, in other classes, like presenters, decorators, components, or any other plain old Ruby object, that isn't usually the case. For instance, in components the view file is associated with the whole Ruby class and not just one method. So now the calling method is only included as part of the key in classes where it's determined the key should be relative to the method.
a2b4c5d
to
6588911
Compare
By default the list of files where these keys are excluded is empty in order to provide backwards compatibility.
@glebm I've updated the pull request based on your comments. Again, I'm not familiar with this code, so any suggestions are much appreciated 😉. |
I forgot to mention I'm using an |
Hi, this would be a useful feature for us, because we did run in similar problems with interactors and components. Can we provide any support to get this merged and released? |
Ah, this slipped through the cracks. |
I'm interested in using this option with View Components using the sidecar setup, where you end up with this:
Is there a way for the |
When using relative keys in controllers and mailers, it usually makes sense to assume the name of the method (such as "index" or "new") should be part of the absolute key, since they generally follow the "one method == one action" pattern and there's a view file associated with this method/action.
However, in other classes, like presenters, decorators, components, or any other plain old Ruby object, that isn't usually the case. For instance, in components the view file is associated with the whole Ruby class and not just one method.
So now the calling method is only included as part of the key in classes where it's determined the key should be relative to the method.
Closes #375.
P.S. It's the first time I check the code of this project and I basically don't know what I'm doing 😄, so any help/advice is appreciated. Particularly about how to properly use the
key_relative_to_method?
method (if at all).