Interpolation in translations doesn't work with Ruby 3 and I18n 1.6.0
kotovalexarian opened this issue · comments
I've upgraded Middleman from 4.3.11 to 4.4.0. I18n was upgraded from 0.9.5 to 1.6.0. String interpolation in translations stopped working after that.
Let's say I have a translation Page_N: "Page %{number}"
. I call it in ERB templates with <%= t(:Page_N, number: 123) %>
. I expect to see Page 123
in generated HTML, but instead I see Page %{number}
.
Remember that in Ruby 3 positional and keyword arguments are completely separated. I've solved the problem by adding custom helper:
def t(*args, **kwargs)
I18n.t(*args, **kwargs)
end
I can't submit a pull request because I'm not sure how to deal with both Ruby 2.5 and Ruby 3. The declaration of #t
is here.
Thanks @kotovalexarian. Can you share an example erb snippet that I could use to build a test case?
Thanks @kotovalexarian. Can you share an example erb snippet that I could use to build a test case?
Let me better submit a pull request. I have an idea about how to deal with both Ruby 2.5 and 3. I can just check RUBY_VERSION
constant and conditionally create helper method.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
It still requires a patch. I'll try to send one as soon as possible.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I really have to do it...