translate / virtaal

Easy-to-use and powerful offline translation tool
https://virtaal.translatehouse.org
GNU General Public License v2.0
298 stars 57 forks source link

Finnish spell checking not working, ERROR:root:Could not initialize spell checking #1354

Open transl8bzimport opened 14 years ago

transl8bzimport commented 14 years ago

Originally posted by Ville-Pekka Vainio:

I'm using Virtaal on Fedora 12 and translating software from English to Finnish. The Finnish spell checking doesn't work with the Fedora package virtaal-0.5.1-1.fc12 or with yesterday's SVN checkout. I'm getting the following error:

ERROR:root:Could not initialize spell checking Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/virtaal/views/unitview.py", line 382, in _update_textview_language spell.set_language(language) RuntimeError: Error setting language

I understand the spell checking is working via PyEnchant, so I made a small test with Finnish on my system:

import enchant d = enchant.Dict("fi_FI") d.check("Testi") True d.check("Tseti") False d.suggest("Tseti") ['Testi']

("Testi" means test in Finnish)

So PyEnchant seems to work on it's own, but for some reason not with virtaal.

transl8bzimport commented 14 years ago

Originally posted by Ville-Pekka Vainio:

In the case of Finnish, the language variable passed to spell.set_language(language) seems to be "fi", but in http://pygtk.org/pygtkspell/class-gtkspell.html it is stated that language should be passed in the "fi_FI" (or "en_US" etc.) form. Manually passing "fi_FI" there makes spell checking work. I'm not familiar with the virtaal codebase, but I'll try to find out where the "fi" is set and how to get it changed to "fi_FI".

transl8bzimport commented 14 years ago

Originally posted by Ville-Pekka Vainio:

Created attachment 621

Set language when creating a Spell object

I noticed set_language() only accepts either "fi_FI" or "fi-FI" but not "fi" as the language code. Interestingly Spell() accepts "fi" too, so I made this patch, which sets the language when initializing the Spell() object. This is probably a bug in gtkspell, but worth a workaround in virtaal in my opinion.

friedelwolff commented 14 years ago

I tried to improve things a bit in SVN trunk with ideas from your patch (passing language already when we create the gtkspell.Spell. Now the language should always work on first use, but switching away from Finnish and back will still cause malfunction of voikko. We can leave this open if you want until it is entirely sorted out.

transl8bzimport commented 14 years ago

Originally posted by Ville-Pekka Vainio:

There seems to be two different issues here:

1) There can only be a single instance of libvoikko running, i.e. libvoikko isn't thread safe. This is because it previously used libmalaga, which isn't thread safe either http://voikko.sourceforge.net/architecture.html, but currently libvoikko has its own malaga implementation and libvoikko 3 should be thread safe once it's released http://voikko.sourceforge.net/contributing.html.

2) Calling gtkspell.Spell.set_language() with "fi" causes a RuntimeError, while "fi_FI" and "fi-FI" work. The gtkspell.Spell() constructor accepts also "fi" as an argument. I've filed bug https://sourceforge.net/tracker/index.php?func=detail&aid=2942898&group_id=7896&atid=107896.

friedelwolff commented 11 years ago

Is this still a problem with recent versions of all the relevant software components? I'm just wondering if Finnish spell checking is still a problem.