Quick rundown: We're working on translating our site. We have a some partial view macro files that need to be translated and can't really be moved into the Content section. So the only other way I know how to get them translated is to use the dictionary.
Problem: Some of the text in these macro files are strings that include HTML tags, something similar to: "{a href='/info'}Click here{/a} for more information" (curly brackets used instead of <> so that you actually see the HTML tag here). But the html in the dictionary apparently just gets rendered as text. I'd really rather not have 2 separate dictionary items for cases like this. Is there someway to do this? A better/different way?
If it´s a link to an internal page, you can use the @Html.Raw method. Then you code should look like this, where you want to output the value of the dictionary item.
Thanks Dennis! That's exactly what I was looking for.
Out of curiosity, you said "If it´s a link to an internal page...", yet @Html.Raw seems to work even if the link is external. Any reason for your "if"?
HTML tags in dictionary?
Quick rundown: We're working on translating our site. We have a some partial view macro files that need to be translated and can't really be moved into the Content section. So the only other way I know how to get them translated is to use the dictionary.
Problem: Some of the text in these macro files are strings that include HTML tags, something similar to: "{a href='/info'}Click here{/a} for more information" (curly brackets used instead of <> so that you actually see the HTML tag here). But the html in the dictionary apparently just gets rendered as text. I'd really rather not have 2 separate dictionary items for cases like this. Is there someway to do this? A better/different way?
Hi Kurt,
If it´s a link to an internal page, you can use the @Html.Raw method. Then you code should look like this, where you want to output the value of the dictionary item.
Remember to change the "DictionaryItemKey" so it match your key for your dictionary item.
You can see and read more about the Html.Raw method here https://umbraco.tv/videos/implementor/working-with-umbraco-data/razor-syntax/htmlraw/
Hope this helps,
/Dennis
Thanks Dennis! That's exactly what I was looking for.
Out of curiosity, you said "If it´s a link to an internal page...", yet @Html.Raw seems to work even if the link is external. Any reason for your "if"?
Hi Kurt,
I just tested it very quickly on an external link, and it´s seems not working for me, but if it works for you then it´s great.
I am happy that I could help you resolve the case you have.
/Dennis
is working on a reply...