I have this key in my locales.yml
file that uses a link_to
helper.
payment_types:
credit_card: "Requires bank authorization. <%= link_to 'Tutorial', 'www.linktotutorial.com', target: '_blank' %>"
Previously we used an a tag with the href inside along with sanitize, like so:
sanitize(t("payment_types.#{payment_type}"),
tags: %w(a), attributes: %w(target href)), payment_type
But I have to refactor it to use the link_to
helper.
The problem is that sanitize is filtering the erb
tag alltogether (nothing appears past "Requires bank authorization"), and I can't find a way to allow the erb
tag and render the link_to
properly.
Getting rid of sanitize in the other hand, renders the string with the erb
tags included.
Are erb
tags even allowed in yml files?
To parse that ERB tag you can create something like locales.yml.erb
But again there will be too much of hassle to check if Rails is internally parsing ERB yml or not.
And even if it is parsing then will link_to helper will be available or not.
Instead I would suggest a simple way:
Please note
_html
suffix. It is for HTML safe translations.Read more about HTML safe translations here