mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Added parameters to parseTranslation
This commit is contained in:
parent
b48ad91dfe
commit
01b63b356c
@ -27,7 +27,7 @@
|
||||
return id;
|
||||
};
|
||||
|
||||
scope.parseTranslation = function parseTranslation(message){
|
||||
scope.parseTranslation = function parseTranslation(message, parameters = {}){
|
||||
const container = document.createDocumentFragment();
|
||||
|
||||
message.split(/(\{[^}]+\})/).forEach(function(part){
|
||||
@ -50,6 +50,19 @@
|
||||
container.appendChild(link);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (parameters[args[0]]){
|
||||
const parameter = parameters[args[0]];
|
||||
if ((typeof parameter) === "function"){
|
||||
container.appendChild(parameter(args.slice(1).join(":")));
|
||||
}
|
||||
else {
|
||||
container.appendChild(document.createTextNode(parameter));
|
||||
}
|
||||
}
|
||||
else {
|
||||
container.appendChild(document.createTextNode(part));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user