2007年10月8日星期一

Aspell引起的Leo不能启动问题

Leo是一个伟大的工具。我在Ubuntu 7.04上运行时出现了如下错误:

reading settings in /opt/leo/config/leoSettings.leo
reading /home/hero/.leoRecentFiles.txt
@enabled-plugins found in leoSettings.leo
rst3 plugin: SilverCity not loaded
err No word lists can be found for the language "zh_CN".
Traceback (most recent call last):
File "/opt/bin/leo", line 360, in
run()
File "/opt/bin/leo", line 125, in run
c,frame = createFrame(fileName)
File "/opt/bin/leo", line 192, in createFrame
c,frame = g.app.newLeoCommanderAndFrame(fileName=fileName,initEditCommanders=True)
File "/opt/leo/src/leoApp.py", line 575, in newLeoCommanderAndFrame
c.finishCreate(initEditCommanders)
File "/opt/leo/src/leoCommands.py", line 220, in finishCreate
c.frame.log.finishCreate()
File "/opt/leo/src/leoTkinterFrame.py", line 2081, in finishCreate
c.spellCommands.openSpellTab()
File "/opt/leo/src/leoEditCommands.py", line 7949, in openSpellTab
self.handler = spellTabHandler(c,tabName)
File "/opt/leo/src/leoEditCommands.py", line 8029, in __init__
self.loaded = self.init_aspell(c)
File "/opt/leo/src/leoEditCommands.py", line 8049, in init_aspell
self.aspell = AspellClass(c,dictionaryFileName,self.local_language_code)
File "/opt/leo/src/leoEditCommands.py", line 8333, in __init__
self.getAspellWithCtypes()
File "/opt/leo/src/leoEditCommands.py", line 8415, in getAspellWithCtypes
raise Exception('aspell checker not enabled')
Exception: aspell checker not enabled
那是因为 aspell 没有中文字典的缘故,稍作修改如下:
--- leoEditCommands.py.old      2007-09-15 19:41:04.000000000 +0800
+++ leoEditCommands.py 2007-10-06 21:08:08.000000000 +0800
@@ -8401,9 +8401,14 @@
print aspell_config_replace(sc, "lang",self.local_language_code)
print aspell_config_retrieve(sc, "lang")

+ # there is no chinese dictionary for aspell, so we replaced with english language
+ # aspell and aspell-en (dictionary) should be installed
+ if aspell_config_retrieve(sc, "lang") == "zh_CN":
+ aspell_config_replace(sc, "lang", "en")
+
possible_err = aspell.new_aspell_speller(sc)
aspell.delete_aspell_config(c_int(sc))
-
+
# Rudimentary error checking, needs more.
if aspell.aspell_error_number(possible_err) != 0:
print 'err', aspell_error_message(possible_err)
简单说就是把中文改成了英文,从而自动使用英文字典,当然,你得装有aspell和aspell-en (英文字典)。

不过我想更好的办法是可以在配置文件中设定。

没有评论: