mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
Added parameters to parseTranslation
This commit is contained in:
parent
b48ad91dfe
commit
01b63b356c
@ -27,7 +27,7 @@
|
|||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.parseTranslation = function parseTranslation(message){
|
scope.parseTranslation = function parseTranslation(message, parameters = {}){
|
||||||
const container = document.createDocumentFragment();
|
const container = document.createDocumentFragment();
|
||||||
|
|
||||||
message.split(/(\{[^}]+\})/).forEach(function(part){
|
message.split(/(\{[^}]+\})/).forEach(function(part){
|
||||||
@ -50,6 +50,19 @@
|
|||||||
container.appendChild(link);
|
container.appendChild(link);
|
||||||
break;
|
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 {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user