Mehmet Yener YILMAZ
Mehmet Yener YILMAZ

Reputation: 25

jquery using i18n values programmatically

I have i18 file for multilanguage, I can use i18 variables inside html elements thats fine
<p hidden id="pcheckinfo" data-i18n="messages.mymessage"></p> for constant i18 values.

But after some interaction by user activities, I need to edit text inside this element...

For expample:

var checkDate = new Date();
    $("#pcheckinfo").hide().empty().append("<i class='ace-icon fa fa-info'></i> There is new updates you can install. Date: " + checkDate).show(500);

Is there way doing like this:

$("#pcheckinfo").hide().empty().append("<i class='ace-icon fa fa-info'></i> 
[html]messages.randommessage" + checkDate).show(500);

What do you suggest ? (ver: i18next-1.11.1.js)

Upvotes: 2

Views: 355

Answers (1)

Lotus91
Lotus91

Reputation: 1125

You can try something like this; add a span with the tag data-i18n="key" of the value you want to be showed.

$("#pcheckinfo").hide().empty().append("<i class='ace-icon fa fa-info'></i><span data-i18n='messages.randommessage'></span>" + checkDate).show(500);

Upvotes: 1

Related Questions