Api: Attributes can contain multiple translatable substrings wrapped with {}

This commit is contained in:
nathan 2021-12-09 11:32:31 -07:00
parent 081b692dd1
commit 684d0846dc

View File

@ -1108,9 +1108,20 @@ export function loadWebComponent(_nodeName : string, _template_node, parent : Et
default: default:
attrValue = mgr.expandName(attrValue); attrValue = mgr.expandName(attrValue);
if(!_template_node.getAttribute("no_lang") && widget_class.translate[attribute]) if(!_template_node.getAttribute("no_lang") && widget_class.translate[attribute])
{
// allow attribute to contain multiple translated sub-strings eg: {Firstname}.{Lastname}
if(attrValue.indexOf('{') !== -1)
{
attrValue = attrValue.replace(/{([^}]+)}/g, function(str, p1)
{
return this.egw().lang(p1);
}.bind(widget));
}
else
{ {
attrValue = widget.egw().lang(attrValue); attrValue = widget.egw().lang(attrValue);
} }
}
break; break;
} }