Integrated translations in Linux desktop - doable?

Updated: March 18, 2020

Here's an interesting problem slash scenario for you. The Gnome and Plasma desktop environments support online account integration to some extent. Fine. You also have fairly powerful, online-aware search tools, which let you do all sorts of complex actions, including wiki queries, mathematical calculations, application functions, and more. Krunner in Plasma is a great example.

But then, you don't really get translations. If you work with several languages and you have a need for occasional linguistic sparring, this option doesn't really feature highly in Linux desktops. Or at all. Combine that with the healthy fact you have no integrated assistants (Siri, Cortana, Alexa, whatnot) that could potentially do this for you, translations are something you must either: a) do online yourself b) use a dedicated app. So I thought, is there an easy way to integrate this kind of functionality into the Linux desktop, Plasma and/or Gnome? Well, let's find out.

Gnome: Text Translator

I was pleasantly surprised to find out there is a Gnome extension, yay! Well, it took me a little while finding the "right" one, as there are several entries, including placeholders for translations for the translator, inception lulza, plus a 404 page and then the real one, Text Translator. The one I want and need.

As a first attempt, I tried Fedora 31, as it ships with the latest Gnome 3 framework, so it ought to have the most relevant results, methinks. Unfortunately, the installation did not work. I had a red ERROR message, and then I had to dig into the system logs (with journalctl no less):

tester org.gnome.Shell.desktop[9253]: extracting: /home/roger/.local/share/gnome-shell/extensions/
text_translator@xxxx.gmail.com/metadata.json
tester gnome-shell[9253]: Extension "text_translator@xxxx.gmail.com" had error: TypeError: this._construct is not a function

I've redacted the author's email from the error. Anyway, apparently, the extension needs to be rewritten to work with the latest Gnome version. Now, the extension also requires a command-line translator package named translate-shell to be installed. This is available in Fedora repos, so there were no issues getting this - but having this does not help in any way get past the error above.

sudo dnf search translate-shell
Last metadata expiration check: 0:09:13 ago on Thu 11 Feb 2020 03:07:49 PM.
========== Name Exactly Matched: translate-shell==========
translate-shell.noarch : A command-line online translator

I decided to try CentOS 7 next, which sounds like a cool plan. I have it all configured minty and whatnot, and I thought I'd have more success there (we will talk about CentOS 8 separately). Well, if Gnome 3 in Fedora 31 is too modern, then the version available in this server-cum-desktop distro is too old. Errors of a different kind, and no translate-shell package in the repos. So this was a no-go unfortunately ...

Plasma: Krunner Translator

With KDE, the name of the game is Krunner Translator, and it does require that you do some compilation yourself at the moment, somewhat similar to what I've shown you when we did the Unity transformation with the panel-integrated window buttons. Sounds all right. Well. I started running the commands, as instructed, and then I hit the following error:

CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find KF5 (missing: Runner) (found version "5.60.0")
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/share/ECM/find-modules/FindKF5.cmake:110 (find_package_handle_standard_args)
CMakeLists.txt:12 (find_package)

I already had the extra-cmake-modules package, and the GitHub page does not state which development packages you need for this. I spent a while guessing, reading, and then decided to grab the ENTIRE development framework for plasma 5.16 - which is what I had on the specific test system. This was a bit mental, as I ended up with almost 2 GB worth of packages! But it did help with the compilation, oh yes it did.

Dev packages

cmake .. -DCMAKE_INSTALL_PREFIX=`kf5-config --prefix` -DKDE_INSTALL_QTPLUGINDIR=`kf5-config --qt-plugins`
-- Found KF5Runner: /usr/lib/x86_64-linux-gnu/cmake/KF5Runner/KF5RunnerConfig.cmake (found version "5.60.0")
-- Found KF5: success (found version "5.60.0") found components: I18n Service Runner TextWidgets ConfigWidgets PlasmaQuick
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - found
-- Performing Test _OFFT_IS_64BIT
-- Performing Test _OFFT_IS_64BIT - Success
-- Performing Test HAVE_DATE_TIME
-- Performing Test HAVE_DATE_TIME - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rogerino/GitHubs/krunner-translator/build

Once this step was done, I installed the plugin, restarted Krunner, and lo and behold, Translator was available as a plugin in the Krunner settings menu. And you can tweak it, including the use of different translation backends. You can use Yandex and Glosbe backends for translations. If you were expecting something else, well, those options aren't there. But when it comes to foreignese, in fact you do want translation software from countries where English is not the first language, because most non-native English speakers have a better affinity for languages and translations, and this shows in relevant products. Having used different translation engines, I do find the Yandex one to be quite good.

Plugin available

Settings

Alas, while I could actually make changes to the settings, the translator itself did not run. I tried the sample commands and whatnot, and Krunner simply had nothing to display. I guess this is another no-go. But at least we get a consistent behavior across desktops, so at least that's comforting.

Not working

Conclusion

I was quite perked up going into this adventure and somewhat rather dejected coming out of it. I am quite dismayed that neither my Gnome nor my KDE experiment worked out. Both failed, in slightly different ways. Moreover, even if the actual steps had taken me to success, the Plasma Krunner plugin setup is difficult in particular. Although for Gnome users, if you don't have Gnome Tweak Tool and aren't that savvy, you won't get far either. But as it turns out, these endeavors are still not ready for general use, and I guess there's a reason why.

There are other problems still in the implementation, hurdles that make instant usage quite difficult. Perhaps there's no real need for this, and it's a nice-to-have academic usecase, and I'm entirely mistaken in the value of something like an integrated desktop translator. And academic it remains for sure, because you probably won't have more success than I did getting the plugins running. I'm not happy to end an article on a negative note, but then, this failure is a valuable lesson, too. The Linux desktop has never quite made it when it comes to online presence, and this is a good example. Maybe one day. Maybe. For now, if you want to play with foreignese, it will have to the old methods. Or the new ones. Hey Tux, how do you say Cheers in Linux?

Cheers.