I have an object like this:
myDataObject = {
name : 'Nikola Tesla',
birth : ['10 July 1856','10. Juli 1856'],
nation : ['Serbian','Serbisch'],
knownFor : ['Alternating current',' Zweiphasenwechselstrom']
}
And two string patterns like these:
var englishStr = '#name#, born #birth[1]# , #nation[1]# best known for his contributions to #knownFor[1]#';
var deutschStr = '#name#, geboren #birth[2]#, #nation[2]# Erfinder, der für seine Beiträge zur #knownFor[2]# bekannt';
Now I want to replace #properties#in this way.
I could do it easily if there weren’t a multilingual indicator like [1] or [2]. similar to this:
$.each(myDataObject , function(n, v){
englishStr = englishStr.replace('#'+ n +'#' , v )
});
So what can I do with #prop[i]#? Thanks you
source
share