1

I have a block of text I'd like to make translatable. Within that block of text there is a link.

The following works:

{{ "Lorem ipsum. <a href='{url}' target='_blank'>Aenean commodo ligula</a> eget dolor."|t({
    url: "#"
})|raw }}

But doesn't feel like the best way to do it as the translation file now requires HTML:

craft/translations/en_us.php

<?php

return array(
    "Lorem ipsum. <a href='{url}' target='_blank'>Aenean commodo ligula</a> eget dolor." => "Lorem ipsum. <a href='{url}' target='_blank'>Aenean commodo ligula</a> eget dolor."
);

Are there any other ways to do this that lead to a better separation of translatable text and HTML that relates to how the translator can interact with that text?

  • If you find a better way, let us know. That's how we do it in the handful of places strings that need translating that have markup in them. – Brad Bell Sep 1 '16 at 3:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.