{"record":{"id":"798fad408d98c64c","repo":"maboloshi/github-chinese","slug":"github-locals-js-798fad","errorCode":null,"errorMessage":"[GitHub 中文化插件] 詞庫文件 locals.js 未加載","messagePattern":"\\[GitHub 中文化插件\\] 詞庫文件 locals\\.js 未加載","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"main_zh-TW.user.js","lineNumber":143,"sourceCode":"        // 當前運行時狀態\n        pageConfig: null,        // 當前頁面配置（null 表示無有效頁面）\n        currentURL: window.location.href, // 當前頁面URL\n        transEngine: 'iflyrec',  // 當前翻譯引擎\n        mutationObserver: null,  // DOM變化觀察器\n        urlChangeHandler: null,  // 存儲URL變化處理器\n        dynamicMenus: {},        // 動態菜單ID記錄\n        initDone: false,\n    };\n\n    /* =========================== 安全檢查 =========================== */\n\n    /**\n     * 檢查詞庫文件是否加載 — 未加載則拋出錯誤阻止繼續執行\n     */\n    function checkI18NLoaded() {\n        if (typeof I18N === 'undefined') {\n            alert('GitHub 漢化插件：詞庫文件 locals.js 未加載，腳本無法運行！');\n            throw new Error('[GitHub 中文化插件] 詞庫文件 locals.js 未加載');\n        }\n    }\n\n    /**\n     * 錯誤邊界 — 包裝函數，捕獲異常避免阻斷頁面正常使用\n     * @param {Function} fn - 要執行的函數\n     * @param {string} label - 錯誤標簽\n     * @returns {Function} 包裝後的函數\n     */\n    function safe(fn, label) {\n        return function (...args) {\n            try {\n                return fn.apply(this, args);\n            } catch (e) {\n                console.error(`[GitHub 中文化插件] ${label} 出錯:`, e);\n            }\n        };\n    }","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/maboloshi/github-chinese/blob/1db777260aeaeba52b39ebc37e1097e0c7053198/main_zh-TW.user.js#L125-L161","documentation":"The Traditional-Chinese variant of the same guard. Its vocabulary comes from a separate file locals_zh-TW.js (generated from locals.js by an opencc sync workflow) required via // @require .../locals_zh-TW.js?v1.9.4.4-2026-06-21. When that generated dictionary did not load, typeof I18N === 'undefined' and the script alerts in Traditional Chinese then throws.","triggerScenarios":"The @require of locals_zh-TW.js on gh-pages 404s — the zh-TW sync workflow (opencc -i locals.js -o locals_zh-TW.js) has not run or the file is missing on the published branch — so the global I18N is undefined at line 165. Also fires if raw.githubusercontent.com is unreachable or @require is disabled in the manager.","commonSituations":"A release where the zh-TW generation step was skipped or failed in CI, leaving locals_zh-TW.js absent at the pinned version; the @require version string pointing at a date (2026-06-21) that has no corresponding published file; network blocking of raw.githubusercontent.com; manager @require disabled.","solutions":["Open the exact locals_zh-TW.js @require URL; a 404 means the zh-TW artifact is missing — fall back to the Simplified main.user.js build (whose locals.js is always published) until the sync workflow runs.","Confirm the .github/workflows opencc sync step produced and committed locals_zh-TW.js, then update the @require version to match the published file.","If the host is blocked, switch to the NJU mirror variant or a local file:/// @require with local-file access enabled.","Re-fetch @require resources in the manager (reinstall / edit+save) after the file is published."],"exampleFix":"// before\n// @require      https://raw.githubusercontent.com/mabolashi/github-chinese/gh-pages/locals_zh-TW.js?v1.9.4.4-2026-06-21\n// after — zh-TW artifact missing, temporarily require the Simplified dictionary\n// @require      https://raw.githubusercontent.com/mabolashi/github-chinese/gh-pages/locals.js?v1.9.4.4","handlingStrategy":"validation","validationCode":"// Before init(), confirm the zh-TW dictionary actually loaded:\nif (typeof I18N === 'undefined' || !I18N || typeof I18N !== 'object') {\n    console.error('[github-chinese] locals_zh-TW.js not loaded — aborting');\n    return;\n}","typeGuard":"function isI18NPresent(v: unknown): v is Record<string, unknown> {\n    return typeof v === 'object' && v !== null;\n}","tryCatchPattern":"try {\n    checkI18NLoaded();\n    init();\n} catch (e) {\n    console.warn('[github-chinese] skipped:', e instanceof Error ? e.message : e);\n}","preventionTips":["Gate releases on the opencc sync producing locals_zh-TW.js (CI check the file exists).","Verify the @require version/date matches a published zh-TW file.","Keep a Simplified-locale fallback @require for when the zh-TW artifact lags.","Ensure the manager fetches @require resources on install."],"tags":["userscript","i18n","runtime-guard","require","zh-tw","ci-artifact"],"backgroundTag":null,"analyzedSha":"1db777260aeaeba52b39ebc37e1097e0c7053198","analyzedAt":"2026-08-13T05:58:27.900Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}