return LuaValue.valueOf(replace(msg, params));
}
private String replace(String msg, LuaTable params) {
for (int i=1; i<params.length()+1; i++) {
LuaValue param = params.get(i);
String actualParam;
if (param.istable()) {
if (!param.get("raw").isnil()) {
actualParam = param.get("raw").checkjstring();
} else if (!param.get("num").isnil()) {
if (param.get("num").isnumber()) {
LuaNumber number = param.get("num").checknumber();
NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag(lang));
actualParam = nf.format(number.todouble());
} else {
actualParam = param.get("num").tojstring();
}
} else {
actualParam = "unknown";
}
} else {
actualParam = param.checkjstring();
}
msg = msg.replace("$"+i, actualParam);
}
return msg;
}