Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improve commenting

  • Loading branch information...
commit 79b8dbd0c82ae8bccfa343c90dabb71f9d04b622 1 parent 0d308fd
Simon Tokumine authored
Showing with 4 additions and 22 deletions.
  1. +4 −22 public/tolk/application.js
View
26 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) {
@@ -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)
- }
- });
- }
- });
-*/
-
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.