-
Notifications
You must be signed in to change notification settings - Fork 264
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
Feature: Support short hand in more Rails controller methods (private methods, before_actions) #540
Comments
Yeah, this is a limitation to the implementation today. It is quite hard to figure out what value we should translate it to, since it can be:
and the last two might have different values. |
According to rails code, the key is always scoped to If I understand the above correctly, this relative key is actually 2 keys:
Detecting this automatically would be quite tricky (we'd need to parse method calls, Perhaps one way to handle this would be to require |
I ran into this as well, but my use case doesn't have a def destroy
...
destroy_step(step, campaign)
end
private
def destroy_step(step, campaign)
...
flash[:success] = t('.success')
end This seems like maybe a case that is a little more clear for |
Yeah, but we have to create a custom matcher that knows it is in a controller. I will try to look at this during my spare time |
@davidwessman does the shorthand work in places where it wouldn't be treated this way? I haven't tested mailers, but I assume they would behave the same way. |
The logic for the shorthand is quite limited, I spent some time trying to write something different and I have a working PoC.
Instead we need to combine 1 and 2 while parsing, so we know what we are looking for, and then we need to have different parser rules for a controller, a mailer and for views. Might have some more time to work on it during this month. |
Any progress on this or recommended workarounds? |
No, lately I have been thinking if this is something that would fit better in e.g. rails-lsp and then maybe i18n-tasks could integrate with it. The only workaround is magic comments :/ |
Is there a magic comment to ignore a missing translation. I couldn't figure that out so I have to add the key it's looking for in the |
Unfortunately not, then you need to add it to the |
I encountered this problem in rails.
I have a controller with a before action:
in my en.yml:
This works in the application but when I run the check it says I have a missing translation for:
and says I have an unused key:
if I change the yml to:
it passes the check but it fails when I try to load the page saying there is no translation found for the given key.
the workaround is to just give the full path for the translation.
Not sure if this is expected behavior or a bug so I figured I'd open an issue. Thanks!
The text was updated successfully, but these errors were encountered: