fix: remove excess line breaks
This commit is contained in:
@@ -439,6 +439,7 @@ export class Translator {
|
||||
let q = el.innerText.trim();
|
||||
this._tranNodes.set(el, q);
|
||||
const keeps = [];
|
||||
console.log("q", q);
|
||||
|
||||
// 保留元素
|
||||
const [matchSelector, subSelector] = this._keepSelector;
|
||||
@@ -462,9 +463,15 @@ export class Translator {
|
||||
});
|
||||
|
||||
if (keeps.length > 0) {
|
||||
q = text;
|
||||
// textContent会保留些无用的换行符,严重影响翻译质量
|
||||
if (q.includes("\n")) {
|
||||
q = text;
|
||||
} else {
|
||||
q = text.replaceAll("\n", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log("q2", q);
|
||||
|
||||
// 太长或太短
|
||||
if (this._invalidLength(q.replace(/\[(\d+)\]/g, "").trim())) {
|
||||
|
||||
Reference in New Issue
Block a user