orca-zh-tw-installer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -0
- package/index.js +133 -0
- package/orca_zh_TW_translation.json +11022 -0
- package/package.json +24 -0
- package/zh-TW-nested.js +13684 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Orca AI IDE 台灣正體中文語系包
|
|
4
|
+
|
|
5
|
+
**Orca zh-TW Language Pack & Installer**
|
|
6
|
+
|
|
7
|
+
為 Orca AI 程式開發環境提供專業的台灣在地化繁體中文支援
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/orca-zh-tw-installer)
|
|
10
|
+
[](https://www.npmjs.com/package/orca-zh-tw-installer)
|
|
11
|
+
[](https://nodejs.org)
|
|
12
|
+
[](#支援的作業系統)
|
|
13
|
+
[](LICENSE)
|
|
14
|
+
|
|
15
|
+
[快速開始](#快速開始) | [功能特色](#功能特色) | [支援系統](#支援的作業系統)
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 關於專案
|
|
22
|
+
|
|
23
|
+
官方 Orca 內建的語言系統具有白名單限制,若強制選擇繁體中文會被退回預設語言(System)或簡體中文。本專案透過跨平臺自動化腳本,解除官方白名單限制,並注入超過 11,000 句針對台灣軟體工程師習慣精修的在地化翻譯。
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 功能特色
|
|
28
|
+
|
|
29
|
+
| 功能 | 說明 |
|
|
30
|
+
|------|------|
|
|
31
|
+
| **一鍵跨平臺安裝** | 透過 `npx` 自動偵測作業系統並完成替換 |
|
|
32
|
+
| **自動破解白名單** | 突破官方限制,將 `zh-TW` 寫入前端與核心白名單 |
|
|
33
|
+
| **專業工程術語** | 翻譯精修,針對台灣開發者習慣用語(如 Worktree、終端機) |
|
|
34
|
+
| **無痛備份機制** | 安裝前自動備份原始檔案(`app.asar.bak`),確保環境安全 |
|
|
35
|
+
| **自動追蹤更新** | npm 發布機制確保未來套用更新時始終取得最新版本 |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 快速開始
|
|
40
|
+
|
|
41
|
+
請確認系統已安裝 Node.js。開啟終端機並輸入以下指令:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx orca-zh-tw
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
腳本將自動執行以下流程:
|
|
48
|
+
1. 自動定位作業系統對應的 Orca 安裝路徑。
|
|
49
|
+
2. 備份官方 `app.asar`。
|
|
50
|
+
3. 解包並破解主程式與渲染器(Renderer)語言限制。
|
|
51
|
+
4. 注入 11,000 句繁體中文字典檔。
|
|
52
|
+
5. 重新封裝。
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 啟用教學
|
|
57
|
+
|
|
58
|
+
1. 安裝完成後,請**徹底關閉 Orca**(於系統工具列右鍵選擇 Quit)。
|
|
59
|
+
2. 重新啟動 Orca 應用程式。
|
|
60
|
+
3. 進入 `Settings -> Appearance -> Language`。
|
|
61
|
+
4. 選擇 `中文(繁體)` 即可套用。
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 支援的作業系統
|
|
66
|
+
|
|
67
|
+
腳本會依據環境自動判定預設安裝路徑:
|
|
68
|
+
|
|
69
|
+
| 作業系統 | 預設自動掃描路徑 |
|
|
70
|
+
|----------|----------------|
|
|
71
|
+
| **Windows** | `AppData/Local/Programs/orca/resources/app.asar` |
|
|
72
|
+
| **macOS** | `/Applications/Orca.app/Contents/Resources/app.asar` |
|
|
73
|
+
| **Linux** | `/opt/Orca/resources/app.asar` |
|
|
74
|
+
|
|
75
|
+
*註:若您的 Orca 安裝於非標準路徑,腳本會提示找不到檔案,您可手動覆蓋處理。*
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 開發與手動安裝
|
|
80
|
+
|
|
81
|
+
若需檢視翻譯內容或手動封裝,請將專案 clone 至本地端:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
git clone <repository-url>
|
|
85
|
+
cd orca_ZH_TW
|
|
86
|
+
npm install
|
|
87
|
+
npm start
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 檔案結構
|
|
91
|
+
|
|
92
|
+
- `index.js`: 核心安裝腳本,處理 asar 解包、修補與封裝。
|
|
93
|
+
- `zh-TW-nested.js`: Orca 前端讀取的最終編譯檔。
|
|
94
|
+
- `orca_zh_TW_translation.json`: 原始語系字典檔,若欲改善翻譯可直接編輯此檔案。
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 免責聲明
|
|
99
|
+
|
|
100
|
+
此為非官方社群補丁,僅修改本地客戶端檔案。安裝過程會自動建立 `app.asar.bak` 備份檔,如遇應用程式異常,請自行還原備份檔案。
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
<div align="center">
|
|
105
|
+
|
|
106
|
+
**Made for the Taiwan Developer Community**
|
|
107
|
+
|
|
108
|
+
</div>
|
package/index.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
console.log('\n🐳 歡迎使用 Orca 台灣繁體中文 (zh-TW) 一鍵安裝包!\n');
|
|
8
|
+
|
|
9
|
+
const platform = os.platform();
|
|
10
|
+
let orcaPath = '';
|
|
11
|
+
|
|
12
|
+
if (platform === 'win32') {
|
|
13
|
+
orcaPath = path.join(os.homedir(), 'AppData', 'Local', 'Programs', 'orca', 'resources', 'app.asar');
|
|
14
|
+
} else if (platform === 'darwin') {
|
|
15
|
+
orcaPath = '/Applications/Orca.app/Contents/Resources/app.asar';
|
|
16
|
+
} else {
|
|
17
|
+
orcaPath = '/opt/Orca/resources/app.asar';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!fs.existsSync(orcaPath)) {
|
|
21
|
+
console.error(`❌ 找不到 Orca 安裝路徑!(${orcaPath})`);
|
|
22
|
+
console.error('如果您的 Orca 安裝在其他位置,請手動替換 app.asar。');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const asar = require('@electron/asar');
|
|
27
|
+
const workDir = path.join(os.tmpdir(), 'orca-zh-tw-patcher');
|
|
28
|
+
const unpackedDir = path.join(workDir, 'app.asar.unpacked');
|
|
29
|
+
|
|
30
|
+
async function patch() {
|
|
31
|
+
try {
|
|
32
|
+
console.log('📦 1/5 正在備份官方 app.asar 並解包 (這可能需要數十秒)...');
|
|
33
|
+
fs.copyFileSync(orcaPath, orcaPath + '.bak');
|
|
34
|
+
|
|
35
|
+
if (fs.existsSync(workDir)) {
|
|
36
|
+
fs.rmSync(workDir, { recursive: true, force: true });
|
|
37
|
+
}
|
|
38
|
+
fs.mkdirSync(workDir, { recursive: true });
|
|
39
|
+
|
|
40
|
+
asar.extractAll(orcaPath, unpackedDir);
|
|
41
|
+
|
|
42
|
+
console.log('🛠️ 2/5 正在破解主程式 (main process) 語言限制...');
|
|
43
|
+
const mainFile = path.join(unpackedDir, 'out', 'main', 'index.js');
|
|
44
|
+
let mainCode = fs.readFileSync(mainFile, 'utf8');
|
|
45
|
+
|
|
46
|
+
// 注入常數
|
|
47
|
+
if (!mainCode.includes('UI_LANGUAGE_TRADITIONAL_CHINESE = "zh-TW"')) {
|
|
48
|
+
mainCode = mainCode.replace(
|
|
49
|
+
'const UI_LANGUAGE_CHINESE = "zh";',
|
|
50
|
+
'const UI_LANGUAGE_CHINESE = "zh";\nconst UI_LANGUAGE_TRADITIONAL_CHINESE = "zh-TW";'
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
// 注入白名單
|
|
54
|
+
if (mainCode.includes('UI_LANGUAGE_CHINESE') && !mainCode.includes('UI_LANGUAGE_TRADITIONAL_CHINESE,')) {
|
|
55
|
+
mainCode = mainCode.replace(
|
|
56
|
+
'UI_LANGUAGE_CHINESE,\n UI_LANGUAGE_KOREAN',
|
|
57
|
+
'UI_LANGUAGE_CHINESE,\n UI_LANGUAGE_TRADITIONAL_CHINESE,\n UI_LANGUAGE_KOREAN'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
fs.writeFileSync(mainFile, mainCode);
|
|
61
|
+
|
|
62
|
+
console.log('🛠️ 3/5 正在破解渲染器 (renderer process) 語言限制...');
|
|
63
|
+
const assetsDir = path.join(unpackedDir, 'out', 'renderer', 'assets');
|
|
64
|
+
const files = fs.readdirSync(assetsDir);
|
|
65
|
+
const i18nFile = files.find(f => f.startsWith('I18nProvider-') && f.endsWith('.js'));
|
|
66
|
+
|
|
67
|
+
if (!i18nFile) {
|
|
68
|
+
throw new Error('找不到 I18nProvider 檔案,Orca 可能已經大幅更改架構!');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const rendererPath = path.join(assetsDir, i18nFile);
|
|
72
|
+
let rendererCode = fs.readFileSync(rendererPath, 'utf8');
|
|
73
|
+
|
|
74
|
+
// 加入常數
|
|
75
|
+
if (!rendererCode.includes('UI_LANGUAGE_TRADITIONAL_CHINESE = "zh-TW"')) {
|
|
76
|
+
rendererCode = rendererCode.replace(
|
|
77
|
+
'const UI_LANGUAGE_CHINESE = "zh";',
|
|
78
|
+
'const UI_LANGUAGE_CHINESE = "zh";\nconst UI_LANGUAGE_TRADITIONAL_CHINESE = "zh-TW";'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
// 加入下拉選單
|
|
82
|
+
if (!rendererCode.includes('labelKey: "settings.appearance.language.traditionalChinese"')) {
|
|
83
|
+
rendererCode = rendererCode.replace(
|
|
84
|
+
'{ value: UI_LANGUAGE_CHINESE, labelKey: "settings.appearance.language.chinese" },',
|
|
85
|
+
'{ value: UI_LANGUAGE_CHINESE, labelKey: "settings.appearance.language.chinese" },\n { value: UI_LANGUAGE_TRADITIONAL_CHINESE, labelKey: "settings.appearance.language.traditionalChinese" },'
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
// 加入 Enum 白名單
|
|
89
|
+
if (!rendererCode.includes('UI_LANGUAGE_TRADITIONAL_CHINESE,') && rendererCode.includes('UI_LANGUAGE_VALUES =')) {
|
|
90
|
+
rendererCode = rendererCode.replace(
|
|
91
|
+
'UI_LANGUAGE_CHINESE,\n UI_LANGUAGE_KOREAN',
|
|
92
|
+
'UI_LANGUAGE_CHINESE,\n UI_LANGUAGE_TRADITIONAL_CHINESE,\n UI_LANGUAGE_KOREAN'
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
// 加入 Fallback 文字
|
|
96
|
+
if (!rendererCode.includes('[UI_LANGUAGE_TRADITIONAL_CHINESE]:')) {
|
|
97
|
+
rendererCode = rendererCode.replace(
|
|
98
|
+
'[UI_LANGUAGE_CHINESE]: "中文(简体)",',
|
|
99
|
+
'[UI_LANGUAGE_CHINESE]: "中文(简体)",\n [UI_LANGUAGE_TRADITIONAL_CHINESE]: "中文(繁體)",'
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
// 注入翻譯檔案 Loader
|
|
103
|
+
if (!rendererCode.includes('"zh-TW": () =>')) {
|
|
104
|
+
rendererCode = rendererCode.replace(
|
|
105
|
+
/ko: \(\) => __vitePreload\(\(\) => import\("\.\/ko-[a-zA-Z0-9_-]+\.js"\), [^,]+, import\.meta\.url\),/,
|
|
106
|
+
`$& \n "zh-TW": () => __vitePreload(() => import("./zh-TW-nested.js"), true ? [] : void 0, import.meta.url),`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
fs.writeFileSync(rendererPath, rendererCode);
|
|
110
|
+
|
|
111
|
+
console.log('📂 4/5 正在植入 11,000 句繁體中文翻譯字典包...');
|
|
112
|
+
const dictSource = path.join(__dirname, 'zh-TW-nested.js');
|
|
113
|
+
if (!fs.existsSync(dictSource)) {
|
|
114
|
+
throw new Error(`找不到字典檔:${dictSource}`);
|
|
115
|
+
}
|
|
116
|
+
fs.copyFileSync(dictSource, path.join(assetsDir, 'zh-TW-nested.js'));
|
|
117
|
+
|
|
118
|
+
console.log('🗜️ 5/5 正在重新打包 app.asar (這可能需要數十秒)...');
|
|
119
|
+
await asar.createPackage(unpackedDir, orcaPath);
|
|
120
|
+
|
|
121
|
+
// 清理
|
|
122
|
+
fs.rmSync(workDir, { recursive: true, force: true });
|
|
123
|
+
|
|
124
|
+
console.log('\n🎉 安裝成功!請完全關閉 Orca (右下角 Quit) 並重新啟動!');
|
|
125
|
+
console.log('然後前往 Settings -> Appearance -> Language 切換為「中文(繁體)」。\n');
|
|
126
|
+
|
|
127
|
+
} catch (err) {
|
|
128
|
+
console.error('\n❌ 安裝過程中發生錯誤:', err.message);
|
|
129
|
+
console.error('已經為您保留了原始的 app.asar.bak 備份檔。');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
patch();
|