feat: improve CUPS Chinese localization

This commit is contained in:
2026-06-09 16:47:29 +08:00
parent 87b3129374
commit 46e8cf397c
4 changed files with 227 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html>
<html lang="zh-CN">
<head>
<link rel="stylesheet" href="/cups.css" type="text/css">
<link rel="shortcut icon" href="/apple-touch-icon.png" type="image/png">

View File

@@ -1,5 +1,229 @@
</div>
</div>
<script type="text/javascript"><!--
(function () {
var exact = {
"Administration": "管理",
"Home": "首页",
"Jobs": "任务",
"Printers": "打印机",
"Classes": "打印机类",
"Help": "帮助",
"Search": "搜索",
"Clear": "清除",
"Default": "默认",
"Printer Default": "打印机默认",
"None": "无",
"No": "否",
"Yes": "是",
"Off": "关闭",
"On": "开启",
"True": "是",
"False": "否",
"Auto": "自动",
"Automatic": "自动",
"Manual": "手动",
"Idle": "空闲",
"Processing": "处理中",
"Stopped": "已停止",
"Paused": "已暂停",
"Unknown": "未知",
"Ready": "就绪",
"Completed": "已完成",
"Current": "当前",
"General": "常规",
"Basic": "基本",
"Advanced": "高级",
"Printer Features": "打印机功能",
"Installable Options": "可安装选项",
"Job Options": "任务选项",
"Page Setup": "页面设置",
"Media": "纸张",
"Paper": "纸张",
"Finishing": "后处理",
"Output": "输出",
"Color": "彩色",
"Grayscale": "灰度",
"Monochrome": "单色",
"Black": "黑色",
"Black and White": "黑白",
"Normal": "普通",
"Draft": "草稿",
"High": "高",
"Best": "最佳",
"Fast": "快速",
"Photo": "照片",
"Text": "文本",
"Graphics": "图形",
"Line Art": "线条图",
"Portrait": "纵向",
"Landscape": "横向",
"Reverse Portrait": "反向纵向",
"Reverse Landscape": "反向横向",
"Plain": "普通",
"Plain Paper": "普通纸",
"Envelope": "信封",
"Labels": "标签纸",
"Transparency": "透明胶片",
"Recycled": "再生纸",
"Heavy": "重磅纸",
"Thick": "厚纸",
"Thin": "薄纸",
"Long Edge": "长边",
"Short Edge": "短边",
"Long-Edge Binding": "长边装订",
"Short-Edge Binding": "短边装订",
"One-Sided": "单面",
"Two-Sided": "双面",
"No Cover": "无封面",
"Classified": "机密",
"Confidential": "保密",
"Secret": "秘密",
"Standard": "标准",
"Top Secret": "绝密",
"Unclassified": "非密",
"Tray 1": "纸盒 1",
"Tray 2": "纸盒 2",
"Tray 3": "纸盒 3",
"Tray 4": "纸盒 4",
"Manual Feed": "手动进纸",
"Multi-Purpose Tray": "多功能纸盒",
"Upper": "上纸盒",
"Lower": "下纸盒",
"Middle": "中纸盒",
"Letter": "Letter 信纸",
"Legal": "Legal 法律纸",
"Executive": "Executive 行政纸"
};
var phrases = [
["Media Size", "纸张尺寸"],
["Page Size", "页面尺寸"],
["Paper Size", "纸张尺寸"],
["Media Type", "纸张类型"],
["Paper Type", "纸张类型"],
["Input Slot", "进纸来源"],
["Paper Source", "纸张来源"],
["Media Source", "纸张来源"],
["Output Bin", "出纸槽"],
["Output Tray", "出纸托盘"],
["Duplex Printing", "双面打印"],
["Two-Sided Printing", "双面打印"],
["2-Sided Printing", "双面打印"],
["Double-Sided Printing", "双面打印"],
["Print Quality", "打印质量"],
["Printout Mode", "打印模式"],
["Output Mode", "输出模式"],
["Color Mode", "色彩模式"],
["Color Model", "色彩模型"],
["Color Correction", "色彩校正"],
["Color Management", "色彩管理"],
["Resolution", "分辨率"],
["Copies", "份数"],
["Collate", "逐份打印"],
["Orientation", "方向"],
["Scaling", "缩放"],
["Fit to Page", "适合页面"],
["Page Region", "页面区域"],
["Page Border", "页面边框"],
["Page Order", "页面顺序"],
["Mirror Print", "镜像打印"],
["Toner Save", "省粉模式"],
["Ink/Toner Save", "省墨/省粉模式"],
["Economy Mode", "经济模式"],
["Draft Mode", "草稿模式"],
["Print Density", "打印浓度"],
["Density", "浓度"],
["Darkness", "深浅"],
["Brightness", "亮度"],
["Contrast", "对比度"],
["Saturation", "饱和度"],
["Gamma", "伽马"],
["Halftoning", "半色调"],
["Image Quality", "图像质量"],
["Installed Memory", "已安装内存"],
["Optional Tray", "可选纸盒"],
["Long-Edge", "长边"],
["Short-Edge", "短边"],
["one-sided", "单面"],
["two-sided-long-edge", "双面(长边翻转)"],
["two-sided-short-edge", "双面(短边翻转)"],
["job-sheets", "作业封面"],
["media", "纸张"],
["sides", "双面设置"]
];
function trimText(text) {
return text.replace(/^\s+|\s+$/g, "");
}
function localizeText(text) {
var core = trimText(text);
var localized = core;
var i;
if (!core) {
return text;
}
if (exact[core]) {
localized = exact[core];
} else {
for (i = 0; i < phrases.length; i++) {
localized = localized.split(phrases[i][0]).join(phrases[i][1]);
}
}
if (localized === core) {
return text;
}
return text.replace(core, localized);
}
function localizeNodeText(root) {
var skip = {SCRIPT: true, STYLE: true, TEXTAREA: true, PRE: true, CODE: true};
var walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
acceptNode: function (node) {
if (!node.nodeValue || !trimText(node.nodeValue)) {
return NodeFilter.FILTER_REJECT;
}
if (node.parentNode && skip[node.parentNode.nodeName]) {
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
}
});
var nodes = [];
var node;
while ((node = walker.nextNode())) {
nodes.push(node);
}
for (var i = 0; i < nodes.length; i++) {
nodes[i].nodeValue = localizeText(nodes[i].nodeValue);
}
}
function localizeControls(root) {
var options = root.querySelectorAll("option");
var inputs = root.querySelectorAll("input[type=submit], input[type=button], input[type=reset], button");
var i;
for (i = 0; i < options.length; i++) {
options[i].text = localizeText(options[i].text);
}
for (i = 0; i < inputs.length; i++) {
if (inputs[i].value) {
inputs[i].value = trimText(localizeText(inputs[i].value));
}
}
}
localizeNodeText(document.body);
localizeControls(document);
document.title = localizeText(document.title);
})();
//--></script>
<div class="footer">CUPS 和 CUPS 标志是 <a href="http://www.apple.com">Apple Inc.</a> 的商标 | 中文汉化版</div>
</body>
</html>