var dict = {
"configMigratedTo": {
"message": "Migrated configuration to configurator: $1"
}
}
var parametersForTranslation = {};
function __tr(src, params) {
parametersForTranslation[src] = params;
return buildMessage(src);
}
function buildMessage(src){
var message=dict[src] ? dict[src].message : src
console.log(message);
var messageArray = message.split("$");
var output = "";
messageArray.forEach(function(elem, index){
if(index === 0){
output += elem;
}else{
// get variable and index
var paramIndex = configMigratedTo.substring(0, 1);
var paramValue = parametersForTranslation[src][paramIndex-1];
output += paramValue;
output += configMigratedTo.substring(1);
}
});
return output;
}
__tr("configMigratedTo", [2]);
console.log(buildMessage("configMigratedTo"));
i want get result like __tr("configMigratedTo", [2]); then it will give me
Migrated configuration to configurator: 2
i do not know where is wrong in my code
__tr()?configMigratedToin thedictobject. It should be something like :dict.configMigratedTo.messageto get the valueMigrated configuration to configurator: $1... Now I really don't know if the $1 will taken in account as a variable... That depends on thebuildMessage()function And I can't tell just like this.configMigratedTovar and the existing property on thedictobject?