/* ============================================================================= * M01_MasterData_UI_Logic_Text.ts * 로직 화면 글자 — [한국어, 영어] · 공용 사전과 같은 모양 · 창끼리 공용 사전 줄이 겹치지 않게 따로 둠 * ========================================================================== */ import { currentLanguageIndex } from "@ui/ui_template_locale"; const TEXT = { Title: ["단가산출 기초", "Unit-price logic"], List_Search: ["이름 · 별칭 찾기", "Search name or alias"], List_Alias: ["별칭 — 쉼표로 여럿 · 고친 뒤 [저장]", "Aliases — comma separated · then [Save]"], List_Blocked: ["막힘", "Blocked"], List_Edited: ["고침", "Edited"], List_New: ["새것", "New"], List_Deleted: ["지움", "Deleted"], List_Fold: ["{n} 줄 펼침 — 같은 절 · 작업량", "Show {n} more — same section · output"], List_Unfold: ["접기", "Fold"], List_Related: ["관련", "Related"], List_RelatedTip: [ "비고가 가리키는 로직 — 계산 밖 · 누르면 열림", "Logic named in the note — not in the calc · click to open", ], Bar_Back: ["← 로직 목록", "← Logics"], Bar_Delete: ["로직 삭제", "Delete logic"], Bar_Save: ["저장", "Save"], Bar_Discard: ["되돌림", "Revert"], Bar_Pending: ["저장 안 한 로직 {n} 개", "{n} unsaved logics"], Head_File: ["파일", "File"], Head_Key: ["키", "Key"], Head_Number: ["원문번호", "Source no."], Head_Name: ["이름", "Name"], Head_Unit: ["결과 단위", "Result unit"], Head_Source: ["출처", "Source"], Head_Revision: ["개정", "Revised"], Head_Owner: ["소유", "Owner"], Head_Note: ["비고", "Note"], Head_Blocked: ["막힌 까닭", "Why blocked"], Ho_Title: ["호표", "Unit-cost lines"], Ho_Qty: ["수량", "Qty"], Ho_Amount: ["금액", "Amount"], Middle_Title: ["중간 값", "Intermediate values"], Formula: ["식", "Formula"], Calc_Title: ["시험 계산", "Test calculation"], Calc_Run: ["계산", "Calculate"], Calc_NoInputs: ["받을 값 없음", "No inputs"], Calc_Draft: ["고친 줄로 계산(저장 전)", "Using unsaved edits"], Calc_Stopped: ["멈춤", "Stopped"], Calc_Result: ["결과", "Result"], Calc_Sum: ["계", "Total"], Pick_Title: ["요소 찾기", "Find element"], Pick_Search: ["이름·키·원문번호", "Name · key · source no."], Pick_Item: ["품목 고르기", "Pick item"], Pick_Machine: ["기계 고르기", "Pick machine"], Calc_UnitWarn: ["단위 다름", "Unit differs"], Pick_Close: ["닫기", "Close"], Mat_NoPrice: ["단가 없음", "No price"], Save_Done: ["저장했음", "Saved"], Save_Stale: [ "그 사이 파일이 바뀜 — 고친 것을 버리고 다시 여세요: {v}", "Files changed meanwhile — discard and reopen: {v}", ], Save_Errors: ["검사에 걸려 저장 안 함", "Check failed — nothing saved"], Save_Failed: ["저장 못 함", "Save failed"], Save_Nothing: ["고친 것 없음", "Nothing to save"], Load_Failed: ["불러오지 못함", "Load failed"], Lab_Title: ["단가산출 기초", "Unit-price logic"], Loading: ["불러오는 중", "Loading"], Confirm_Delete: [ "로직 「{v}」 을 지울까요? 로직 · 수식이 서버에서 바로 지워짐", "Delete logic “{v}”? Logic and formula are removed on the server now", ], Delete_Done: ["로직 「{v}」 지움", "Deleted logic “{v}”"], Delete_Used: ["부르는 곳이 있어 못 지움", "In use — not deleted"], Confirm_Discard: [ "저장 안 한 고친 것(기본정보 · 수식)을 버리고 저장 뒤 상태로 되돌릴까요?", "Discard unsaved edits (info · formula) and revert to the saved state?", ], /* ── 멈춘 까닭을 설계자 말로 ── */ Stop_Missing: [ "「{name}」 값을 아직 안 넣었습니다 — 값을 넣으면 계산됩니다", "「{name}」 is empty — enter it to calculate", ], Stop_NoRow: [ "넣은 값에 맞는 표 줄이 없습니다 — 값을 바꿔 보세요", "No table row fits these values — try other values", ], Stop_Spec: [ "「{name}」 규격이 여럿이라 정하지 못함 — 위 「쓰이는 재료·기계」에서 하나를 골라 주세요", "「{name}」 has several specs — pick one in the materials list above", ], Stop_Generic: [ "이 조건으로는 셈하지 못함 — 입력값 · 표에 그 조합이 있는지 확인", "Cannot be calculated with these inputs — check the values and the table", ], Stop_NoPrice: [ "「{name}」 단가가 자료에 비어 있어 셈하지 못함 — 자료를 채워야 함", "「{name}」 has no price in the data yet", ], } as const satisfies Record; export type TextKey = keyof typeof TEXT; /** 엔진이 멈춘 까닭을 설계자 말로 — 모르는 글은 그대로 */ export function plainReason(reason: string): string { const missing = /입력 「([^」]+)」 없음/.exec(reason); if (missing) return tx("Stop_Missing", { name: missing[1] }); if (/맞는 줄 0개/.test(reason)) return tx("Stop_NoRow"); const spec = /「([^」]+)」 후보 여럿/.exec(reason); if (spec) return tx("Stop_Spec", { name: spec[1] }); const noPrice = /「([^」]+)」 값 없음/.exec(reason); if (noPrice) return tx("Stop_NoPrice", { name: noPrice[1] }); return reason; } /** 화면에 찍는 까닭의 마지막 방어 — 중괄호 · 따옴표 · Decimal( 이 섞인 날글은 사람 말 한 줄로 */ export function safeReason(reason: string): string { const plain = plainReason(reason); return /[{}"']|Decimal\(/.test(plain) ? tx("Stop_Generic") : plain; } /** 공용 `t()` 와 같은 뜻 — `{n}`·`{v}` 는 채움 */ export function tx(key: TextKey, fill: Record = {}): string { const entry = TEXT[key]; const text: string = entry[currentLanguageIndex as 0 | 1] ?? entry[0]; return text.replace(/\{(\w+)\}/g, (m, k: string) => (k in fill ? String(fill[k]) : m)); }