From 698f3262f0dbf5e103b82842fa395213a9b61943 Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Tue, 9 Jun 2026 17:01:06 +0800 Subject: [PATCH] fix: limit CUPS localization scope --- cups-templates-zh_CN/trailer.tmpl | 33 ++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/cups-templates-zh_CN/trailer.tmpl b/cups-templates-zh_CN/trailer.tmpl index 8bba555..a5effc4 100644 --- a/cups-templates-zh_CN/trailer.tmpl +++ b/cups-templates-zh_CN/trailer.tmpl @@ -205,13 +205,21 @@ } function localizeControls(root) { - var options = root.querySelectorAll("option"); + var selects = root.querySelectorAll("select"); var inputs = root.querySelectorAll("input[type=submit], input[type=button], input[type=reset], button"); var i; + var j; + var select; - for (i = 0; i < options.length; i++) { - options[i].text = localizeText(options[i].text); + for (i = 0; i < selects.length; i++) { + select = selects[i]; + if ((select.id && select.id.indexOf("select-") === 0) || select.name === "OP") { + for (j = 0; j < select.options.length; j++) { + select.options[j].text = localizeText(select.options[j].text); + } + } } + for (i = 0; i < inputs.length; i++) { if (inputs[i].value) { inputs[i].value = trimText(localizeText(inputs[i].value)); @@ -219,9 +227,24 @@ } } - localizeNodeText(document.body); + function localizeSafeTextBlocks(root) { + var blocks = root.querySelectorAll("h1, h2, h3, th, .title, .header a, .tabs label"); + var cells = root.querySelectorAll("td"); + var i; + + for (i = 0; i < blocks.length; i++) { + localizeNodeText(blocks[i]); + } + + for (i = 0; i < cells.length; i++) { + if (/^\s*(job-sheets|media|sides)=/.test(cells[i].textContent || "")) { + localizeNodeText(cells[i]); + } + } + } + + localizeSafeTextBlocks(document); localizeControls(document); - document.title = localizeText(document.title); })(); //-->