This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Tools & Utilities

Language translation from the command line or clipboard

By Ben Martin on April 04, 2008 (9:00:00 AM)

Share    Print    Comments   

Web-based automatic translators such as translate.google.com are great for getting the gist of what a document is saying, but it can be cumbersome to have to open a new tab in your browser, load that URL, and copy and paste the text you want to translate into your browser. The twandgtw project allows you to get language translations directly from the Linux command line using either local dictionaries or online services.

Binary packages are available for Fedora 7 and 8. Other distributions have to follow the normal configure; make; sudo make install procedure to install from source.

As the project name suggests, twandgtw is actually two programs. tw is a non-graphical command-line word translator, while gtw has a graphical interface. To use tw to translate a word from English into Spanish, for example, specify a dictionary name and a word:

$ tw en-es hello hello : hola

The gtw tool, shown in the figure, uses the GTK+ toolkit to present a graphical interface with similar functionality to the tw command line tool.

While the local dictionaries can only handle translating a single word at a time, you can feed online services a whole phrase at a time for translation. tw supports both www.freetranslation.com and translate.google.com for online translations. To translate a phrase you must pass it as a single argument to tw and a Web service:

$ tw translate.google.com.en-fr 'that looks like a tasty cake' Qui ressemble à un gâteau savoureux

If you are a KDE3 user and you want to translate phrases frequently, a great place to gain access to this functionality is from the clipboard, with klipper. You can add translation as an action that klipper can perform for you, so you can translate text from any application. In the Configure Klipper window, under the Actions tab, create a regular expression with ^. as its contents. Right-click the regular expression and select Add Command. Set the command to kdialog --passivepopup "$(tw translate.google.com.en-fr "%s")" and give a description to the item. See the Global Shortcuts tab for the key to activate the "Manually Invoke Action on Current Clipboard" action. It can be handy to bind this action to a mouse button, especially if your mouse has five or more buttons.

Now you should be able to select a phrase and invoke a translation on it directly from the clipboard. The translated text will appear in a passive popup window that will close itself after 10 seconds. See this tutorial for other options for kdialog.

Having tw installed can make translating a phrase quick and easy by avoiding having to use a Web browser for the task. Since it's a command-line tool, it's also easy to integrate tw into other applications. And if you have a clipboard manager like klipper running, you can integrate the task of translation as an action you can perform on any text in the clipboard.

Ben Martin has been working on filesystems for more than 10 years. He completed his Ph.D. and now offers consulting services focused on libferris, filesystems, and search solutions.

Share    Print    Comments   

Comments

on Language translation from the command line or clipboard

Note: Comments are owned by the poster. We are not responsible for their content.

Language translation from the command line or clipboard

Posted by: akbar on April 04, 2008 11:17 AM
Accurate translation of data by careful understanding of the context is not an easy job. Many organizations hire language translation service companies, known for quality translated service as consultants or on contract basis to meet the need of the hour.
Language breakdowns resulting from poorly translated documents can be costly to a business. These sorts of breakdowns can jeopardize the customer relationship and the identity of the company. If there is a linguistic communication barrier, you should get professional language translation service to make sure your message is understood. Translation, or interpreting the meaning of a text, communicates the same general message in another nomenclature. The translated text, usually referred to as the source text is rendered into the target language. Another text is produced. When a person translates a text, they must take into account context and grammar rules of both languages. When there is not a simple word for word rendering between two languages, the translator must try and determine the best way to outline the text. Therefore, accurate interlingual rendition is not easy and only qualified professionals can accurately translate a document.

Nonetheless, many companies and individuals require accurate translation. In the workplace, if documents are translated incorrectly, this can significantly impact a customer relationship or a business objective within a company. With professional language translation service, a business owner or employees can acquire the tools needed to communicate with any audience. Some opt to have an in-house translator who is a regular employee. This may be a necessary option for companies that require language translation service on a regular basis. However some companies need translation services sporadically and choose to contract with a language translation service company. If you contract with a company, some will give you professional or team of professionals which will be similar to consultants. The only advantage factor is you will not have to pay the overhead costs associated with employing another person. This employee will be at your disposal and you can call upon this person when you have an interlingual rendition problem.

Before you contract with a company, make sure you interview the person you will be working with thoroughly. Being bilingual alone does not qualify someone to be a translator. Translation is an art that takes years of experience to perfect. A professional translator knows to translate ideas and has the skill set available to make a translated document read like an original and not a translated version.

Whether you employ someone in house or as a consultant, you should choose a language professional who can translate into their native nomenclatures and are experts in the fields covered by your projects. For example, if you need a legal brief translated, you should choose a translator who has experience in the desired language and legal field. Although most are native speakers, there are some who are not proficient in the target language and quality. When choosing a translator, make sure he or she passes a competency test. Furthermore, check and see samples of their work before you consider working with them. This will ensure that you will receive a quality language translation service each time; that is certified and proofread carefully for accuracy and not modified in any way. For certain languages, such as Spanish, there are a variety of options available for translation however for other nomenclatures there may not be as many translators.

#

Language translation from the command line or clipboard

Posted by: toronto on April 08, 2008 01:01 AM
Any online translator should only be used for entertainment <a href="http://www.alancoxonachip.com" target="_blank">purposes</a> only. They can never really take things in context of a real conversation or regional slang. French in <a href="http://www.precede.ca" target="_blank">Canada</a> and French in France look and sound very different for example.
[Modified by: toronto on April 29, 2008 03:39 AM]

#

Language translation from the command line or clipboard

Posted by: Anonymous [ip: 89.48.204.68] on April 09, 2008 10:33 AM
sudo is NOT normal!! its for ubuntu users, ubuntu means: too dumb to use debian.

#

Language translation from the command line or clipboard

Posted by: Anonymous [ip: 81.168.52.226] on April 09, 2008 11:15 AM
This is a very useful idea, thanks. In particular, it's a great help for me with language learning. I use a tool firefox tool (gtranslate) for conveniently translating words from websites, but it's great to be able to have a similar tool that can work across any application via the clipboard.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya