package xlsxtranslate import "strings" // glossary holds the mandatory translation pairs. Values here were harvested // from the shipped bilingual SIP workbook (D4-A08AR12000002-A3), where the // English sheet has been maintained for 11 revisions — they are confirmed // translations, not suggestions. Glossary hits short-circuit the LLM. // // Lookup is exact first, then trimmed, then whitespace-insensitive for short // strings, because layout padding such as "客 戶 " is part of the // stored text but not part of the term. var glossary = map[string]string{ // Company and document identity "苏州和信精密科技有限公司": "WTP TECHNOLOGY (SUZHOU) CO., LTD.", "苏州和信精密科技有限公司 ": "WTP TECHNOLOGY (SUZHOU) CO., LTD.", "组装检验标准": "Assembly Process SIP", "检验标准": "Inspection Standard", "标准": "Standard", "SIP版次:": "SIP REV:", "SIP版次": "SIP REV", "版本": "Version", "版本号": "Version No.", "日期": "Date", "备注": "Comments", "新制定": "First released", "修订页面": "Where", "主要修订内容": "Revised content", "修改人": "Revised", "修订历史": "Revision History", "履历": "History", // Header field labels (traditional variants included on purpose — the // source mixes simplified and traditional forms) "客户": "Customer", "客戶": "Customer", "机种": "Model", "機種": "Model", "序号": "No.", "序號": "No.", "品名": "Part Name", "页次": "Page", "頁次": "Page", "页码": "Page", "制作单位": "Division", "抽样计划": "Sampling Plan", "抽樣計劃": "Sampling Plan", "依MIL-STD-1916表 主抽樣表": "Per MIL-STD-1916 main sampling table", "检验项目": "Inspection Item", "檢驗項目": "Inspection Item", "规格说明": "Specification", "規格說明": "Specification", "检验工具": "Inspection Tools", "檢驗工具": "Inspection Tools", "检验频率": "Inspection Frequency", "檢驗頻率": "Inspection Frequency", "首件": "First Piece", "末件": "Last Piece", "首/末件": "First/Last Piece", "巡检": "Patrol Inspection", "巡檢": "Patrol Inspection", "基本信息": "Basic Information", "结构": "Structure", "結構": "Structure", "尺寸": "Dimensions", "外观": "Appearance", "外觀": "Appearance", "目视": "Visual", "目視": "Visual", "等级": "Class", "等级面划分": "Class surface division", "重点检验": "Key inspections", "重點檢驗": "Key inspections", "检验条件": "Inspection conditions", "檢驗條件": "Inspection conditions", // Common hardware and inspection nouns seen in the drawing text boxes "螺母": "NUT", "螺丝": "SCREW", "螺钉": "SCREW", "螺栓": "BOLT", "万向轮": "Caster", "腳杯": "Leveling Foot", "脚杯": "Leveling Foot", "接地": "Grounding", "接地区域": "Grounding area", "接地螺丝": "Grounding screw", "接地螺絲": "Grounding screw", "支撑件": "Support", "支撐件": "Support", "水平仪": "Spirit level", "钢直尺": "Steel ruler", "鋼直尺": "Steel ruler", "卷尺": "Tape measure", "塞尺": "Feeler gauge", "检具": "Inspection gauge", "檢具": "Inspection gauge", "手电筒": "Flashlight", "手电筒/目视/手触摸": "Flashlight/Visual/Touch by hand", "手触摸": "Touch by hand", "对角线": "Diagonal", "對角線": "Diagonal", "平面度": "Flatness", "平行度": "Parallelism", "底板平面度": "Bottom plate flatness", "顶板平面度": "Top plate flatness", "外宽": "Outer width", "內宽": "Inner width", "内宽": "Inner width", "前门": "Front door", "后门": "Rear door", "前門": "Front door", "後門": "Rear door", "侧板": "Side panel", "側板": "Side panel", "顶板": "Top panel", "底板": "Bottom panel", "立柱": "Vertical post", "螺纹孔": "Threaded hole", "螺紋孔": "Threaded hole", "方孔": "Square hole", "葫芦孔": "Keyhole", "焊道": "Weld bead", "焊点": "Weld point", "铜箔纸": "Copper foil paper", "防烤胶带": "High-temperature tape", "标签": "Label", "標籤": "Label", "SN标签": "SN label", "机柜": "Rack", "機櫃": "Rack", "机柜本体": "Rack body", "包装": "Packing", "出厂检验": "Outgoing inspection", "出货检验": "Outgoing inspection", "组装": "Assembly", "組裝": "Assembly", // Worksheet (sheet tab) names — workbook sheet tabs are renamed too "更改履历": "Revision History", "更改記錄": "Revision History", "前置加工": "Pre-processing", "全检项目": "Full Inspection Items", "全檢項目": "Full Inspection Items", "出货包装": "Outgoing Packaging", "出貨包裝": "Outgoing Packaging", "检验": "Inspection", "檢驗": "Inspection", "检查": "Check", "客诉": "Customer complaint", "客訴": "Customer complaint", "异常": "Abnormal", "異常": "Abnormal", "变形": "Deformation", "变形、刮伤": "Deformation or scratch", "刮伤": "Scratch", "划伤": "Scratch", "生锈": "Rusty", "生鏽": "Rusty", "锈斑": "Rust spot", "毛刺": "Burr", "氧化": "Oxidation", "脏污": "Stain", "人员": "Operator", "部门": "Department", "日期 ": "Date ", "审核": "Reviewed by", "核准": "Approved by", "编制": "Prepared by", "批准": "Approved by", "签名": "Signature", "其他": "Others", "其它": "Others", "左侧": "Left side", "右侧": "Right side", "前面": "Front", "后面": "Rear", "顶部": "Top", "底部": "Bottom", "内部": "Inside", "外部": "Outside", "左侧面": "Left side panel", "右侧面": "Right side panel", "正面": "Front surface", "背面": "Rear surface", "水平距离": "Horizontal distance", "间距": "Distance", "間距": "Distance", "高度": "Height", "宽度": "Width", "厚度": "Thickness", "深度": "Depth", "数量": "Quantity", "位置": "Position", "序号 ": "No. ", "工单": "Work order", "图纸": "Drawing", "图面": "Drawing", "图號": "Drawing No.", "图号": "Drawing No.", "料号": "Part number", "料號": "Part number", "版本进阶": "Version upgrade", "资料": "Document", "資料": "Document", "照片": "Photo", "图片": "Picture", "图片、": "Pictures, ", "说明": "Description", "說明": "Description", "要求": "Requirement", "標準視力": "Standard vision", "视力": "Vision", "目視距離": "Viewing distance", "检验角度": "Inspection angle", "目视时间": "Viewing time", "使用者在正常操作状态下": "in normal operation, the user", "一直会看到的面": "surface that is always visible", "有时会看到的面": "surface that is sometimes visible", "较少会看到的面": "surface that is rarely visible", "不会看到的面": "surface that is never visible", } // glossaryMaxLooseLookup bounds the whitespace-insensitive lookup: stripping // all whitespace is only safe for short label-like strings. const glossaryMaxLooseLookup = 40 // glossaryLooseIndex maps whitespace-stripped keys to values, built once. var glossaryLooseIndex = buildLooseIndex() func buildLooseIndex() map[string]string { idx := make(map[string]string, len(glossary)) for k, v := range glossary { idx[whitespaceKey(k)] = v } return idx } // lookupGlossary resolves s through the glossary: exact match, then trimmed, // then whitespace-insensitive for short label-like strings. Returns "" on miss. func lookupGlossary(s string) string { if v, ok := glossary[s]; ok { return v } trimmed := strings.TrimSpace(s) if trimmed != s { if v, ok := glossary[trimmed]; ok { return v } } if len([]rune(s)) <= glossaryMaxLooseLookup { if v, ok := glossaryLooseIndex[whitespaceKey(s)]; ok { return v } } return "" }