Parrot Time Magazine

The Thinking of Speaking
Issue #8 March / April 2014
GlobTech
Google Translate Section

Google Translate Section

by Erik Zidowecki
March / April 2014 |  asd


GlobTech is a new column dealing with new ways of utilizing globalization technology on the internet.

For most language lovers, the mere mention of Google Translate is likely to evoke groans of misery or even curses.

The idea of having a machine translating from one language to another is one that people have long promised, but the results are usually rather disappointing. Translating between languages can be tricky enough for a human fluent in two languages. For a machine that can't even truly understand the language, the task becomes much more difficult and that results in some very poor texts.

I would not suggest using a machine translation when trying to communicate with someone else. First, it is likely to be very annoying to the other person, for their language is being butchered. It is also insulting, because it shows that you aren't making any real effort to speak to them as people.

Having said that, there are benefits to using an automated translator in certain situations. Quite often, we don't need to have a perfect understanding of what was said. Rather, we need to have a basic understanding, and even a bad machine translation can usually provide us with such. In that case, we are inflicting the translation upon ourselves.

So, when using a translation system, use it for your own understanding, like converting a web page into something you can understand. Do not, however, use such a system to translate a web page to present to others.

Using on a Site

With the Google Translate page, a person can enter text written in one language and have it instantly converted to another. There is also a feature that allows someone to translate an entire webpage into another language. This can be useful if you need the information on a page but it doesn't have a page in your language.

There is a much more specialized use for the Google Translate system that I have put to use. That is the ability to translate just a specific piece of text on a page. The given text is specified in the code of the page and when a certain link is clicked (the default in English is "Translate"), it is instantly translated into a specific language. Another click and it returns to normal.

While most sites probably wouldn't have a need for such a device, there are many uses for it on a site for learning languages. The most obvious is on a forum. The text of a post can be converted as needed for a person, so even posts written in an unknown language to the reader can be understood.

Furthermore, this can be used as a learning aid in that environment. If a person is learning Polish, they can practice their comprehension by reading posts written in Polish, using the translation button only when they find themselves stuck.

Translating the text of a post could also be achieved by using the page translator or the text translator page of Google, but this is much more accessible and faster.

Another use is in comment and feedback sections. Parleremo has a journal system, in which people write about something in a language they are studying. They then rely upon other members to correct them and leave comments. These comments might be left in the studied language, but be beyond the capabilities of the original poster to understand fully. Putting these comments into a translatable section ensures the writer will understand the responses. The translation capability has been added here as well as the recording system, which is similar, except that people record themselves reading a text.

What is Needed

Generally, there are three components to adding this sectional translation capability to a page. First, some basic Javascript code is added to set up a few class names and color. This is what is used on Parleremo:



<script type="text/javascript">
function googleSectionalElementInit() {
new google.translate.SectionalElement({
   sectionalNodeClassName: 'goog-trans-section',
   controlNodeClassName: 'goog-trans-control',
   background: '#f4fa58'
}, 'google_sectional_element'); }
</script>

The background color is simply to help the mechanism blend in better with a website.

Next, we need a line to include a script into the page which will do the heavy lifting:


<script type="text/javascript"
  src="//translate.google.com/translate_a/element.js
  ?cb=googleSectionalElementInit&ug=section&hl=en"></script>

The last part, hl=en, dictates what language the text will be translated into. The en is the ISO-639-2 code for English. This should be changed to whatever is needed. On Parleremo, this is replaced by what a person has selected for their site language, which is viewed as their source language for the entire site.

Finally, the actual wrapping of the section of the text:


<div class="goog-trans-section" lang="nl">
     Dit is de te vertalen tekst
     <div class="goog-trans-control"></div>
 </div>

Replace "Dit is de te vertalen tekst" with whatever you want. The lang="nl" defines the language of the text, again using the ISO-639-2 codes. If the entire line lang="" is left out, then Google Translate will attempt to guess what language is being used. This works best with a larger body of text because it will be more likely that a proper guess will be made.

The second div is where the "Translate" link will be placed. This is needed to toggle between translations. The first div holds the text to be translated and the control div.

Note that the classes used in this last bit of code match those used in the original declarations. You could probably change these to whatever you want, but I suggest just keeping them unique as they are.

That's It!

Now you can add your own sectional translations to your website or blog. As I said before, I wouldn't rely upon this to come up with completely accurate translations, but it should provide a user with a basic understanding. Remember that it won't work for all languages, just for those that Google Translate knows. The good part about that is it already has over seventy languages, with more being added.PT

GlobTech - Google Translate Section
Writer: Erik Zidowecki
Images:
Petey: world map

All images are Copyright - CC BY-SA (Creative Commons Share Alike) by their respective owners, except for Petey, which is Public Domain (PD) or unless otherwise noted.

Searching for language resources?
Scriveremo Publishing, has lots of fun books and resource to help you learn a language. Click the link below to see our selection of books, availlable for over 30 langauges!
Indonesian Pocket Searches - The Basics - Volume 1



Also in this issue




Others like this

Comments

comments powered by Disqus