How to test that all rails translations calls pass all interpolation keys?
I'd like to verify that all translation calls in my app pass the proper interpolation arguments. However, when no argument is passed, there is no exception raised.
Per Rails i18n documentation http://guides.rubyonrails.org/i18n.html
"If a translation expects an interpolation variable but it has not been passed to #translate an I18n::MissingInterpolationArgument exception is raised."
However, this doesnt seem to be the case if NO interpolation variables are passed. For instance, this code doesn't raise an exception:
require 'i18n'
I18n.backend.store_translations :en, :thanks => 'Thanks %{name}! '
I18n.translate :thanks # <- expect an exception, but it just returns 'Thanks %{name}!'
I18n.translate :thanks, :foo => 'bar' # <- this raises
Anyone know of a way to detect calls that are missing translation keys during the tests other than parsing for "开发者_Go百科%{" ?
This looks like a rail bug to me. Why don't you try patching it?
精彩评论