iGEL / it

A helper for links and other html tags in your translations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with MissingInterpolationArgument exception

karolsluszniak opened this issue · comments

it gem seems to expect that I18n just ignores missing interpolations and returns uninterpolated but translated string. Then, it interpolates everything on its own. This hovewer fails with recent i18n (0.7.0) which by default raises the MissingInterpolationArgument exception on every missing interpolation that matches traditional interpolation regex (like %{email}). It only happens in the helper version of t and as a result it only happens in helper version of it which calls t helper. Using I18n.it allows to bypass this problem.

In my case, fixing the it helper was possible by adding the following into app initializer:

I18n.config.missing_interpolation_argument_handler = Proc.new do |key|
  "%{#{key}}"
end

But it's not always a good solution. I think it should handle this internally as it's a matter of communication between it and I18n.

Sorry, I can't reproduce this error. The view helper of it works fine in my Rails 4.1.9 app with I18n 0.7.0 on Ruby 2.2.2, also with traditional interpolations. The missing_interpolation_argument_handler is raising an exception when I explicitly call it, so I haven't changed anything there - but using it it isn't triggered. Also all specs are green.

I would be happy if you're able to investigate this issue further. I reopen the issue then.

I was getting MissingInterpolationArgument exceptions too, using it 0.8.0, i18n 0.7.0 and rails 3.2.22.

Things worked again when I used It.it instead of it in my views. Although using It.it requires you to specify the full key (e.g. projects.show.title instead of .title in app/views/projects/show.html.erb).

Hi @airblade! Thanks for the report. Again I tried to reproduce it, but failed (see here). All works as expected.

Could you provide me with an example that demonstrates the bug? Can be a fork of that repo or your own stuff. If you don't want to post it publicly, you can also send it via email to igel@igels.net.