# 在 Windows 與 Ubuntu 24.04 安裝好用的中文輸入法
之前在 Ubuntu 20.04 用了很像新注音的 [Hime](https://hime-ime.github.io/)輸入法,感覺相當良好;無奈到了 22.04 以後,Hime 與系統的相容性就開始出現了一些問題,例如無法使用系統原本的 Terminal 等等,使得我開始尋找新的替代方案。
目前可以找到的最好方案,是使用 [fcitx5](https://github.com/fcitx/fcitx5) 輸入法框架搭配不同的輸入法。像是熟悉[新酷音](https://chewing.im/)輸入法的使用者,就可以安裝相應的輸入法。
目前我使用的是[RIME 中州韻](https://rime.im/)輸入法**引擎**。稱作引擎的原因,是 RIME 本身僅為輸入法的框架,可以驅動任何由使用者自定的輸入法;另外 RIME 的自定詞庫大小沒有上限,對於時常需要輸入物種名稱[^1]的我而言,可說是輸入法的最佳解。
## 在 Windows 中安裝中州韻輸入法引擎
Windows 版本的 RIME 稱作「小狼毫」,可以直接下載與安裝;使用者資料夾位於 `%APPDATA%Rime`。
## 在 Ubuntu 24.04 中安裝中州韻輸入法引擎
### 安裝輸入法
在終端機基本上可以完成所有的安裝:
```bash=
sudo apt install fcitx5 fcitx5-config-qt fcitx5-frontend-gtk4
sudo apt install fcitx5-rime
# 若要安裝新酷音輸入法則輸入下行
# sudo apt install fcitx5-chinese-addons fcitx5-chewing
```
安裝完之後,進行系統設定:
```bash=
sudo vi /etc/environment
```
要加入檔案中的內容如下:
```bash=
GTK_IM_MODULE=fcitx5
QT_IM_MODULE=fcitx5
XMODIFIERS=@im=fcitx5
```
最後就可以打開設定,把輸入法設為 fcitix5 了,或者:
```bash=
im-config -n fcitx5
```
最後可以在電腦的套件清單中找到 `fcitx5 configtool` 點進去設定,或者終端機輸入:
```bash=
fcitx5-configtool
```
把 Rime 加到輸入法當中就完成了。
Ubuntu 的 Rime 使用者資料夾位於 `~/.local/share/fcitx5/rime`
### 安裝輸入法配置
裝好 `fcitx5-rime` 後會發現,即使在 rime 的設定中把輸入法由漢語拼音(如朙月拼音)改為注音,依然無法用注音輸入,這是因為缺乏相關配置檔案的關係。可以利用中州韻的輸入法配置工具[東風破](https://github.com/rime/plum)來下載與管理。最簡單的使用法如下:
```{bash}=
cd ~/.local/share/fcitx5/rime
curl -fsSL https://raw.githubusercontent.com/rime/plum/master/rime-install | bash
```
這樣會下載與安裝所有的輸入法配置。
如果只想下載特定輸入法,例如[注音](https://github.com/rime/rime-bopomofo),可以從東風破的首頁連結進入該輸入法的頁面後,下載檔案放到 `/usr/share/rime-data/`。其他配置如顏色、候選詞數量可以參考[官方文件說明](https://github.com/rime/home/wiki/CustomizationGuide#%E4%B8%80%E4%BE%8B%E5%AE%9A%E8%A3%BD%E6%96%B9%E6%A1%88%E9%81%B8%E5%96%AE)。
最後別忘了要重新部署:
```{bash}=
fcitx-remote -r
```
在中洲韻輸入法中,按 `F4` 或者 `Ctrl + ~` 快速鍵可以喚出輸入法的選單列。
若覺得候選輸入法太多,可以編輯設定檔:
```{bash}=
vi ~/.local/share/fcitx5/rime/default.custom.yaml
```
檔案內容如下(以僅保留正體中文_注音輸入法為例):
```
patch:
schema_list:
- schema: bopomofo_tw
```
另外可能會遇到輸入的字並非教育部指定用字的情形,這時需要修改 `/usr/share/opencc/t2tw.json` 檔案為以下內容(原因參考[此篇](https://blog.pulipuli.info/2022/04/fixing-the-problem-of-opencc-issues-when-typing-with-bopomofotw-of-fcitx-rime.html#postcata_2022_04_fixing-the-problem-of-opencc-issues-when-typing-with-bopomofotw-of-fcitx-rime.html0_anchor3)):
```{json}
{
"name": "Traditional Chinese to Traditional Chinese (Taiwan standard)",
"segmentation": {
"type": "mmseg",
"dict": {
"type": "ocd2",
"file": "TWVariants.ocd2"
}
},
"conversion_chain": [
{
"dict": {
"type": "ocd2",
"file": "TWVariantsRevPhrases.ocd2"
}
},{
"dict": {
"type": "ocd2",
"file": "TWVariants.ocd2"
}
}]
}
```
## 中州韻輸入法引擎的詞庫與設定
前面提過,中州韻輸入法引擎的最大特點在於可自定空間很大,從外觀、輸入法到詞庫都可以自行設定與調整,在此僅介紹詞庫的部分。
### 詞庫檔案的結構
下圖是中州韻輸入法引擎的詞庫結構圖,可以看到所有的字典都是透過主字典來指定的。
```mermaid
graph TD
Search[[Rime 輸入法引擎]]
Main{{主字典}}
A([字典 A])
B([字典 B])
C([字典 C])
Search === Main
Main --> A
Main --> B
Main --> C
```
在操作上,我習慣在使用者資料夾中新建一個 `dicts` 資料夾存放所有字典,而主字典則置於使用者資料夾當中。
### 建立詞庫檔案
首先進到使用者資料夾,建立好 `dicts` 資料夾。
接下來,建立主字典檔案,檔案後綴為 .dict.yaml,內容如下:
```yaml=
---
name: bopomofoMainDict #字典名稱
version: #版本
sort: by_weight
use_preset_vocabulary: true # 是否導入預設詞彙
import_tables:
- terra_pinyin
- dicts/字典A
- dicts/字典B
- dicts/字典A
...
# 以下也可以加入自己的詞
苔蘚 tai2 xian3
```
注意中文與拼音之間使用 tab 區隔,其餘縮排均使用兩個空白。可以把上方內容複製到自己的檔案中修改。
新增完詞庫之後,Windows 用戶要到工作列的小狼毫圖示按滑鼠右鍵,點選「重新部署」後等待一小段時間;Ubuntu 用戶如果沒有找到相應的重新部署選項,可以直接把 fcitx5 關掉重開,或者鍵入 `fcitx5-remote -r` 指令。
目前 RIME 的詞庫多以簡體中文為主;正體中文的詞庫主要有[洋蔥方案](https://github.com/oniondelta/Onion_Rime_Files)以及[洋蔥純注音修改版](https://github.com/sunsun8170/Onion-Rime-Bopomo-Revised);生物名詞部分可以參考 [Gavin987/ BopomoforTerminologies](https://github.com/Gavin987/BopomoforTerminologies/tree/main/RIME_pinyin)。
中州韻輸入法引擎的彈性,讓使用者可以依自己的需求,逐步打磨出屬於自己獨一無二的輸入法,其他使用者也持續貢獻詞庫檔案,大幅提升打字效率。相當推薦這個輸入法,也希望更多人貢獻詞庫,用集體智慧打造更美好的輸入環境。
<span style="font-size:30px">🐕🦺</span><font color="dcdcdc">2025.08.07</font>
#### 參考文章
1. [RIME.TW 使用者指南](https://rimetw.gitbooks.io/rime/content/)
2. [Ubuntu 安裝 Fcitx5 注音輸入,並解決無法在瀏覽器切換輸入法的問題](https://blog.alpaca.tw/posts/ubuntu-fcitx5-chewing-input-method/)
3. [在 Debian 上透過 Fcitx 5 使用中州韻輸入法引擎](https://blog.fernvenue.com/zh/archives/configure-fcitx5-and-rime-on-debian/)
4. [Ubuntu繁體中文輸入法?改用Fcitx5來輸入中文吧!](https://ivonblog.com/posts/ubuntu-fcitx5/)
5. [中州韻輸入法引擎](http://note.zn2.us/rime.htm?fbclid=IwAR1HcvHvCVm90dKTmn1eFodO_zwlOHmRqUqVPmTCAosY_fDG7jXczcafJ5I)
[^1]: 根據臺灣物種名錄網站,目前臺灣總共有 65,009 種生物(資料時間 2025.08.05)。