When message/label is translated and written directly to the HTML tag, switching to other language will not re-translate such HTML tag.
-
Execute the following JavaScript to put English message.
$('dispMsg').html(i18next.t("msg.error.fileNotFound");
-
Result.
<div id="dispMsg">File not found.</div>
-
Change to Japanese.
i18next.changeLanguage("ja"); $('[data-i18n]').localize(); // need jQuery-i18next
-
Result (not translated).
<div id="dispMsg">File not found.</div>
-
Execute the following JavaScript to put English message into the div's attribute.
$('#dispMsg').attr("data-i18n", "msg.error.fileNotFound") .localize();
-
Result.
<div id="dispMsg" data-i18n="msg.error.fileNotFound">File not found.</div>
-
Change to Japanese.
i18next.changeLanguage("ja"); $('[data-i18n]').localize();
-
Result (translated).
<div id="dispMsg" data-i18n="msg.error.fileNotFound">ファイルがないです。</div>