Skip to content
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

Problem with MissingInterpolationArgument exception #13

Closed
karolsluszniak opened this issue Mar 5, 2015 · 3 comments
Closed

Problem with MissingInterpolationArgument exception #13

karolsluszniak opened this issue Mar 5, 2015 · 3 comments

Comments

@karolsluszniak
Copy link

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.

@iGEL
Copy link
Owner

iGEL commented Jun 15, 2015

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.

@iGEL iGEL closed this as completed Jun 15, 2015
@airblade
Copy link

airblade commented Dec 1, 2015

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).

@iGEL
Copy link
Owner

iGEL commented Dec 18, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants