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
Translation not missing if default contains nil #431
Comments
I think it depends on your settings. The exception is only raised if your have [7] pry(main)> I18n.translate(:foo, default: [nil])
=> "translation missing: en.foo"
Can you link to the part of the docs where you read that this should return nil? |
Thanks. The point is not the exception, it is the expectation to get nil rather than an exception, or 'translate missing'. I do want to raise an exception when the translation is missing and I did not supply default:nil
I don't actual remember what I was referring to, and can't find it now... In any case, I think the behaviour I was expecting is more consistent and more useful: The current behaviour is that the function goes through the list of defaults one by one as long as the previous translation was missing. This happens for all values except nil, so I would expect it to happen for nil as well. It is also more useful, since it allows checking if either the translation or the defaults exist, and if not continue in some other manner, rather than raising an exception (of course, there are other means to achieve the same, but less convenient). |
I hit this too. For what it's worth for anyone stumbling on the same problem, I had something like this in a Rails view that I was doing some maintenance on:
With I found the following was though:
|
The way I read the docs, calling
Should return
nil
rather than raise an exception (when:foo
does not exist). However, this is not what happens in the code (or in real life).The text was updated successfully, but these errors were encountered: