Google Translator

Google Translator is a simple Plasmoid created using PyQt and PyKDE4 that lets you translate sentences using the Google Translate web service.

UPDATE
Google is shutting down their Translate API come December and they have already started to require a REFERER in the request. I would have to make quite a lot of changes to make it work just for the rest of November, so the Google Translator Plasmoid is officially discontinued.

https://code.google.com/apis/language/translate/overview.html

Google Translator 0.5

Google Translator 0.5

 

 

Google Translator tooltip

Features

  • Simpler, more intuitive (IMHO) and smaller than the Translatiod Plasmoid (some might not see this as a feature :-)
  • Select to and/or from language(s) from the dropdown lists and the translated sentence will be updated in realtime.
  • Change the sentence to be translated and click on the “Go” nutton and the translated result will be updated.
  • Selected languages and text is saved between sessions.
  • Selected languages can be swapped easily.
  • Auto-detect language.
  • Docks in the Panel or on the Desktop.

Dependencies

Because I have only tried the Plasmoid on my own computer you may be able to use earlier versions.

  • python-kde4 v. 4.5.1
  • python-qt4 v. 4.7.2
  • python-simplejson
  • plasma-scriptengine-python v. 4.4.4

Installation

Download the newest version.


plasmapkg -i ./google-translator-<version>.plasmoid

If the Plasmoid is already installed you might have to run:

plasmapkg -u ./google-translator-<version>.plasmoid

From source code

Follow the instruction to download with svn.

Change to the currency-converter-plasmoid/currency-converter directory and issue the following commands:

zip -r ../google-translator.plasmoid .
cd ..

And then continue by following the instructions on KDE UserBase.

Or add it from:
“Add Widgets”=>”Get New Widgets”=>”Download New Plasma Widgets”

Known Issues

As the Plasmoid gets its language codes from KLocale in kdelibs you will probably get the “invalid translation language pair” message more often than in the web based Google Translate and there maybe languages missing that Google Translate supports.

Changelog

Built on the KDE Platform

-<version>

28 Responses to “Google Translator”

  1. Dmitry Says:

    Can’t install(
    neither from kde-look, not from your site
    just plasma restarting((
    all needed packages are installed

  2. Chris Says:

    Hi!

    I get this error when running your widget:

    setup_network: 0
    Traceback (most recent call last):
    File “/usr/share/kde4/apps/plasma_scriptengine_python/pyappletscript.py”, line 55, in init
    self.pyapplet.init()
    File “/home/cbourque/.kde4/share/apps/plasma/plasmoids/google-translator/contents/code/main.py”, line 62, in init
    self.setup_network()
    File “/home/cbourque/.kde4/share/apps/plasma/plasmoids/google-translator/contents/code/main.py”, line 285, in setup_network
    notifier = Solid.Networking.notifier()
    AttributeError: type object ‘Networking’ has no attribute ‘notifier’

    Any idea?

    Thanks

    • tanghus Says:

      Which version of KDE SC are you using? I need to update this page because now I use KDE SC 4.4.4 and maybe the Python binding have improved there.

  3. Hector Says:

    I’m using KDE 4.4.5, and the widget doesn’ work. I got a “Script initialization failed”…

    • tanghus Says:

      Can you try to run it view plasmoidviewer from Konsole and check the output?

      plasmoidviewer google-translator

      • Hector Says:

        Hi tanghus, the output of the script is different than the Zefiryn output.

        Traceback (most recent call last):
        File “/usr/share/apps/plasma_scriptengine_python/pyappletscript.py”, line 59, in init
        self.module = __import__(self.pluginName+’.’+relpath)
        File “/usr/share/apps/plasma_scriptengine_python/plasma_importer.py”, line 107, in load_module
        exec code in mod.__dict__
        File “/home/hector/.kde4/share/apps/plasma/plasmoids/google-translator/contents/code/main.py”, line 33, in
        from GoogleTranslator import GoogleTranslator
        File “/usr/share/apps/plasma_scriptengine_python/plasma_importer.py”, line 107, in load_module
        exec code in mod.__dict__
        File “/home/hector/.kde4/share/apps/plasma/plasmoids/google-translator/contents/code/GoogleTranslator.py”, line 33, in
        import os, simplejson
        ImportError: No module named simplejson
        TypeError: invalid result type from PythonAppletScript.shape()
        TypeError: invalid result type from PythonAppletScript.shape()

        I’m using Gentoo 10.1.

      • tanghus Says:

        Hector:
        Please read on this page the section “Dependencies” which says “python-simplejson”.

        You need to install the Python module simplejson. It depends on your distribution how you install it. In a debian-derivate (*ubuntu etc.) you should run:

        sudo apt-get install python-simplejson

  4. Zefiryn Says:

    I have the same problem. The output from the plasmoidviewer is:

    GoogleTranslatorApplet: init().
    init() in BasePlasmoid
    Name: Google Translator
    Description: Translate short sentences using Google Translate
    Version: 0.6
    Category: Language
    Author: Thomas Olsen
    Plugin name: google-translator
    Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
    NetworkMonitor: 1
    NetworkMonitor: Connected to network notifier.
    NetworkMonitor: Network is connected: False
    NetworkMonitor: Current status: Unknown
    GoogleTranslatorApplet: Creating main widget.
    GoogleTranslator: init
    missing new-style support for KIO.Job.result
    GoogleTranslator: init. Done
    Traceback (most recent call last):
    File “/usr/share/apps/plasma_scriptengine_python/pyappletscript.py”, line 75, in init
    self.pyapplet.init()
    File “/home/zefiryn/.kde4/share/apps/plasma/plasmoids/google-translator/contents/code/main.py”, line 66, in init
    self.setGraphicsWidget(self._widget)
    File “/usr/lib/python2.6/site-packages/PyKDE4/plasmascript.py”, line 49, in __getattr__
    return getattr(self.applet, key)
    AttributeError: ‘Applet’ object has no attribute ‘setGraphicsWidget’

    I’m using Mandriva 2010.1 with KDE 4.4.3,
    python-kde4 v. 4.4.3
    python-qt4 v. 4.7.3
    python-simplejson-2.1.1
    plasma-scriptengine-python v. 4.4.3 (in Mandriva this package is a part of kdebase4-workspace)

    I suppose that the problem is python-kde4 package. There must be some change in kde 4.5

    • tanghus Says:

      Yes, though I guess it’s the plasma-scriptengine-python that has to be at least 4.5. Guess it’s time to upgrade your KDE ;-)

      • Zefiryn Says:

        The problem is Mandriva haven’t made KDE 4.5 packages yet and I’m rather reluctant to upgrading from KDE packages since there may be some differences and I have just reinstalled the system, so it is clean. If there will be no update by MDV I try updating KDE myself.

        For the time being, tomorrow I’ll try updating just scriptengine to 4.5

        By the way. I’ve tried 0.5.1 version and the widget couldn’t establish internet connection.

      • tanghus Says:

        Hmm. Two bad that there are no newer packages.

        About 0.5.1 not being able to connect it’s actually an error in Solid on some distributions where it reported network connection as ‘Unknown’ even though there was a connection. There’s a small workaround in 0.6.

      • Zefiryn Says:

        Solid fix worked.
        Those who, like me, wait for a KDE update in their distro may download this fix. I hope it wouldn’t be inappropriate if I use original package. I renamed it to google-translator-0.5.1.1 since it is small fix.
        The plasmoid is here: http://wierzba.wzks.uj.edu.pl/~08_jewula/pliki/google-translator-0.5.1.1.plasmoid

  5. Mohn Says:

    Hello!
    Not work. “Script initialization failed”

    QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: Нет такого файла или каталога
    QFileSystemWatcher: failed to add paths: /home/mohn/.config/ibus/bus
    Bus::open: Can not get ibus-daemon’s address.
    IBusInputContext::createInputContext: no connection to ibus-daemon
    plasmoidviewer(2560)/kdecore (services) KServiceFactory::findServiceByDesktopPath: “” not found
    GoogleTranslatorApplet: init().
    init() in BasePlasmoid
    Name: Google Translator
    Description: Translate short sentences using Google Translate
    Version: 0.6
    Category: Language
    Author: Thomas Olsen
    Plugin name: google-translator
    Updating from version ’0.0.0′ to ’0.6′
    google-translator icon installed
    Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
    NetworkMonitor: 1
    NetworkMonitor: Connected to network notifier.
    NetworkMonitor: Network is connected: True
    NetworkMonitor: Current status: Connected
    GoogleTranslatorApplet: Creating main widget.
    GoogleTranslator: init
    GoogleTranslator: init. Done
    Traceback (most recent call last):
    File “/usr/share/kde4/apps/plasma_scriptengine_python/pyappletscript.py”, line 75, in init
    self.pyapplet.init()
    File “/home/mohn/.kde/share/apps/plasma/plasmoids/google-translator/contents/code/main.py”, line 66, in init
    self.setGraphicsWidget(self._widget)
    File “/usr/lib/pymodules/python2.6/PyKDE4/plasmascript.py”, line 49, in __getattr__
    return getattr(self.applet, key)
    AttributeError: ‘Applet’ object has no attribute ‘setGraphicsWidget’
    job_done

  6. Gerold Neuwirt (@gemane) Says:

    I’m sometimes getting the message “Waiting for network connection” on my kubuntu netbook system, although I am not doing anything with the Google Translator. There should be no message at all, as long as I am not searching for new translations.

    • tanghus Says:

      Hi Gerold
      You can disable the notification by going to ‘System Settings’/’Application And System Notifications’, select ‘Google Translator Plasma Widget’ from the dropdown list, select ‘Waiting for Network’ and remove the check mark from ‘Show a message in a popup’.
      The notification should only be triggered if you loose your network connection. If you are on eg. a mobile network connection this can happen and the best solution is as described above.
      For now this is the default behavior as I share base classes with all the Plasma Widgets I’ve made and this behavior is in the base class.

  7. Martin Says:

    Hi, I really love this – but now I’m using KDE 4.6.5 on OpenSUSE 11.4, all I get is “Unknown translation error!”. This applies both with Welsh (which is my main usage) and also more “mainstream” languages.

    • tanghus Says:

      Yeah, I should have mentioned. Google is closing down their translation API so the Google Translator Plasmoid is discontinued. The Translatoid Plasmoid (can be found at http://kde-look.org) still works for now.
      I will see if I can make a new Plasmoid using another translation engine, but it will take some time.

      Sorry for the inconvenience.

      • Martin Says:

        Don’t apologise, not your fault! Thanks for all your work.

      • GREY_FOX Says:

        Hi,
        i think is possible to use google translator without API also. If you see querys are sent by a simple url scheme and result is displayed in a div called result_box ;)

  8. marten Says:

    Kurcze niestety Was nie rozumiem ;( ale jeśli jesteście niemcami, to bardzo nie dobrze! yyy gdzie ten granat?

    • tanghus Says:

      Sorry, but I don’t understand your question, and Google Translate doesn’t make much sense of if.

      The Google Translator Plasmoid has been discontinued and will no longer be updated.

  9. Bohdan Says:

    I live in Ukraine. I am looking for a translator for your Kubuntu (KDE 4.8.4). Google Translator – the best. But when the description of the commands in the terminal you get an answer – No such file or directory.
    Help me solve this problem.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: