translate / virtaal

Easy-to-use and powerful offline translation tool

Home Page:https://virtaal.translatehouse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It is not possible to configure the spell check

mbouzada opened this issue · comments

In Debian 9 and Ubuntu 18.4, to work in Galician, having installed the indicated in https://virtaal.readthedocs.io/en/latest/spell_checking.html
including the hunspell package, it is not possible to activate the spellchecker in Edit → Preferences → Addons

Works for me in Arch Linux. Was the package built with spellchecking support? Could you run Virtaal from command line e see if any helping error message is displayed?

Please enter in Python 2 interactive console (run python or python2 in the terminal), then type import gtkspell and hit Enter to see if it successfully imports the library. Let me know if no error message is displayed, or, if displayed, paste it in here.

I realized something: Arch Linux builds Python2's version of pygtkspellcheck setting the GTKSPELL=true parameter (see build rules for this package in Arch) which adds the file gtkspell.py (and other compiled files) to the resulting package (see the package's file list in Arch). This enables the exact library I asked you to try to import.

The python-gtkspellcheck package on Debian and Ubuntu, however, doesn't seem to have this gtkspell.py file included in the package's file list and in no other package as far as I can tell. That's probably the reason why you are unable to successfully import gtkspell.

In order to include gtkspell library to the resulting python-gtkspellcheck package it only takes a GTKSPELL=true parameter added to ./setup.py line when building the package, as can be seen from the upstream's source code.

Can you file a bug report against python-gtkspellcheck from Debian and Ubuntu requesting them to add GTKSPELL=true parameter?

The upstream source code release that's used in Debian, which was downloaded from https://pypi.org/project/pygtkspellcheck/#files, doesn't include the gtkspell.py module (presumably the upstream developer built their sdist tarball without specifically enabling the gtkspell module). That module appears to only be available from the upstream git repository.

It seems to be a deprecated wrapper to emulate an older PyGTK API.

I suspect virtaal's spellchecker plugin should use gtkspellchecker directly, instead of going via gtkspell (there's hardly any code in the gtkspell.py wrapper). This is a necessary step if virtaal is ever going to move to Python 3, because the gtkspell module is not available for Python 3.

The gtkspell module was already described as a "legacy API" in the commit that added it to gtkspellcheck in 2012, so it seems to be going quite far back into technical debt.

Well, then I guess some kind of workaround have to be done in order to run Virtaal with spellchecking in this scenario. Here are the options that come to me right now:

  • Get source package for the python-gtkspellcheck from the desired distribution (e.g. Debian, Ubuntu 18.04 "bionic") and use the upstream tarball from https://github.com/koehlma/pygtkspellcheck/releases/tag/4.0.5, adding somehow GTKSPELL=true to ./configure and adjusting what is needed.
  • Copy gtkspell.py, gtkspell.pyc and gtkspell.pyo from somewhere else to your system. (e.g. download Arch Linux package, extract, copy the file to the proper place in your system.) However, I have no idea if this works at all.

Or change the spellchecker plugin so that instead of trying to use pygtkspellcheck via gtkspell, it calls into pygtkspellcheck directly? gtkspell is a very thin wrapper around pygtkspellcheck: it doesn't add any new functionality.

Indeed, @smcv. It only takes a Pull Request and an active admin (which I am not) to approve and merge.

@friedelwolff This is important. Can you speed up this? Thanks in advance.

BTW people, it would be much easier to get the fix landed if you actually propose it as a pull request.

Thank you for reporting this. I believe basic functionality will be possible through pygtkspellcheck without changes to Virtaal. I think I got pygtkspellcheck pretending to be python-gtkspell to work a long while ago already. I didn't commit it, because of some outstanding issues:

If I remember correctly the performance of pygtkspellcheck is pretty bad. I started with some optimisation work on pygtkspellcheck and pyenchant, but I never finished it. Additionally, we should reconsider our current handling of the popup, etc.

If I remember correctly I even considered reimplementing pygtkspellcheck in Virtaal to get exactly the right behaviour (we can do some nice things if we are in control), but obviously I have not had the time to pursue even simpler solutions.

Please report on how your testing with pygtkspellcheck went if you can install it with GTKSPELL=true.

@friedelwolff
I could not run ./configure, therefore I could not do the test

@friedelwolff, I have gtkspell enabled in my Arch, as mentioned in this comment. What information should I provide you and where (here or another issue, to not hijack this thread) ?

@rffontenelle It seems that you gave all the required information, thank you. It is good to know that pygtkspell can be a drop-in substitute for python-gtkspell. Now we need to lobby distributions to package it that way. For me on Mageia, python-gtkspell still works fine, though, so I'm not sure what went wrong in the last few years. Sorry that I haven't had more time for maintenance on Virtaal recently!