Files
2026-11-23 07:24:30 +00:00

448 lines
51 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 語言(中文/English)與幣別(TWD/USD)切換。主看板與 /my 共用。
// - 語言:中文是原始畫面;切成 English 時,這裡把畫面上的中文換成英文(依下面的對照表),
// 姓名顯示「中文+英文」(英文名由 /api/names 提供)。
// - 幣別:金額一律用 PMI18n.cur()/amt()/sym() 顯示;USD 依核心參數的匯率(預設 30)換算。
// - 兩個設定各自存在瀏覽器(pmb-lang、pmb-currency),預設中文、TWD。
(function () {
'use strict';
function read(key) { try { return localStorage.getItem(key); } catch (e) { return null; } }
function write(key, value) { try { localStorage.setItem(key, value); } catch (e) {} }
var lang = read('pmb-lang') === 'en' ? 'en' : 'zh';
var currency = read('pmb-currency') === 'USD' ? 'USD' : 'TWD';
var rate = Number(read('pmb-usd-rate')) > 0 ? Number(read('pmb-usd-rate')) : 30;
document.documentElement.setAttribute('lang', lang === 'en' ? 'en' : 'zh-Hant');
// ---- 金額 ----
function convert(v) { var n = Number(v) || 0; return currency === 'USD' ? n / rate : n; }
function amt(v) { return Math.round(convert(v)).toLocaleString('en-US'); }
function sym() { return currency === 'USD' ? 'US$' : 'NT$'; }
function cur(v) {
if (v === null || v === undefined) return '—';
var n = Math.round(convert(v));
return (n < 0 ? '−' : '') + sym() + ' ' + Math.abs(n).toLocaleString('en-US');
}
// 大數字的簡寫:中文 TWD 用「萬」,其他用 K/M(例如 US$ 1.2M)。
function compact(v) {
var n = Math.abs(convert(v));
if (lang === 'zh' && currency === 'TWD') return Math.round(n / 10000).toLocaleString('en-US') + ' 萬';
if (n >= 1e6) return (n / 1e6).toFixed(n >= 1e8 ? 0 : 1) + 'M';
if (n >= 1e3) return Math.round(n / 1e3).toLocaleString('en-US') + 'K';
return Math.round(n).toLocaleString('en-US');
}
function setRate(value) {
var next = Number(value);
if (!(next > 0)) return false;
var changed = next !== rate;
rate = next;
write('pmb-usd-rate', String(next));
return changed && currency === 'USD';
}
// ---- 中文 → English 對照表 ----
var DICT = {
// 導覽與共用
'LeadBoard · 2027 試算': 'LeadBoard · 2027 Planning', 'LeadBoard': 'LeadBoard', '各部門平均日工作 CODA': 'Avg daily CODA per dept',
'儀表板': 'Dashboard', '年度發票額': 'Annual Invoice', '人員資料': 'Staff', '常態型外包': 'Regular Contractors',
'預排異動': 'Planned Changes', '預計離職': 'Planned Departures', '預計新進': 'Planned Hires',
'預排離職:最後': 'Planned departure: last month', '預排新進:': 'Planned hire: ', '開始': 'start',
'最後工作月份': 'Last working month', '備註': 'Note', '名稱': 'Name', '期間': 'Period',
'預估薪資': 'Est. salary', '+ 加入': '+ Add', '選擇人員…': 'Choose a person…', '選擇部門…': 'Choose a department…',
'等待 HR': 'Waiting for HR', '時間到了 HR 還沒改': 'Past due, HR not updated', '之後自動移除': 'auto-removed after',
'自動移除紀錄': 'Auto-removal log', 'HR 名單上已經沒有這個人': 'No longer in HR', 'HR 已填離職日': 'HR has a leave date',
'HR 名單已出現': 'Now in HR', '時間過了 HR 一直沒改,自動移除': 'Expired — HR never updated', '對到': 'Matched',
'目前沒有預計離職。': 'No planned departures.', '目前沒有預計新進。': 'No planned hires.',
'組織架構': 'Organization', '核心參數': 'Core Parameters', '業務管理': 'Production & Management (P)', '藝術家': 'Artists (A)',
'部門 CODA': 'Department CODA', '組別分析': 'Team Analysis', '模擬試算': 'Simulation', '權限管理': 'Permissions',
'日間': 'Light', '夜間': 'Dark', '配色': 'Theme', '語言': 'Language', '幣別': 'Currency',
'未登入': 'Not signed in', '登出': 'Sign out', '公司帳號登入': 'Sign in with company account',
'同時登出 MoonShine 公司帳號': 'Also signs you out of your MoonShine company account',
'正在從預覽伺服器載入合成資料…': 'Loading synthetic data from the preview server…',
'營運概況': 'Overview', '各部門 發票 vs CODA': 'Invoice vs CODA by Department', '年度發票目標': 'Annual Invoice Target',
'承擔發票': 'Bears Invoice', '其他': 'Other', '人力分佈': 'Headcount Mix', '部門倍率': 'Department Multiplier',
'人薪倍率 × 內部成本 ÷ A 成本': 'Salary Multiplier × Internal Cost ÷ A Cost',
'人員概況': 'People', '查看完整名單': 'View full list', '各部門人力預算佔比': 'Labor Budget Share by Department',
'人員主表 (全部門': 'Staff Table (All Departments', '人員主表': 'Staff Table',
'所有公司': 'All companies', '所有部門': 'All departments', '所有組別': 'All teams',
'顯示薪資': 'Show salaries', '隱藏薪資': 'Hide salaries', '新增內部人員': 'Add internal staff',
'公司': 'Company', '姓名': 'Name', '職稱': 'Title', '部門': 'Department', '組別': 'Team', '職能': 'Function',
'管理職': 'Manager', '月/時薪': 'Monthly / Hourly Pay', '每週天數': 'Days / Week',
'H1 起': 'H1 Start', 'H1 迄': 'H1 End', 'H2 起': 'H2 Start', 'H2 迄': 'H2 End',
'狀態': 'Status', '個人總成本': 'Total Cost per Person', '操作': 'Actions',
'全體 P 系列預算': 'Total P Budget', 'P 年度薪資承擔額(依管理/PC比例)': 'P Annual Salary Share (by Manager / PC ratio)',
'製作部門藝術家成本(含支援分攤)': 'Artist Cost in Production Departments (incl. shared support)',
'調整全公司營運基準、倍率、以及各項自動計算參數。變動將立即影響所有視圖。': 'Company-wide baselines, multipliers and calculation parameters. Changes apply to every view immediately.',
'P 系列預算': 'P Budget',
'藝術家預算 = 各部門最終 CODA。成本=年薪 × 人薪倍率,不除以產出率。': 'Artist budget = each department’s final CODA. Cost = annual salary × salary multiplier, not divided by output rate.',
'全公司總 CODA': 'Company Total CODA',
'選一個部門,試試加人或調薪後實際 CODA、平均日 CODA、定錨 CODA、發票會變多少。只是試算,不會存檔、不影響正式數字。部長們看到的是同一份畫面(/my)。': 'Pick a department and see how Actual CODA, Avg. Daily CODA, Anchored CODA and invoice change if you add people or raise pay. A what-if only: nothing is saved and official numbers are unaffected. Heads of Production see the same screen (/my).',
'公司 → 部門 → 組別。外包依所在部門與組別歸入該部門的公司;沒有部門的人列在各公司的「未歸部門」(不列入部門 CODA)。': 'Company → Department → Team. Contractors follow the company of their department and team; people without a department are listed under “No department” of each company (not counted in department CODA).',
'全部展開': 'Expand all', '全部收合': 'Collapse all', '公司/部門/組別': 'Company / Department / Team',
'人數': 'Headcount', '總成本': 'Total Cost', '佔上一層比例': 'Share of Parent',
'整體 A:P 成本比': 'Overall A:P Cost Ratio', '試算': 'Run', '(vs 正式)': ' (vs official)', 'vs 正式': 'vs official',
'底線發票': 'Break-even Invoice', '夢想創造 CODA(不含研發部)': 'MoonShine Creative CODA (excl. R&D)',
'全企業總成本': 'Total Company Cost', '發票/CODA 覆蓋率': 'Invoice / CODA Coverage', '未對應公司': 'Unmapped company',
'CODA 為 0(只有營運支援或外包,或已分攤至其他部門):': 'CODA is 0 (operations support or contractors only, or allocated to other departments): ',
'全企業不虧本至少要開的發票,不含利潤:全企業總成本': 'Minimum invoice for the company to break even, before profit: total company cost',
'全體正職': 'All full-time staff',
'全公司': 'Whole company', '最高': 'Highest', '差額': 'Difference', '佔比': 'Share', '上半年': 'H1', '下半年': 'H2',
'燈號依四部門 A:P 成本比相對排名:': 'Indicator ranks the four departments by A:P cost ratio: ',
'精實': 'Lean', '接近精實': 'Near lean', '臨近超標': 'Near over', '超標': 'Over', '無 P': 'No P',
'相同': 'same', '位 P': ' P staff', '成本比': 'Cost Ratio',
'定錨後': 'After anchoring', '新進': 'New hire', '離職': 'Left', '調薪/成本變動': 'Pay / cost change', '職能改變': 'Function change',
'調動': 'Transfer', '定錨(': 'Anchor (', ':定錨全年': ': Anchored annual', '定錨全年': 'Anchored annual',
'調動移轉': 'Transfer adjustment', '半年內增加(最高點)': 'Increase this half (peak)', '= 全年': '= Annual', '全年': 'Annual',
'有效比例 (全額承擔': 'Effective ratio (full share', '有效比例 (×': 'Effective ratio (×', 'PC承擔': 'PC share',
'管理職 ×': 'Manager ×', '主管承擔': 'Manager share', '個部門': ' departments', '未指定公司': 'No company', '未歸部門': 'No department',
'年度薪資成本': 'Annual Salary Cost', '成本(× 人薪倍率)': 'Cost (× Salary Multiplier)', '發票總額': 'Total Invoice', '怎麼來': 'How it is calculated',
'內部人力成本': 'Internal labor cost', '÷ 毛利率': '÷ Gross margin', '+ 常態型外包': '+ Regular contractors', '+ 專案委外': '+ Project outsourcing', '+ 員旅': '+ Company trip',
'誰來分:': 'Who shares it: ', '只有「承擔發票」的部門分這筆總額,依下面三個指標的加權比例分配。': 'Only departments that bear invoice share this total, split by the weighted mix of the three indicators below.',
'不計入的單位:': 'Excluded units: ', '不分發票,列出年度薪資成本與成本供參考。角色在「核心參數 › 發票承擔設定」調整。': 'They get no invoice; annual salary cost and cost are shown for reference. Change roles in “Core Parameters › Invoice Roles”.',
'「成本」的意思:': 'What “cost” means: ', '本站的成本=年薪 × 人薪倍率': 'Cost on this site = annual salary × salary multiplier',
';A 再除以產出率': '; A is further divided by output rate', '%。「年度薪資成本」是實際年薪。': '%. “Annual Salary Cost” is the actual annual salary.',
'燈號:': 'Indicator: ', '依四個部門的 A:P 成本比': 'by the A:P cost ratio of the four departments', '相對排名': 'relative ranking',
':最精實的是「精實」、最重的是「超標」,其餘和四部門平均比較,分成「接近精實」和「臨近超標」(橘色表示比其他臨近超標的部門更重)。燈號只是標示,不影響計算。': ': the leanest is “Lean”, the heaviest is “Over”; the rest are compared with the four-department average as “Near lean” or “Near over” (orange = heavier than other “Near over” departments). The indicator is a label only and does not affect calculations.',
'指標3 P 輕重:': 'Indicator 3, P Weight: ',
'P 成本 × (P 成本 ÷ A 成本),A 成本含常態型外包,再換算成四個部門的佔比;A:P 成本比 = A 成本 ÷ P 成本。': 'P cost × (P cost ÷ A cost), with A cost including regular contractors, then converted to a share of the four departments; A:P cost ratio = A cost ÷ P cost.',
'公司/部門/人員': 'Company / Department / Person', '指標1 P佔比': 'Ind. 1 P Share', '權重': 'Weight', '指標2 A佔比': 'Ind. 2 A Share',
'指標3 P 輕重': 'Ind. 3 P Weight', '最終比例': 'Final Share', '責任發票額': 'Invoice Target', '員旅配額': 'Company Trip Quota',
'P 人員承擔比計算說明': 'How P staff invoice share is calculated', '一般 P:有效承擔成本 = 全額薪資成本(×100%)': 'Regular P: effective cost = full salary cost (×100%)',
'P 管理職(isManager):有效承擔成本 ×': 'P manager (isManager): effective cost ×', '(釋出': ' (released ',
'PC(Production Coordinator):有效承擔成本 ×': 'PC (Production Coordinator): effective cost ×',
'各 P 的個人承擔額 = 部門發票目標 × (個人有效成本 / 部門有效P成本合計': 'Each P’s personal share = department invoice target × (personal effective cost / department total effective P cost',
'原始薪資預算總計': 'Total Raw Salary Budget', '全公司 P 總計': 'Company P Total', '全公司 A 總計': 'Company A Total', '全公司 O 總計': 'Company O Total',
'人員 | 佔比': 'Staff | Share', '專案 P': 'Project P', '內製 A': 'In-house A', '外包 O': 'Contractor O', '個部門 · 預設': ' departments · default',
'發票承擔設定': 'Invoice Roles', '承擔發票:計入總額並分配發票': 'Bears invoice: counted in the total and allocated invoice',
'成本分攤:計入總額、不分配': 'Cost sharing: counted in the total, not allocated', '不計入:只看成本 × 人薪倍率': 'Excluded: shown as cost × salary multiplier only',
'承擔發票的部門': 'Departments bearing invoice', '成本分攤': 'Cost sharing', '不計入單位成本': 'Excluded unit cost',
'新部門自動套用所屬公司的預設;部門可以個別改。': 'New departments use their company’s default; each department can be changed individually.',
// 定錨
'定錨': 'Anchor', '定錨資料讀取失敗,請重新整理。': 'Could not load anchor data. Please refresh.',
'H1(1–6 月)': 'H1 (Jan–Jun)', 'H2(7–12 月)': 'H2 (Jul–Dec)', '已定錨': 'anchored', '說明:': 'Note: ',
'尚未定錨。第一次正式定錨:': 'Not anchored yet. First official anchor: ', '年 1 月。': ' January.', '確定': 'OK', '取消': 'Cancel',
'定錨後這半年的發票與定錨 CODA 只增不減,快照不能修改,只能由下一次定錨取代。': 'After anchoring, invoice and Anchored CODA for this half can only increase. The snapshot cannot be edited; only the next anchor replaces it.',
'確認': 'Confirm', '定錨…': 'Anchoring…', '實際 CODA': 'Actual CODA', '定錨 CODA 全年': 'Anchored CODA (Annual)', '發票全年': 'Invoice (Annual)',
'定錨 CODA:各組取半年內的最高點,部門=各組加總;沒有全公司合計(調動時原單位不降、新單位增加,加總會重複)。發票:定錨全年+調動淨額+半年內自身增加的最高點。H1=全年÷2;H2=最新全年−H1 結算。': 'Anchored CODA: each team takes its peak within the half; department = sum of teams. No company total (on transfer, the old unit does not drop and the new unit increases, so a sum would double count). Invoice: anchored annual + net transfers + the department’s own peak increase within the half. H1 = annual ÷ 2; H2 = latest annual − settled H1.',
'調動(定錨後)': 'Transfers (after anchoring)', '從': 'From', '到': 'To', '生效月份': 'Effective month',
'異動清單(與定錨快照比對,': 'Changes (compared with the anchor snapshot, ', '筆)': ' items)', '類型': 'Type', '部門/組': 'Department / Team',
'全年成本增減': 'Annual Cost Change', '發票增減': 'Invoice Change', '定錨後沒有異動。': 'No changes since anchoring.', '發票:': 'Invoice: ', '定錨 CODA:': 'Anchored CODA: ', '定錨 CODA': 'Anchored CODA',
'重設最高點(資料打錯時用,只有你能按,會留紀錄)': 'Reset peak (for data entry errors; only you can do this; it is logged)', '重設': 'Reset',
'項目': 'Item', '重設前': 'Before reset', '原因': 'Reason', '時間': 'Time', '已還原': 'Restored', '還原': 'Restore',
'撤銷最近一次定錨(只有你能按,會留紀錄)': 'Undo the latest anchor (only you can do this; it is logged)',
'撤銷後回到定錨前的狀態,可以重新定錨;外部系統會看到資料版本換號。': 'Undo returns to the state before anchoring so you can anchor again; external systems will see a new data version.',
'研發組勾選': 'R&D team flags', 'CG Lead 組勾選': 'CG Lead team flags', '發票角色': 'Invoice Role',
'下一次定錨才生效的修改': 'Changes that take effect at the next anchor', '與目前相同': 'Same as current', '撤銷紀錄:': 'Undo log: ', ',原因:': ', reason: ',
'定錨(發票+定錨 CODA)': 'Anchor (Invoice + Anchored CODA)', '沒有完成:': 'Not completed: ', '定錨沒有完成:': 'Anchoring was not completed: ',
// 核心參數
'基本參數': 'Basic Parameters',
'調整人薪倍率、年度工作天數與產出率,這些值會直接影響各部門 CODA 的計算基準。': 'Salary multiplier, annual working days and output rates. These directly drive each department’s CODA.',
'人薪倍率(正職)': 'Salary Multiplier (full-time)', '外包倍率': 'Contractor Multiplier', '年度工作天數': 'Annual Working Days', '月平均工作天數': 'Avg. Working Days per Month',
'P 產出率': 'P Output Rate', 'A 產出率': 'A Output Rate', '美金匯率(1 USD = 幾 TWD)': 'Exchange Rate (TWD per 1 USD)',
'發票分配與目標': 'Invoice Allocation & Targets', '設定各項指標權重與年度專案成本,系統將依此自動演算出各部門應達成的發票目標。': 'Indicator weights and annual project costs. The system derives each department’s invoice target from them.',
'指標1:P 成本': 'Indicator 1: P Cost', '指標2:A 成本': 'Indicator 2: A Cost', '指標3:P 輕重(A:P 成本比)': 'Indicator 3: P Weight (A:P cost ratio)',
'發票總額參數': 'Total Invoice Parameters', '專案委外': 'Project Outsourcing', '員旅(不除毛利率)': 'Company Trip (not divided by gross margin)', '毛利率': 'Gross Margin',
'研發參數與標註': 'R&D Parameters & Flags', '設定研發減免比例。': 'Set the R&D deduction rate.', '研發減免': 'R&D Deduction',
'管理職與 PC 承擔比例': 'Manager & PC Share Ratios', '定義管理職與 PC 職位的成本承擔比例,未承擔的成本將由組員共同分攤。': 'Share ratios for managers and PCs; the unshared cost is spread across the team.',
'未分組': 'No team', '指定部門': 'Assigned department', '手動分組': 'Manual team', '修改手動': 'Edit manual', '清除手動': 'Clear manual',
'修改後自動儲存;清空欄位或按「清除手動」可還原。HR 之後提供資料時以 HR 為準。': 'Saved automatically. Clear the field or press “Clear manual” to revert. HR data takes priority once HR provides it.',
'手動': 'Manual', '依 HR 組織資料自動產生:公司 → 部門 → 組別。RD/CG 勾選會自動儲存;未歸部門的人員不列入部門 CODA。': 'Built from HR organization data: Company → Department → Team. R&D / CG flags save automatically; people without a department are not counted in department CODA.',
'無結果': 'No results', '重新計算中...': 'Recalculating...', '外包(未對應公司)': 'Contractors (unmapped company)', '佔全部': 'of total',
'沒有資料。': 'No data.', '未分組 (需由管理清單指派': 'No team (assign from the management list', '佔總 P 預算': 'of total P budget', '月薪': 'Monthly Pay',
'管理率': 'Management Ratio', '年度預算估計': 'Annual Budget Estimate', '主管': 'Manager', '研發釋出 -': 'R&D release -', '分攤研製預算': 'Shared R&D budget',
'原始加總:': 'Raw total: ', '未分攤': 'Not shared', '月/日薪': 'Monthly / Daily Pay', '工作率': 'Work Rate', '年度總成本': 'Annual Total Cost',
'請輸入有效數值;工作天數、產出率與毛利率必須大於零。': 'Please enter a valid number. Working days, output rates, gross margin and exchange rate must be greater than zero.',
'在職 (12m': 'Active (12m', '未安排 (0m': 'Not scheduled (0m', '非滿年度': 'Partial year',
'沒有符合條件的人員,可調整篩選或新增。': 'No matching people. Adjust the filters or add someone.',
'實習生:薪資 × 1 只算進發票,不算 CODA,計入 A/P 人數': 'Intern: salary × 1 counts toward invoice only, not CODA; included in A/P headcount',
'待分類': 'Unclassified', '篩選總額': 'Filtered Total', '待設定 P/A 職能': 'P / A function not set', 'HR 尚未提供可用薪資': 'HR has not provided a usable salary',
'不計入': 'Excluded', '已儲存': 'Saved', '儲存失敗': 'Save failed',
'HR 試算資料更新失敗,請重新整理後再試。': 'Could not update HR planning data. Please refresh and try again.',
'部門/組別儲存失敗,請重新整理後再試。': 'Could not save department / team. Please refresh and try again.',
'清除手動部門/組別失敗,請重新整理後再試。': 'Could not clear the manual department / team. Please refresh and try again.',
'HR 未提供,可手動補': 'Not provided by HR; can be filled in manually', 'O - 外包': 'O - Contractor', 'A - 藝術家': 'A - Artist',
'新增常態型外包': 'Add regular contractor', '— 未分組': '— No team', '日薪': 'Daily Pay', '時薪': 'Hourly Pay', '/ 日': '/ day', '/ 月': '/ month',
'已刪除': 'Deleted', '已復原': 'Restored', 'HR 組織資料:不是任何單位的主管': 'HR organization data: not a manager of any unit', 'HR 組織資料:': 'HR organization data: ',
'顯示每個人的薪資與成本': 'Show each person’s salary and cost', '隱藏每個人的薪資與成本': 'Hide each person’s salary and cost', '復原': 'Undo',
'常態型外包不在 HR 系統內,在此獨立維護日薪、合約月份與部門/組別;新增、修改、刪除會自動儲存在本站。': 'Regular contractors are not in the HR system. Their daily pay, contract months and department / team are kept here; additions, edits and deletions save automatically.',
'HR 試算名單。姓名、職稱、部門/組別與薪資來自 HR;P/A、管理職及未辨識部/組可在此補齊。未完成 P/A 的人會列出,但不納入正式總額。': 'HR planning roster. Name, title, department / team and salary come from HR; P / A, manager flags and unrecognized departments / teams can be completed here. People without P / A are listed but excluded from official totals.',
'新增人員': 'Add person', '未指定': 'Not set', '其他 (未定義': 'Other (undefined', '已分攤至': 'Allocated to', '含分攤': 'incl. allocation',
'P 預算': 'P Budget', 'A 預算': 'A Budget', '倍率': 'Multiplier', '佔部門總成本': 'of department total cost', '平均日工作 CODA': 'Avg. Daily CODA',
'不含O': 'excl. O', '總月份': 'Total Months', '應負責 CODA': 'Responsible CODA', '日工作 CODA': 'Daily CODA', '[不負責業績]': '[No revenue responsibility]',
'主管承擔 −': 'Manager share −', '您目前以': 'You are signed in as', '身份登入,以下僅顯示您所屬部門': '; only your department',
'的成本組成與細節,全公司總 CODA 仍維持整體規模呈現。': ' cost breakdown and details are shown below. Company total CODA still shows the full scale.',
'佔全公司': 'of company', '平均倍率': 'Avg. Multiplier', 'CODA 組成 (純內製 P+A': 'CODA Composition (in-house P+A only', '部門平均日工作 CODA': 'Department Avg. Daily CODA',
'組別倍率=人薪倍率 × 組別最終 CODA ÷ 組內 A 成本': 'Team multiplier = salary multiplier × team final CODA ÷ team A cost',
'部門平均倍率=人薪倍率 × 部門 CODA ÷ 部門 A 成本(即各組倍率依 A 成本加權的平均)': 'Department avg. multiplier = salary multiplier × department CODA ÷ department A cost (A-cost-weighted average of team multipliers)',
'常態型外包儲存失敗,請重新整理後再試;剛才的外包修改尚未保存。': 'Could not save contractors. Please refresh and try again; your recent contractor changes were not saved.',
'已定錨:剛才的參數修改會在下一次定錨才生效,這半年的數字照舊。': 'Anchored: your parameter changes take effect at the next anchor; numbers for this half stay as they are.',
'RD/CG 勾選或核心參數儲存失敗,請重新整理後再試;剛才的修改尚未保存。': 'Could not save R&D / CG flags or core parameters. Please refresh and try again; your changes were not saved.',
// 登入狀態
'本機預覽': 'Local preview', '本機預覽,尚未啟用登入或權限控管': 'Local preview; sign-in and permissions are not enabled', '確認登入狀態中': 'Checking sign-in', '無法確認登入狀態': 'Cannot confirm sign-in',
'本機未啟用公司登入': 'Company sign-in is not enabled locally', '公司帳號': 'Company account', '目前登入帳號': 'Signed-in account', '登入狀態確認失敗': 'Sign-in check failed',
'請重新整理或登入': 'Please refresh or sign in', '尚未登入或登入已逾時': 'Not signed in or session expired', '登入後即可載入資料': 'Sign in to load data', '重新登入': 'Sign in again',
'登入已失效,請按左下角「重新登入」載入資料。': 'Your session has expired. Press “Sign in again” at the lower left to load data.',
'目前登入的公司帳號不在 LeadBoard 的允許名單內。': 'The signed-in company account is not on the LeadBoard allow list.',
'本站尚未收到平台提供的 HR Sync 執行期設定;因此沒有使用合成資料替代。': 'This site has not received the HR Sync runtime settings from the platform, so no synthetic data is used instead.',
'公司登入成功,但 HR Sync 未核准這個帳號的資料交換權限。': 'Company sign-in succeeded, but HR Sync has not approved data exchange for this account.',
'HR Sync 已連線,但拒絕目前要求的資料範圍。': 'HR Sync is connected but refused the requested data scope.', '公司登入已過期,請重新登入。': 'Your company sign-in has expired. Please sign in again.',
'HR Sync 暫時無法回應,請稍後重新整理。': 'HR Sync is not responding. Please refresh later.', 'HR Sync 服務目前尚未可用。': 'The HR Sync service is not available yet.',
'HR 試算資料讀取失敗(HTTP': 'Could not load HR planning data (HTTP', '伺服器回傳格式不符。': 'The server response format is not valid.',
'HR 試算|已轉入': 'HR planning | Imported', '位 HR 在職人員;': ' active HR employees; ',
'位待確認 P/A 或薪資,暫不納入正式總額。時薪先按每週 5 天、每天 8 小時計算;H1 預設為 1–6 月。常態型外包': ' need P / A or salary confirmation and are excluded from official totals for now. Hourly pay assumes 5 days a week, 8 hours a day; H1 defaults to Jan–Jun. Regular contractors: ',
'位,在本站手動維護並儲存。': ', maintained and saved on this site.',
'合成資料預覽|姓名、薪資與參數皆為虛構資料;修改只保留在目前頁面工作階段。': 'Synthetic data preview | Names, salaries and parameters are fictional; edits last only for this page session.',
'無法載入預覽資料:': 'Could not load preview data: ',
// 新增人員視窗
'職能角色': 'Function', 'P - 製作人': 'P - Producer', 'P - 執行製作': 'P - Line Producer', 'A - 特效師': 'A - FX Artist', 'A - 動畫師': 'A - Animator',
'A - 剪輯': 'A - Editor', 'A - 燈光': 'A - Lighting', '屬性': 'Type', 'H1 上半年合約期間': 'H1 Contract Period', '— 無': '— None',
'1月': 'Jan', '2月': 'Feb', '3月': 'Mar', '4月': 'Apr', '5月': 'May', '6月': 'Jun', '7月': 'Jul', '8月': 'Aug', '9月': 'Sep', '10月': 'Oct', '11月': 'Nov', '12月': 'Dec',
'H2 下半年合約期間': 'H2 Contract Period', '✓ 確認新增': '✓ Add',
// /my 與模擬試算(scope-ui.js)
'MoonShine LeadBoard · 我的範圍': 'MoonShine LeadBoard · My View', '我的範圍': 'My View', '讀取中…': 'Loading…',
'實際 CODA:即時計算,資料一變就跟著變,定價看「平均日 CODA」。定錨 CODA:半年的目標(1 月、7 月定錨),半年內只增不減。所有數字都由伺服器計算。': 'Actual CODA is calculated live and changes whenever the data changes; use “Avg. Daily CODA” for pricing. Anchored CODA is the half-year target (anchored in January and July) and can only increase within the half. All numbers are calculated on the server.',
'工號': 'Employee No.', '權限來源:': 'Access via: ', '目前': 'Current', '定錨': 'Anchor',
'A 藝術家': 'A Artist', 'P 製作': 'P Production', 'O 外包': 'O Contractor', '實習生': 'Intern', '工讀(算 O)': 'Part-time (counted as O)',
'G 管理': 'G Manager', '外包': 'Contractor', '實習': 'Intern', '工讀': 'Part-time',
'本試算只用來快速估算加人、調薪後大約的 CODA 與發票量,結果只代表試算當下的狀態。實際數字會隨人員與參數變動,正式數字一律以每年 1 月、7 月定錨後統一公布的為準。': 'This simulation is only a quick estimate of CODA and invoice after adding people or raising pay, as of the moment it runs. Actual numbers change with staffing and parameters; official numbers are always those published after the January and July anchors.',
'尚未定錨': 'Not anchored yet', '在職月份': 'Months Employed', '薪資': 'Salary', '年度成本': 'Annual Cost',
'這個部門不分配發票': 'This department is not allocated invoice', '定錨:上半年': 'Anchor: H1', '/下半年': ' / H2', '(定錨前預估)': ' (estimate before anchoring)',
'指標 1 P 佔比': 'Indicator 1 P Share', '你部門 P 的成本,佔四個出發票部門 P 成本總和的比例。': 'Your department’s P cost as a share of total P cost in the four invoicing departments.',
'指標 2 A 佔比': 'Indicator 2 A Share', '你部門 A 的成本,佔四個出發票部門 A 成本總和的比例。': 'Your department’s A cost as a share of total A cost in the four invoicing departments.',
'指標 3 P 輕重': 'Indicator 3 P Weight', 'P 成本 ×(P 成本 ÷ A 成本,A 含常態型外包),再換算成佔比。P 相對 A 越重,分得越多。': 'P cost × (P cost ÷ A cost, A including regular contractors), converted to a share. The heavier P is relative to A, the larger the share.',
'發票佔比 = 三個指標各自乘上權重後加總。下面是你部門的三個指標:': 'Invoice share = sum of the three indicators, each times its weight. Your department’s three indicators:',
'指標': 'Indicator', '你部門': 'Your department', '貢獻': 'Contribution', '發票佔比': 'Invoice Share',
'A:P 成本比(A 含外包 ÷ P):你部門': 'A:P cost ratio (A incl. contractors ÷ P): your department', ',四個部門整體': ', four departments overall',
'。數字越大,代表每 1 元 P 成本對應的 A 越多。': '. A higher number means more A per dollar of P cost.', '目前沒有資料': 'No data yet',
'實際 CODA(部門)': 'Actual CODA (Department)', '平均日 CODA(部門)': 'Avg. Daily CODA (Department)', '定錨 CODA(部門)': 'Anchored CODA (Department)',
'定錨後發票': 'Invoice after Anchoring', '尚未定錨,定錨後才有': 'Available after the first anchor', '不變': 'No change', '▲ 增加': '▲ Up', '▼ 減少': '▼ Down',
'個百分點': ' percentage points', '加 1 人:': 'Add 1 person: ', '調薪:': 'Raise: ', '沒有調整任何東西(目前的數字)。': 'Nothing adjusted (current numbers).',
'各組的實際 CODA 都沒有變。': 'Actual CODA did not change for any team.', '人(不算 CODA)': ' people (not counted in CODA)', '調薪': 'Raise',
'實際 CODA 的變化,變最多的排最上面。': 'Change in Actual CODA, largest first.', '發票是全公司一起分的:你部門': 'Invoice is shared across the company: your department', '變多,其他部門會相對變少。': ' goes up, so other departments go down.', '變少,其他部門會相對變多。': ' goes down, so other departments go up.', '金額': 'Amount', '清除': 'Clear', '加 1 人': 'Add 1 person',
'① 你這次試算了什麼': '① What you changed', '② 結果:現在 → 試算後': '② Result: now → after', '③ 影響在哪一組': '③ Which teams are affected',
'移除': 'Remove', '模擬調薪(': 'Simulated raises (', '人可調)': ' people adjustable)', '可調)': ' adjustable)', '預算': 'Budget', '模擬後': 'After', '已調整': 'Adjusted',
'模擬試算(不會存檔)': 'Simulation (not saved)',
'在本部門加人或調薪,看看實際 CODA、平均日 CODA、定錨 CODA、發票、倍率會變多少。工讀算 O:日薪=時薪×8。實習生只進發票、不算 CODA。': 'Add people or raise pay in this department and see how Actual CODA, Avg. Daily CODA, Anchored CODA, invoice and multiplier change. Part-timers count as O: daily pay = hourly pay × 8. Interns count toward invoice only, not CODA.',
'+ 加一個人': '+ Add a person', '你目前沒有可以模擬的部門。': 'You have no department to simulate.', '目前沒有可以看的部門或組別。': 'There is no department or team for you to view.',
'試算失敗:': 'Simulation failed: ', '(請檢查在職月份與金額)': ' (check months employed and amounts)', '內容已改,請重新試算。下面是上一次試算的結果。': 'Inputs changed; please run again. Below are the previous results.',
'你目前沒有 LeadBoard 的檢視權限。需要的話請找管理者開通。': 'You do not have LeadBoard view access yet. Ask an administrator if you need it.',
'資料讀取失敗,請稍後重新整理。': 'Could not load data. Please refresh later.', '不調整': 'No change', '模擬薪資': 'simulated salary',
// 補充(畫面檢查時找到的)
'主選單': 'Main menu', '搜尋姓名、職稱...': 'Search name, title...', '搜尋': 'Search', '請輸入姓名': 'Enter a name', '請輸入': 'Enter', '例:': 'e.g. ', '資深特效師': 'Senior FX Artist',
'切換年份(查看已封存的年度)': 'Switch year (view archived years)', '說明': 'info', '只供參考,不影響任何計算。': 'For reference only; does not affect any calculation.',
'只供參考': 'For reference only', '不影響任何計算': 'does not affect any calculation', '查看分配明細': 'view allocation details', '明細': 'details',
'與「部門 CODA」頁相同:P + A 成本,不含營運支援與外包': 'Same as the “Department CODA” page: P + A cost, excluding operations support and contractors',
'人薪倍率': 'Salary Multiplier', '成本': 'cost', '不含': 'excl.', '含': 'incl.', '多': 'over by', '差': 'short by', '全公司(含未歸部門人員)': 'Whole company (incl. people with no department)',
'研發組減免比例': 'R&D Team Deduction Rate', '管理職 P 承擔比例': 'Manager P Share Ratio', 'PC 承擔比例': 'PC Share Ratio', '管理職 A 承擔比例': 'Manager A Share Ratio', 'CG Lead 承擔比例': 'CG Lead Share Ratio',
'承擔比例': 'Share Ratio', '承擔': 'share', '比例': 'ratio', '公司預設': 'Company default', '預設': 'Default', '全部跟隨': 'All follow company', '跟隨公司': 'Follow company', '改回跟隨': 'Revert to company default',
'含外包': 'incl. contractors', '(不列入部門 CODA)': ' (not counted in department CODA)', '不列入': 'not counted in', '專案管理': 'Project Management', '員工': 'Employee ',
'輸入部門': 'Enter department', '輸入組別': 'Enter team', '輸入': 'Enter', '(部)': ' (Dept.)', '(組)': ' (Team)', '(公司)': ' (Company)', '(集團)': ' (Group)', '(集團,次要)': ' (Group, secondary)',
'(公司,次要)': ' (Company, secondary)', '(組,次要)': ' (Team, secondary)', '(部,次要)': ' (Dept., secondary)', '次要': 'secondary', '集團': 'Group',
'管理職(由 HR 提供,不可修改)': 'Manager (from HR, read-only)', '由 HR 提供,目前不可在試算頁覆寫': 'Provided by HR; cannot be overridden on the planning page', '薪資已隱藏': 'Salary hidden', 'HR 同步': 'HR sync',
'G 營運支援:計成本 × 人薪倍率': 'G Operations Support: cost × salary multiplier', 'AI影像企劃': 'AI Visual Planner', '實習AI概念美術': 'AI Concept Art Intern', '實習工程師': 'Engineering Intern',
'內部人員': 'Internal staff', '導演': 'Director', '特約藝術家': 'Freelance Artist', '須另行負擔之外包成本:': 'Additional contractor cost:', '須另行負擔之外包成本': 'Additional contractor cost',
'含主管及 CG Lead 承擔分攤': 'incl. manager and CG Lead share allocation', '組內 P+A': 'Team P+A', 'O外包': 'O Contractors', '年度總成本(組內佔比)': 'Annual Total Cost (share within team)', '組內佔比': 'share within team',
'分攤研製及管理 CODA': 'Allocated R&D and Management CODA', '分攤來源:': 'Allocated from: ', '依各部門自身 CODA 比例': 'in proportion to each department’s own CODA',
'本部門 P+A 合計': 'This department P + A total', '依比例分攤': 'allocated proportionally', '合計': 'Total', '公司合計': 'Company total',
'底線發票說明': 'Break-even invoice info', '全企業總成本說明': 'Total company cost info', '指標3 說明': 'Indicator 3 info',
'全企業不虧本至少要開的發票,不含利潤:全企業總成本': 'Minimum invoice for the company to break even, before profit: total company cost',
'年度發票目標,查看分配明細': 'Annual invoice target; view allocation details',
'指標3=P 成本 × (P 成本 ÷ A 成本),A 成本含常態型外包,再換算成佔比:P 相對 A 越重,分得越多。下方「P 比平均多/少」是和四部門整體成本比(': 'Indicator 3 = P cost × (P cost ÷ A cost), with A cost including regular contractors, converted to a share: the heavier P is relative to A, the larger the share. “P above / below average” below compares with the four departments’ overall cost ratio (',
')相比。': ').', 'A:P 成本比': 'A:P cost ratio', '(承擔部門平均': ' (average of invoice-bearing departments', '。A 成本含常態型外包。': '. A cost includes regular contractors.',
'P 比平均多': 'P above average by', 'P 比平均少': 'P below average by', '與平均相同': 'same as average',
'不計入發票的單位(成本 × 人薪倍率)': 'Units outside the invoice (cost × salary multiplier)', '人員資料(全部門)': 'Staff (All Departments)', '常態型外包(全部門)': 'Regular Contractors (All Departments)',
'刪除': 'Delete', 'RD 研發組:成本扣除研發比例': 'R&D team: cost minus R&D deduction', '選擇部門': 'Select department', '定錨 CODA(部門=各組加總)': 'Anchored CODA (department = sum of teams)',
'發票與倍率': 'Invoice & Multiplier', '部門內部成本(P+A+G,不含外包)÷ A 成本 × 人薪倍率': 'Department internal cost (P + A + G, excl. contractors) ÷ A cost × salary multiplier',
'發票佔比怎麼來的': 'How the invoice share is calculated', '人力': 'Headcount', '部門總人力成本(年)': 'Department Total Labor Cost (annual)', '總人力成本(年)': 'Total Labor Cost (annual)',
'正職年薪 × 人薪倍率 + 外包 × 外包倍率,不含實習生': 'Full-time annual salary × salary multiplier + contractors × contractor multiplier, excl. interns',
'各組': 'Teams', '平均日 CODA': 'Avg. Daily CODA', '人數是算 CODA 的人(A 與外包);總人力成本含組內所有人(含 P、外包,不含實習生)。': 'Headcount counts people in CODA (A and contractors); total labor cost covers everyone in the team (incl. P and contractors, excl. interns).',
'顯示目前薪資': 'Show current salaries', '隱藏目前薪資': 'Hide current salaries', '最高管理者': 'Top administrator', '管理者': 'Administrator',
'全公司沒有定錨 CODA 合計(調動時原單位不降、新單位增加,加總會重複)。': 'There is no company total for Anchored CODA (on transfer the old unit does not drop and the new unit increases, so a sum would double count).',
'個人明細(': 'Individual details (', '個人明細': 'Individual details', '人)': ' people)', '人,': ' people, ', '發票': 'Invoice', '年薪': 'Annual Salary', '倍數': 'Multiple',
'正職': 'Full-time', '比較': 'Comparison', '平均': 'Average', '人員': 'Staff', '總額': 'Total',
// 公司、部門、組別(依架構圖)
'夢想動畫股份有限公司': 'MoonShine Animation Co., Ltd.', '夢想創造股份有限公司': 'MoonShine Creative Co., Ltd.', '夢境現實股份有限公司': 'MoonDream Reality Co., Ltd.',
'虛擬實景股份有限公司': 'MoonShine XR Studio Co., Ltd.', '登月智慧股份有限公司': 'Moonland AI Co., Ltd.',
'夢想集團': 'MoonShine Group', '夢想動畫': 'MoonShine Animation', '夢想創造': 'MoonShine Creative', '夢境現實': 'MoonDream Reality', '虛擬實景': 'MoonShine XR Studio', '登月智慧': 'Moonland AI', '虛實入口': 'Phygitalport',
'前製部': 'Pre-Production', '動畫部': 'Animation', '視效部': 'VFX', '廣告部': 'Commercial', '研發部': 'R&D', '營運部': 'Operations', '業務部': 'Business',
'互動技術部': 'Interactive Technology', '互動美術部': 'Interactive Art', '專案與場館營運部': 'Projects & Venue Operations',
'導演組': 'Directing', '設計概念組': 'Concept Design', '畢製續約': 'Graduate Renewal', '動畫組': 'Animation', '前製組': 'Pre-Production', '後製組': 'Post-Production',
'技術組': 'Technical', '專案組': 'Production', '動畫部管理組': 'Animation Management', '3D組': '3D', '3D 組': '3D', '特效組': 'FX', '合成組': 'Compositing',
'視效部管理組': 'VFX Management', 'A組': 'Team A', 'B組': 'Team B', 'C組': 'Team C', 'D組': 'Team D', 'AD組': 'Art Direction', 'AD 組': 'Art Direction',
'開發1組': 'Development 1', '開發2組': 'Development 2', '平台組': 'Platform', '研發部製程組': 'Pipeline', 'AI內容製作組': 'AI Content Production', '管理組': 'Management',
'資訊組': 'IT', '行政管理組': 'Administration', '企劃行銷組': 'Marketing & Planning', '美術組': 'Art', '場館營運組': 'Venue Operations',
'研發組': 'R&D team', '營運支援': 'Operations Support', '執行長': 'CEO', '部長': 'Head of Production', '督導': 'Supervisor', '組長': 'Lead'
};
var PUNCT = { ',': ', ', '。': '. ', ':': ': ', ';': '; ', '(': ' (', ')': ') ', '「': '“', '」': '”', '、': ', ', ' ': ' ',
'=': ' = ', '+': ' + ', '/': ' / ', '!': '! ', '?': '? ', '~': '~', '《': '“', '》': '”' };
var CJK = /[㐀-鿿]/;
var names = {}; // 中文姓名 → 英文名
var table = null, matcher = null;
var missing = new Map(); // 沒翻到的中文 → 原句(檢查用)
function escapeRe(s) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
function build() {
table = Object.assign({}, DICT);
Object.keys(names).forEach(function (zh) { table[zh] = zh + ' ' + names[zh]; });
var keys = Object.keys(table).filter(function (k) { return k && CJK.test(k); }).sort(function (a, b) { return b.length - a.length; });
matcher = new RegExp(keys.map(escapeRe).join('|'), 'g');
}
var WORD_END = /[A-Za-z0-9)%\]$]$/, WORD_START = /^[A-Za-z0-9(\[$#]/;
function join(parts) {
var out = '';
parts.forEach(function (p) {
if (!p) return;
if (out && WORD_END.test(out) && WORD_START.test(p)) out += ' ';
out += p;
});
return out;
}
// 跟數字連在一起的單字(人、位、年、月、日、時、倍、天):只在數字旁邊才換,避免拆壞其他詞。
// 只在整段文字就是這個字時才換(單位、頭像縮寫)。
var EXACT = { '倍': '×', '天': 'days', '率': '%', '組': 'Team', '預': 'P', '日': 'day', '時': 'hr', '人': 'people', '年': '', '位': '', '月': '', '元': 'NT$' };
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
function mon(n) { var i = Number(n); return i >= 1 && i <= 12 ? MONTHS[i - 1] : n; }
function numberRules(s) {
return s
.replace(/(\d+)–(\d+)、(\d+)–(\d+)\s*月/g, function (m, a, b, c, d) { return mon(a) + '–' + mon(b) + ', ' + mon(c) + '–' + mon(d); })
.replace(/(\d+)–(\d+)\s*月/g, function (m, a, b) { return mon(a) + '–' + mon(b); })
.replace(/(^|\s)日 (?=(?:NT|US)\$)/g, '$1Daily ').replace(/(^|\s)時 (?=(?:NT|US)\$)/g, '$1Hourly ')
.replace(/佔(?=[\u3400-\u9fffA-Za-z])/g, 'of ')
.replace(/(\d+)\s*月(?![份薪平])/g, function (m, n) { var i = Number(n); return i >= 1 && i <= 12 ? MONTHS[i - 1] : m; })
.replace(/(\d[\d,]*)\s*(?:位|名)?\s*人(?![員力數])/g, '$1 people')
.replace(/(\d[\d,]*)\s*位/g, '$1')
.replace(/(\d{4})\s*年(?!度)/g, '$1')
.replace(/(\d[\d,.]*)\s*倍/g, '$1×')
.replace(/(\d[\d,.]*)\s*天/g, '$1 days')
.replace(/(\d[\d,.]*)\s*筆/g, '$1 items');
}
function translate(text, spacing) {
if (lang !== 'en' || !text || !CJK.test(text)) return text;
if (!matcher) build();
var lead = text.match(/^\s*/)[0], tail = text.match(/\s*$/)[0];
var body = text.trim();
if (EXACT[body] !== undefined) return lead + EXACT[body] + tail;
body = body.replace(/(\d{4}) 試算/g, '$1 Planning');
var parts = [], last = 0, m;
matcher.lastIndex = 0;
while ((m = matcher.exec(body))) {
parts.push(body.slice(last, m.index));
parts.push(table[m[0]]);
last = m.index + m[0].length;
}
parts.push(body.slice(last));
var out = numberRules(join(parts)).replace(/[,。:;()「」、 =+/!?~《》]/g, function (c) { return PUNCT[c]; });
out = out.replace(/ {2,}/g, ' ').replace(/ ([,.;:)%])/g, '$1').replace(/\( /g, '(').replace(/^ +/, '');
// 中文原本不用空格;和旁邊的文字(另一個節點)相連時補一個空格,避免黏在一起。
if (spacing) {
if (spacing.after && /[\u3400-\u9fff]$/.test(body) && /[A-Za-z0-9)]$/.test(out) && !tail) out += ' ';
if (spacing.before && /^[\u3400-\u9fff]/.test(body) && /^[A-Za-z0-9(]/.test(out) && !lead) out = ' ' + out;
}
var check = out;
Object.keys(names).forEach(function (zh) { check = check.split(zh).join(''); });
var left = check.match(/[㐀-鿿][㐀-鿿\s]*/g);
if (left && !missing.has(body)) missing.set(body, left.map(function (s) { return s.trim(); }).join(' | '));
return lead + out + tail;
}
// ---- 畫面翻譯(只在 English 時啟動) ----
var ATTRS = ['title', 'placeholder', 'aria-label', 'data-tip', 'alt'];
var SKIP = { SCRIPT: 1, STYLE: 1, TEXTAREA: 1, CODE: 1 };
// 每個節點記住原文與譯文:畫面程式改了內容才重翻;英文名載入後從原文重翻,不會翻兩次。
var seen = new WeakMap();
function doText(node, again) {
var value = node.nodeValue;
var rec = seen.get(node);
var source = rec && (value === rec.out) ? rec.orig : value;
if (rec && value === rec.out && !again) return;
var next = translate(source, { before: !!node.previousSibling, after: !!node.nextSibling });
seen.set(node, { orig: source, out: next });
if (next !== value) node.nodeValue = next;
}
function doAttrs(el, again) {
var rec = seen.get(el) || {};
ATTRS.forEach(function (a) {
if (!el.hasAttribute(a)) return;
var v = el.getAttribute(a);
var r = rec[a];
var source = r && v === r.out ? r.orig : v;
if (r && v === r.out && !again) return;
if (!CJK.test(source)) return;
var n = translate(source);
rec[a] = { orig: source, out: n };
if (n !== v) el.setAttribute(a, n);
});
seen.set(el, rec);
}
function skipped(node) {
for (var el = node.nodeType === 1 ? node : node.parentElement; el; el = el.parentElement) {
if (SKIP[el.tagName] || el.hasAttribute('data-i18n-skip')) return true;
}
return false;
}
function walk(root, again) {
if (!root || skipped(root)) return;
if (root.nodeType === 3) { doText(root, again); return; }
if (root.nodeType !== 1) return;
doAttrs(root, again);
var walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, {
acceptNode: function (n) { return n.nodeType === 1 && (SKIP[n.tagName] || n.hasAttribute('data-i18n-skip')) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; }
});
var n;
while ((n = walker.nextNode())) { if (n.nodeType === 3) doText(n, again); else doAttrs(n, again); }
}
function startDom() {
if (lang !== 'en' || !document.body) return;
document.title = translate(document.title);
walk(document.body);
new MutationObserver(function (records) {
records.forEach(function (r) {
if (r.type === 'characterData') { if (!skipped(r.target)) doText(r.target); }
else if (r.type === 'attributes') { if (!skipped(r.target)) doAttrs(r.target); }
else r.addedNodes.forEach(function (n) { walk(n); });
});
}).observe(document.body, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ATTRS });
['alert', 'confirm', 'prompt'].forEach(function (k) {
var original = window[k];
window[k] = function (message) { var args = Array.prototype.slice.call(arguments); args[0] = translate(String(message == null ? '' : message)); return original.apply(window, args); };
});
}
// ---- 英文名 ----
function loadNames() {
if (lang !== 'en') return Promise.resolve();
return fetch('/api/names', { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).then(function (data) {
if (!data || !data.names) return;
names = data.names; build();
if (document.body) walk(document.body, true);
}).catch(function () {});
}
// ---- 切換按鈕:放在有 data-pmb-switches 的位置 ----
function renderSwitches() {
document.querySelectorAll('[data-pmb-switches]').forEach(function (host) {
var cls = host.getAttribute('data-pmb-switches') || 'theme-toggle';
host.setAttribute('data-i18n-skip', '');
host.innerHTML =
'<div class="' + cls + '" role="group" aria-label="Language / 語言">' +
'<button type="button" data-pmb-lang="zh" aria-pressed="' + (lang === 'zh') + '">中文</button>' +
'<button type="button" data-pmb-lang="en" aria-pressed="' + (lang === 'en') + '">EN</button></div>' +
'<div class="' + cls + '" role="group" aria-label="Currency / 幣別">' +
'<button type="button" data-pmb-cur="TWD" aria-pressed="' + (currency === 'TWD') + '">NT$</button>' +
'<button type="button" data-pmb-cur="USD" aria-pressed="' + (currency === 'USD') + '">US$</button></div>';
host.querySelectorAll('[data-pmb-lang]').forEach(function (b) { b.addEventListener('click', function () { if (b.dataset.pmbLang !== lang) { write('pmb-lang', b.dataset.pmbLang); location.reload(); } }); });
host.querySelectorAll('[data-pmb-cur]').forEach(function (b) { b.addEventListener('click', function () { if (b.dataset.pmbCur !== currency) { write('pmb-currency', b.dataset.pmbCur); location.reload(); } }); });
});
}
function init() { renderSwitches(); startDom(); loadNames(); }
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init); else init();
window.PMI18n = {
lang: function () { return lang; }, currency: function () { return currency; }, rate: function () { return rate; },
setRate: setRate, amt: amt, sym: sym, cur: cur, compact: compact, t: function (s) { return translate(s); },
missing: function () { return Array.from(missing.entries()); }
};
})();