Skip to content
Advertisement

HTML tags in i18next translation

I’m using i18next to power i18n for my weblog. It works great on text-only content, but when I try to translate content that includes HTML markup, it is displaying the raw markup when I translate the text.

As an example, here is a snippet of the markup from a post that is not working as expected:

JavaScript

The translation code looks like this:

JavaScript

When the translation is rendered, HTML tags are escaped and output as text:

JavaScript

How do I get i18next to change the HTML of translated elements?

Advertisement

Answer

In order to make this work, you have to prefix the data-i18n attribute of the elements you want to translate with [html]:

JavaScript

Source: i18next.jquery.js

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement