I want to translate from JSON file by html attribute
get JSON value like translate attribute and "ed" key
JSON FILE
{
"open" : [
{
"en": "Open",
"ed": "Opened"
}
],
"close" : [
{
"en": "Close",
"ed": "Closed"
}
]
}
HTML
<p translate="open"></p>
JQuery
var word = $("p");
var wordA = $("p").attr("translate"); // open
$.getJSON('language.json', function(data) {
$.each(data, function(key, val) {
if (key === wordA) {
word.html(val.ed);
// result opened
}
});
});