开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜