Plugin for Pidgin

From Apertium
Jump to: navigation, search

Contents

[edit] Description

When enabled, this plugin keeps track of the user's language preferences for each of their buddies (both incoming and outgoing messages). If the user has set the language pair eng-spa (English → Spanish) for incoming messages from buddy1, then the plugin will attempt to tranlate all incoming messages from buddy1 to Spanish (assuming they will be in English).

The translating is done by an Apy that may run locally or on a remote location (its address can be set from within the plugin).

The plugin is able to use several Apy instances, as it stores an ordered Apy list. The first Apy in the list takes priority when the plugin needs to make a request to an Apy. If the first Apy is unreachable or unable to give an answer, the plugin will attempt to make the same request to the second Apy in the list, and so on.

[edit] Installing the plugin

[edit] Requirements

  • libpurple. The library containing all the development sources and headers needed for Pidgin Plugins, as well as some example plugins to help new developers get started. You can get a pidgin .tar file with libpurple here (don't forget to ./configure and make it, as explained in this tutorial ).
Alternatively, you can install the pidgin-dev package.
  • glib2.0. Install package libglib2.0
  • Python. Install package python-dev
  • Apy(Optional). Only needed if you intend to run your own Apy in your machine.

[edit] Compilation and installation

The code can be downloaded here.

You can get a copy of the code with

git clone https://github.com/Sbalbp/Pidgin_Translator_Plugin.git

which will create a local Pidgin_Translator_Plugin directory. Now enter this directory and run

./updateSub

This will attempt to retrieve the latest version of the Apertium_Plugin_Utils submodule, a Python module which is necessary for the plugin to work. Since this script always tries to get the latest updates on the submodule, it can be used to keep it up to date.

Now that you have the Python module, you might want to install it. First enter the submodule directory

cd Apertium_Plugin_Utils

and install the module. You can opt for a global installation with

sudo python setup.py install

Alternatively, you can install the module to a chosen directory (prefix installation). To do this run the following

python setup.py install --prefix=route/to/module

don't forget to use your own custom route to install the module there. After that, a new directory tree containing the Python module will be created. You still need to tell Python to look for the module in this new directory, so you will have to add its route to your PYTHONPATH environment variable:

export PYTHONPATH=route/to/module/lib/pythonX.Y/site-packages:$PYTHONPATH

don't forget to add the whole route up to the site-packages directory (included). You can also edit your .profile/.bash_profile/.login file to add the above line so that the route is added to the PYTHONPATH automatically when you log in (therefore, you won't have to manually edit it every time).

You can refer to this documentation for other different installing alternatives.

Now, to compile the plugin, go back to the main repository directory and run

./autogen.sh

which will generate the Makefile. It will also attempt to find out what your installed version of python is and change the Makefile accordingly. It is assumed by default that your python version is 2.7.

Now run

make

and the plugin (.so file) will be directly installed to the directory where Pidgin expects it to be (~/.purple/plugins).

It will also generate the documentation in the doc folder.

Lastly, in order to use the plugin, you must first activate it in Pidgin. From the Pidgin plugin installation page: You can manage available plugins by accessing the "Tools" menu from the Buddy List window and selecting "Plugins.". This plugin will be listed as 'Message Translator'. If there was an error during plugin load, an error would be thrown.

[edit] Plugin commands

The following commands are available in for use:

  • /apertium_apy position address Inserts an Apy address at the given position of the Apy list. If no arguments are passed, it just shows the list of addresses. If the address argument is omitted, the address at the given position is shown.
For example, if the Apy list looks like [address1, address2, address3] and we issue the command /apertium_apy 1 http://localhost 2737, it will insert the address http://localhost:2737 to the Apy list in the position number 1, pushing back ay other Apy, which results in the following Apy list: [address1, http://localhost:2737, address2, address3]. This means that the new address wil take priority over address2 and address3 when issuing a command that makes a request to an Apy, but it will always be asked after address1.
The default list only address is http://localhost:2737. The address http://apy.projectjj.com can be added to the list. This address, however, is not guaranteed to work 100% of the times, as it is still in test stage.
  • /apertium_apyremove position Removes the Apy address located at the given position in the Apy list.
  • /apertium_check Shows the current language pairs associated with the buddy whose conversation you issued the command on.
  • /apertium_pairs Ask the Apy which language pairs are available and shows them.
  • /apertium_bind direction source target Sets a language pair for the buddy whose conversation the command was issued on. direction must be either 'incoming' (for incoming messages) or 'outgoing' (for messages sent to that buddy). source and target are the source and target languages of the language pair to be set, respectively.
  • /apertium_unbind direction Delete language pair data for the buddy whose conversation the command was issued on. direction is an optional argument. If present, it must be either 'incoming' or 'outgoing', to delete the language pair bindings for incoming or outgoing messages, respectively. If omitted, all language pair bindings are deleted.
  • /apertium_display displayMode Selects how the messages should be displayed. displayMode (optional) can be 'both' (the translation and the original message are both displayed), 'translation' (only the translated message is displayed) or 'compressed' (both the translation and the original message are shown, in a compressed 2-line way). If no argument is passed, the current display mode is shown. The default display mode is 'compressed'.
  • /apertium_infodisplay infoDisplayMode Sets how the information messages should be shown. infoDisplayMode must be 'dialog' (information will be displayed in a new pop-up window), 'print' (information will be printed to the current conversation) or 'none' (no information will be displayed).
  • /apertium_errors switch Turns on/off the error notifications from the plugin. switch must be either 'on' (enable notifications) or 'off' (disable notifications).
Personal tools