Skip to content

Commit

Permalink
improve commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Tokumine committed Jul 18, 2010
1 parent 0d308fd commit 79b8dbd
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions public/tolk/application.js
@@ -1,14 +1,16 @@
google.load("language", "1");

Event.observe(window, 'load', function() {

// Translate the phrase when the translator clicks on the text area
// only fires if textarea is blank
$$('textarea').invoke('observe', 'click', function(event) {
var phrase = this.up('tr').down('span.to_translate');
var textarea = this;
var target_language = $('target_language').innerHTML;

if (phrase && textarea && $F(textarea).blank){
//translate it
//translate it using google translate, autodetect source language
var to_trans = phrase.innerHTML;
google.language.translate(to_trans, "", target_language, function(result) {
if (!result.error) {
Expand All @@ -17,25 +19,5 @@ Event.observe(window, 'load', function() {
}
});
}
});

/*
// translate everything on the page. Not so useful as translator has to do everything.
$$('table.translations tr').each(function(row){
var phrase = row.down('span.to_translate');
var textarea = row.down('textarea');
var target_language = $('target_language').innerHTML;
if (phrase && textarea && $F(textarea).blank){
//translate it
var to_trans = phrase.innerHTML;
google.language.translate(to_trans, "", target_language, function(result) {
if (!result.error) {
textarea.setValue(result.translation)
}
});
}
});
*/

});
});

0 comments on commit 79b8dbd

Please sign in to comment.