Merge pull request #27278 from shariquerik/translate-header-block
fix: header block is not translatable
This commit is contained in:
commit
60cfeb0dee
1 changed files with 9 additions and 1 deletions
|
|
@ -104,8 +104,16 @@ export default class Header extends Block {
|
|||
this._data = this.normalizeData(data);
|
||||
|
||||
if (data.text !== undefined) {
|
||||
let text = this._data.text || "";
|
||||
let text = __(this._data.text) || "";
|
||||
const contains_html_tag = /<[a-z][\s\S]*>/i.test(text);
|
||||
|
||||
// apply translation to header text
|
||||
let div = document.createElement("div");
|
||||
div.innerHTML = text;
|
||||
let only_text = div.innerText;
|
||||
only_text = frappe.utils.escape_html(only_text);
|
||||
text = text.replace(only_text, __(only_text));
|
||||
|
||||
this._element.innerHTML = contains_html_tag
|
||||
? text
|
||||
: `<span class="h${this._settings.default_size}">${text}</span>`;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue