noLang only affects options, label, statustext, placeholder, emptyLabel get always translated

This commit is contained in:
ralf 2022-07-26 15:46:42 +02:00
parent aa80b4027a
commit dee28cb53f
3 changed files with 19 additions and 6 deletions

View File

@ -128,6 +128,19 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
}
}
/**
* List of properties that get translated
*
* @returns object
*/
static get translate()
{
return {
...super.translate,
emptyLabel: true
}
}
get slots()
{
return {
@ -332,7 +345,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
return html``;
}
return html`
<sl-menu-item value="">${this.egw().lang(this.emptyLabel)}</sl-menu-item>`;
<sl-menu-item value="">${this.emptyLabel}</sl-menu-item>`;
}
/**

View File

@ -195,7 +195,7 @@ export const Et2widgetWithSelectMixin = <T extends Constructor<LitElement>>(supe
*/
_emptyLabelTemplate() : TemplateResult
{
return html`${this.emptyLabel ? this.egw().lang(this.emptyLabel) : ''}`;
return html`${this.emptyLabel}`;
}
/**

View File

@ -1413,15 +1413,15 @@ function transformAttributes(widget, mgr : et2_arrayMgr, attributes)
break;
default:
attrValue = mgr ? mgr.expandName("" + attrValue) : attrValue;
if(attrValue && typeof attrValue == "string" && !attributes.noLang && widget_class.translate[attribute])
if(attrValue && typeof attrValue == "string" && 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)
attrValue = attrValue.replace(/{([^}]+)}/g, (str, p1) =>
{
return this.egw().lang(p1);
}.bind(widget));
return widget.egw().lang(p1);
});
}
else
{