Skip to content Skip to sidebar Skip to footer

Translate Custom Attributes With I18next (placeholder, Value)

I am investigating what is possible with i18next localization library. Right now I have the following code (full Fiddle is here): HTML
<

Solution 1:

After asking i18next creator this question directly, I received the following reply: all I need is to put my custom attribute in front of the translation element. Here is an example:

<divdata-i18n="[title]titleTransl"></div><inputdata-i18n="[placeholder]placeTransl"value="name">

If multiple attributes are needed, separate them by a ;.

I learned 2 things by this:

  • I have to read better documentation.
  • 118next's creator is really helpful (this is a thank you remark for him).

Solution 2:

For me the following worked

<input data-i18n="[placeholder]placeTransl" value="name">

So just enter the attribute's name between [] and then the translation.

Solution 3:

Consider calling

$('body').i18n()

inside .done() function. You should tell where to look for localizer. This will work without having to call [placeholders] in the data-i18n attribute.

Post a Comment for "Translate Custom Attributes With I18next (placeholder, Value)"