日前安裝了 Ubuntu 12.04 後,在使用 ibus 裡的「倉頡五代輸入法」打字時發現似乎預設採用了簡體語系。於是爬文找了一下,原來這狀況在之前的版本裡已經存在了,便參考了這篇文章修改一下。
修改方法不難,使用任何一個編輯器開啟 /usr/share/ibus-table/engine/table.py 這個檔案,然後找到第 96 行到第 129 行這段:
96 # self._chinese_mode: the candidate filter mode,
97 # 0 is simplify Chinese
98 # 1 is traditional Chinese
99 # 2 is Big charset mode, but simplify Chinese first
100 # 3 is Big charset mode, but traditional Chinese first
101 # 4 is Big charset mode.
102 # we use LC_CTYPE or LANG to determine which one to use
103 self._chinese_mode = self._config.get_value (
104 self._config_section,
105 "ChineseMode",
106 self.get_chinese_mode())
107
108 def get_chinese_mode (self):
109 '''Use LC_CTYPE in your box to determine the _chinese_mode'''
110 try:
111 if os.environ.has_key('LC_CTYPE'):
112 __lc = os.environ['LC_CTYPE'].split('.')[0].lower()
113 else:
114 __lc = os.environ['LANG'].split('.')[0].lower()
115
116 if __lc.find('_cn') != -1:
117 return 0
118 # hk and tw is should use tc as default
119 elif __lc.find('_hk') != -1 or __lc.find('_tw') != -1\
120 or __lc.find('_mo') != -1:
121 return 1
122 else:
123 if self.db._is_chinese:
124 # if IME declare as Chinese IME
125 return 1
126 else:
127 return -1
128 except:
129 return -1 在 get_chinese_mode 裡會依 locale 的 LC_CTYPE 來判斷,但由於我將 LC_CTYPE 設定成 en_US.UTF-8,原本在第 125 行就會返回 0 這個值,但依據第 96 行到第 101 行的註解,當返回 0 時則採用簡體中文語系。
所以,修改方式就是將第 125 行的返回值改成 1,這麼一來就可以直接使它使用繁體中文語系了。
1 則留言:
這篇救了我... XD
感謝。
張貼留言