HTML tags in i18next translation
08:48 16 Apr 2013

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:

In Medellín they have many different types of jugos naturales (fruit juice) ...

...

The translation code looks like this:

var resources = {
  "en": ...,
  "es": {
    "translation": {
      "content": {
        "body": "En Medellín hay varios tipos diferentes de jugos naturales ... 

... " } } } } i18n.init({"resStore": resources}, function( t ) { $('.i18n').i18n(); });

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

En Medellín hay varios tipos diferentes de <i>jugos naturales</i>...<br /><br />

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

javascript internationalization i18next