Changeset 68


Ignore:
Timestamp:
03/17/2009 09:07:25 AM (3 years ago)
Author:
ofer
Message:

Initial commit of auto-translate feature

Location:
trunk/WordPress/plugin/transposh
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/constants.php

    r54 r68  
    6161define("TRANLSLATOR", 'translator'); 
    6262 
    63 //Option defining whether anonymous translation is allowed.  
     63//Option defining whether anonymous translation is allowed. 
    6464define("ANONYMOUS_TRANSLATION", "transposh_allow_anonymous_translation"); 
    6565 
     
    7373define("DEFAULT_LANG", "transposh_default_language"); 
    7474 
    75 //Define segment id prefix, will be included in span tag. 
     75//Option defining transposh widget appearance 
     76define("WIDGET_TRANSPOSH", "transposh_widget"); 
     77 
     78//Define segment id prefix, will be included in span tag. also used as class identifier 
    7679define("SPAN_PREFIX", "tr_"); 
    7780 
     
    7982define("IMG_PREFIX", "tr_img_"); 
    8083 
    81 //Option defining transposh widget appearance 
    82 define("WIDGET_TRANSPOSH", "widget_transposh"); 
    83  
    8484//Option to enable/disable rewrite of permalinks 
    8585define("ENABLE_PERMALINKS_REWRITE", "transposh_enable_permalinks"); 
    86  
    8786?> 
  • trunk/WordPress/plugin/transposh/js/transposh.js

    r58 r68  
    1515 *      Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    1616 */ 
     17 
    1718function display_dialog(caption, content) 
    1819{         
     
    4748 
    4849// fetch translation from google translate... 
    49 function getgt(lang) 
     50function getgt() 
    5051{ 
    51         google.language.translate($("#tr_original_unescaped").text(), "", lang, function(result) { 
     52        google.language.translate($("#tr_original_unescaped").text(), "", transposh_target_lang, function(result) { 
    5253                  if (!result.error) { 
    53                     $("#tr_translation").attr('value',result.translation); 
     54                    $("#tr_translation").val(result.translation); 
    5455                  }  
    5556                }); 
    5657} 
    5758 
     59//Ajax translation 
     60function ajax_translate(original,translation,source,segment_id) { 
     61    var query = 'original=' +  escape(original) + 
     62    '&translation=' + translation + 
     63    '&lang=' + transposh_target_lang + 
     64    '&source=' + source + 
     65    '&translation_posted=1'; 
     66 
     67    $.ajax({   
     68        type: "POST", 
     69        url: transposh_post_url, 
     70        data: query,   
     71        success: function(req) { 
     72                //rewrite onclick function - in case of re-edit 
     73                $("#tr_img_" + segment_id).click(function () { 
     74                        translate_dialog(original, translation, segment_id); 
     75                    }); 
     76 
     77                //current img  
     78                var img = $("#tr_img_" + segment_id).attr('src'); 
     79                var text_rewrite = translation; 
     80                 
     81                if(jQuery.trim(translation).length == 0) { 
     82                    //reset to the original content - the not escaped version 
     83                    text_rewrite = original; 
     84 
     85                    //switch to the edit img 
     86                    img = img.replace(/translate_fix.png/, "translate.png"); 
     87                } 
     88                else { 
     89                        if (source == 1) { 
     90                                //switch to the auto img 
     91                                img = img.replace(/translate.png/, "translate_auto.png");                                
     92                        } else { 
     93                                //switch to the fix img 
     94                                img = img.replace(/translate.png/, "translate_fix.png"); 
     95                        } 
     96                } 
     97                 
     98                 
     99                //rewrite text 
     100                $("#tr_" + segment_id).html(text_rewrite); 
     101 
     102                //rewrite image 
     103                $("#tr_img_" + segment_id).attr('src', img); 
     104 
     105                //close dialog 
     106                cClick(); 
     107                }, 
     108                 
     109        error: function(req) { 
     110                alert("Error !!! failed to translate.\n\nServer's message: " + req.statusText); 
     111               } 
     112    }); 
     113 
     114} 
     115 
    58116//Open translation dialog  
    59 function translate_dialog(original, trans, lang, post_url, segment_id) 
     117function translate_dialog(original, trans, segment_id) 
    60118{ 
    61119caption='Edit Translation'; 
    62  
     120//alert (this.id); 
    63121var dialog = ''+ 
    64     ('<form id="tr_form" name="transposh_edit_form" method="post" action="' + post_url + '"><div>') + 
     122    ('<form id="tr_form" name="transposh_edit_form" method="post" action="' + transposh_post_url + '"><div>') + 
    65123     '<p dir="ltr">Original text<br \/><textarea id="tr_original_unescaped" cols="60" rows="3" readonly="readyonly">' + 
    66124       original + '</textarea> <\/p>' + 
     
    68126    '"' + 'onfocus="OLmEdit=1;" onblur="OLmEdit=0;"<\/p>' + 
    69127    '<input type="hidden" id="tr_original" name="original" value="' + escape(original) +'">' + 
    70     '<input type="hidden" id="tr_lang" name="lang" value="'+lang+'">' + 
    71128    '<input type="hidden" name="translation_posted" value= "1">' + 
    72     '<p><input onclick="getgt(\''+lang+'\')" type="button" value="Get Suggestion!"/>&nbsp;<input type="submit" value="Translate"/><\/p>' + 
     129    '<p><input onclick="getgt()" type="button" value="Get Suggestion!"/>&nbsp;<input type="submit" value="Translate"/><\/p>' + 
    73130    ('<\/div><\/form>'); 
    74131 
    75 display_dialog(caption, dialog); 
     132        display_dialog(caption, dialog); 
    76133 
    77 // attach handler to form's submit event  
    78 $('#tr_form').submit(function() {  
     134        // attach handler to form's submit event  
     135        $('#tr_form').submit(function() {  
    79136        var translation = $('#tr_translation').val(); 
    80         var query = 'original=' +  escape(original) + 
    81                     '&translation=' + translation + 
    82                     '&lang=' + $('#tr_lang').val() + 
    83                     '&translation_posted=1'; 
    84          
    85                  
    86         $.ajax({   
    87             type: "POST", 
    88             url: post_url, 
    89             data: query,   
    90             success: function(req) { 
    91                     //rewrite onclick function - in case of re-edit 
    92                     $("#tr_img_" + segment_id).click(function () { 
    93                             translate_dialog(original, translation, lang, post_url, segment_id); 
    94                         }); 
    95  
    96                     //current img  
    97                     var img = $("#tr_img_" + segment_id).attr('src'); 
    98                     var text_rewrite = translation; 
    99                      
    100                     if(jQuery.trim(translation).length == 0) { 
    101                         //reset to the original content - the not escaped version 
    102                         text_rewrite = original; 
    103  
    104                         //switch to the edit img 
    105                         img = img.replace(/translate_fix.png/, "translate.png"); 
    106                     } 
    107                     else { 
    108                         //switch to the fix img 
    109                         img = img.replace(/translate.png/, "translate_fix.png"); 
    110                     } 
    111                      
    112                      
    113                     //rewrite text 
    114                     $("#tr_" + segment_id).html(text_rewrite); 
    115  
    116                     //rewrite image 
    117                     $("#tr_img_" + segment_id).attr('src', img); 
    118  
    119                     //close dialog 
    120                     cClick(); 
    121                     }, 
    122                      
    123             error: function(req) { 
    124                     alert("Error !!! failed to translate.\n\nServer's message: " + req.statusText); 
    125                    } 
    126                  
    127                      
    128         }); 
     137                         
     138        ajax_translate(original,translation,0,segment_id); 
    129139         
    130140        // return false to prevent normal browser submit and page navigation  
     
    132142         
    133143    }); 
     144 
    134145} 
     146//function for auto translation 
     147 
     148function do_auto_translate() { 
     149        $(".tr_u").each(function (i) { 
     150                var translated_id = $(this).attr('id'); 
     151                google.language.translate($(this).text(), "", transposh_target_lang, function(result) { 
     152                        if (!result.error) { 
     153                                var segment_id = translated_id.substr(translated_id.lastIndexOf('_')+1); 
     154                        ajax_translate($("#"+translated_id).text(),result.translation,1,segment_id); 
     155                        }  
     156                }); 
     157        }); 
     158} 
  • trunk/WordPress/plugin/transposh/parser.php

    r61 r68  
    9797                        $tag_start = $pos; 
    9898                        $pos = strpos($page, '>', $pos); 
    99                          
     99 
    100100                        //Mark tag end position 
    101101                        $tag_end = $pos; 
     
    156156        logger("Exit " . __METHOD__, 4); 
    157157} 
    158  
    159158 
    160159/* 
     
    209208                        global $is_in_channel; 
    210209                        $is_in_channel = TRUE; 
    211                         break;   
    212         } 
    213  
    214 } 
    215  
     210                        break; 
     211        } 
     212 
     213} 
    216214 
    217215/* 
     
    240238} 
    241239 
    242  
    243240/* 
    244241 * Process html tag. Set the direction for rtl languages. 
     
    301298        if(is_word('![CDATA[')) 
    302299        { 
    303                 $pos += 8; //skip to end of ![CDATA[  
     300                $pos += 8; //skip to end of ![CDATA[ 
    304301        } 
    305302        else 
     
    311308                } 
    312309        } 
    313          
     310 
    314311        logger("Exit " . __METHOD__. ": $pos", 5); 
    315312        return substr($page,$start, $pos - $start); 
     
    385382{ 
    386383        global $page, $pos; 
    387          
     384 
    388385        logger("Enter " . __METHOD__ , 4); 
    389386 
     
    394391                $start = $pos; 
    395392                $page_length =  strlen($page); 
    396                  
    397                 // Indicates if the html entity should break into a new translation segment.  
    398                 $is_breaker = FALSE;   
    399                  
     393 
     394                // Indicates if the html entity should break into a new translation segment. 
     395                $is_breaker = FALSE; 
     396 
    400397                while($pos < $page_length && $page[$pos] != '<') 
    401398                { 
     
    409406                                        $start = $end_of_entity; 
    410407                                } 
    411                                  
     408 
    412409                                //skip past entity 
    413410                                $pos = $end_of_entity; 
     
    433430} 
    434431 
    435  
    436 /* 
    437  * Translate the content of a cdata section.  For now we only expect to handle it  
    438  * within RSS feeds.  
     432/* 
     433 * Translate the content of a cdata section.  For now we only expect to handle it 
     434 * within RSS feeds. 
    439435 */ 
    440436function process_cdata_section() 
    441437{ 
    442438        global $page, $pos; 
    443          
     439 
    444440        logger("Enter " . __METHOD__  , 4); 
    445441 
     
    450446                $start = $pos; 
    451447                $page_length =  strlen($page); 
    452                  
     448 
    453449                while($pos < $page_length && !is_word(']]>')) 
    454450                { 
     
    477473/** 
    478474 * Determines position in page marks a transaltable tag in html page or rss feed section. 
    479  * Return TRUE if should be translated otherwise FALSE.   
     475 * Return TRUE if should be translated otherwise FALSE. 
    480476 */ 
    481477function is_translatable_section() 
     
    484480        $rc = FALSE; 
    485481        $current_tag = end($tags_list); 
    486          
     482 
    487483        if($is_in_body || $current_tag == 'title') 
    488484        { 
     
    496492 
    497493        logger("Exit " . __METHOD__ . " $current_tag, translate: " . ($rc ? "yes" : "no"), 4); 
    498         return $rc;    
     494        return $rc; 
    499495} 
    500496 
     
    525521                        $page[$position] == ';' || 
    526522                        //break on numbers but not like: 3rd, 4th 
    527                         (is_digit($position) && !is_a_to_z_character($position+1)))  
     523                        (is_digit($position) && !is_a_to_z_character($position+1))) 
    528524        { 
    529525                //break the sentence into segments regardless of the next character. 
     
    537533 * Determines if the current position marks the begining of an html 
    538534 * entity. E.g &amp; 
    539  * Return 0 if not an html entity otherwise return the position past this entity. In addition  
     535 * Return 0 if not an html entity otherwise return the position past this entity. In addition 
    540536 *        the $is_breaker will be set to TRUE if entity should break translation into a new segment. 
    541537 * 
     
    677673} 
    678674 
    679  
    680675/* 
    681676 * Check within page buffer position for the given word. 
    682677 * param word The word to look for. 
    683  * param index1 Optional position within the page buffer, if not available then the current  
    684  *              position ($pos) is used.   
     678 * param index1 Optional position within the page buffer, if not available then the current 
     679 *              position ($pos) is used. 
    685680 * Return TRUE if the word matches otherwise FALSE 
    686681 */ 
     
    689684        global $page, $pos; 
    690685        $rc = FALSE; 
    691          
     686 
    692687        if(!isset($index1)) 
    693688        { 
     
    695690                $index1 = $pos; 
    696691        } 
    697          
     692 
    698693        $index2 = 0; //position within word 
    699694        $word_len =   strlen($word); 
    700695        $page_length =  strlen($page); 
    701          
     696 
    702697        while($index1 < $page_length && $index2 < $word_len) 
    703698        { 
     
    712707                } 
    713708        } 
    714          
     709 
    715710        //check if we have full match 
    716711        if($index2 == $word_len) 
     
    718713                $rc = TRUE; 
    719714        } 
    720          
     715 
    721716        return $rc; 
    722717} 
    723718 
    724  
    725 /** 
     719/* 
    726720 * Translate the text between the given start position and the current 
    727721 * position (pos) within the buffer. 
     
    757751        } 
    758752 
    759         $translated_text = fetch_translation($original_text); 
    760  
    761         insert_translation($original_text, $translated_text, $start, $end); 
     753        list($translated_text, $source) = fetch_translation($original_text); 
     754 
     755        insert_translation($original_text, $translated_text, $source, $start, $end); 
    762756} 
    763757 
     
    769763 * param end Marks the end position of the text to be replaced within the original page 
    770764 */ 
    771 function insert_translation(&$original_text, &$translated_text, $start, $end) 
     765function insert_translation(&$original_text, &$translated_text, $source, $start, $end) 
    772766{ 
    773767        global $segment_id, $is_edit_mode, $tags_list; 
     
    784778        else 
    785779        { 
    786                 $span = "<span id=\"" . SPAN_PREFIX . "$segment_id\">"; 
     780                $span_prefix = SPAN_PREFIX; 
     781                // We will mark translated text with tr_t class and untranslated with tr_u 
     782                $span = "<span class=\"$span_prefix"; 
    787783 
    788784                if($translated_text == NULL) 
    789785                { 
     786                        $span .= "u\" id=\"{$span_prefix}{$segment_id}\">"; 
    790787                        $span .= $original_text . '</span>'; 
    791788                } 
    792789                else 
    793790                { 
     791                        $span .= "t\" id=\"{$span_prefix}{$segment_id}\">"; 
    794792                        $span .= $translated_text . "</span>"; 
    795793                        $is_translated = TRUE; 
     
    801799 
    802800                //Insert image to allow editing this segment 
    803                 $img = get_img_tag($original_text, $translated_text, $segment_id, $is_translated); 
     801                $img = get_img_tag($original_text, $translated_text, $source, $segment_id, $is_translated); 
    804802                update_translated_page($end + 1, - 1, $img); 
    805803 
     
    813811} 
    814812 
    815  
    816813/* 
    817814 * Scrubs text prior to translation to remove/encode special 
     
    833830        return $text; 
    834831} 
    835  
    836832 
    837833/** 
     
    865861 
    866862} 
    867  
    868863?> 
  • trunk/WordPress/plugin/transposh/transposh.php

    r67 r68  
    4242 
    4343//Database version 
    44 define("DB_VERSION", "1.01"); 
     44define("DB_VERSION", "1.02"); 
    4545 
    4646//Constant used as key in options database 
     
    221221 * Fetch translation from db or cache. 
    222222 * Returns the translated string or NULL if not available. 
     223 * TODO: // will an array work? 
    223224 */ 
    224225function fetch_translation($original) 
     
    230231    if(ENABLE_APC && function_exists('apc_fetch')) 
    231232    { 
    232         $cached = apc_fetch($original . $lang, $rc); 
     233        $cached = apc_fetch($original .'___'. $lang, $rc); 
    233234        if($rc === TRUE) 
    234235        { 
     
    243244    if($row !== FALSE) 
    244245    { 
    245         $translated = $row->translated; 
    246         $translated = stripslashes($translated); 
    247  
    248         logger("db result for $original >>> $translated ($lang)" , 3); 
     246        $translated_text = stripslashes($row->translated); 
     247        $translated = array($translated_text, $row->source); 
     248 
     249        logger("db result for $original >>> $translated_text ($lang) ({$row->source})" , 3); 
    249250    } 
    250251 
     
    260261 
    261262        //update cache 
    262         $rc = apc_store($original . $lang, $cache_entry, 3600); 
     263        $rc = apc_store($original .'___'. $lang, $cache_entry, 3600); 
    263264        if($rc === TRUE) 
    264265        { 
     
    298299    $js .= "\n<script type=\"text/javascript\" src=\"$overlib_dir/overlibmws_shadow.js\"></script>"; 
    299300 
    300     $js .= "\n<script type=\"text/javascript\" src=\"$plugin_url/js/transposh.js\"></script>\n"; 
    301     $js .= "\n<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></script>\n"; 
    302     $js .= "\n<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>\n"; 
    303     $js .= "\n<script type=\"text/javascript\">google.load(\"language\", \"1\");</script>\n"; 
     301    $js .= "\n<script type=\"text/javascript\" src=\"$plugin_url/js/transposh.js\"></script>"; 
     302    $js .= "\n<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></script>"; 
     303    $js .= "\n<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>"; 
     304    $js .= "\n<script type=\"text/javascript\">google.load(\"language\", \"1\");</script>"; 
     305    global $lang, $home_url; 
     306    $post_url = $home_url . '/index.php'; 
     307    $js .= "\n<script type=\"text/javascript\">var transposh_post_url='$post_url';var transposh_target_lang='$lang';$(document).ready(function() {do_auto_translate();});</script>"; 
    304308 
    305309    echo $js; 
     
    313317         placed within the img tag for use on client side operation (jquery) 
    314318 */ 
    315 function get_img_tag($original, $translation, $segment_id, $is_translated = FALSE) 
     319function get_img_tag($original, $translation, $source, $segment_id, $is_translated = FALSE) 
    316320{ 
    317321    global $plugin_url, $lang, $home_url; 
     
    330334    } 
    331335 
     336    if ($source == 1) { 
     337        $add_img = "_auto"; 
     338    } 
     339 
    332340    $img = "<img src=\"$plugin_url/translate$add_img.png\" alt=\"translate\" id=\"" . IMG_PREFIX . "$segment_id\" 
    333            onclick=\"translate_dialog('$original','$translation','$lang','$url', '$segment_id'); return false;\" 
     341           onclick=\"translate_dialog('$original','$translation','$segment_id'); return false;\" 
    334342           onmouseover=\"hint('$original'); return true;\" 
    335343           onmouseout=\"nd()\" />"; 
     
    395403    $translation = $_POST['translation']; 
    396404    $lang = $_POST['lang']; 
     405    $source = $_POST['source']; 
    397406 
    398407    if(!isset($original) || !isset($translation) || !isset($lang)) 
    399408    { 
    400         logger("Enter " . __FILE__ . " missing params: $original , $translation, $lang," . 
    401                $ref, 0); 
     409        logger("Enter " . __FILE__ . " missing params: $original , $translation, $lang," . $ref, 0); 
    402410        return; 
    403411    } 
     
    413421    $translation = $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translation)))); 
    414422 
    415     $update = "REPLACE INTO  $table_name (original, translated, lang) 
    416                 VALUES ('" . $original . "','" . $translation . "','" . $lang . "')"; 
     423    //TODO: Check more escaping... 
     424 
     425    $update = "REPLACE INTO  $table_name (original, translated, lang, source) 
     426                VALUES ('" . $original . "','" . $translation . "','" . $lang . "','" . $source . "')"; 
    417427 
    418428    $result = $wpdb->query($update); 
     
    420430    if($result !== FALSE) 
    421431    { 
    422         update_transaction_log($original, $translation, $lang); 
     432        update_transaction_log($original, $translation, $lang, $source); 
    423433 
    424434        //Delete entry from cache 
    425435        if(ENABLE_APC && function_exists('apc_store')) 
    426436        { 
    427             apc_delete($original . $lang); 
     437            apc_delete($original .'___'. $lang); 
    428438        } 
    429439        logger("Inserted to db '$original' , '$translation', '$lang' " , 3); 
     
    443453 * 
    444454 */ 
    445 function update_transaction_log(&$original, &$translation, &$lang) 
     455function update_transaction_log(&$original, &$translation, &$lang, $source) 
    446456{ 
    447457        global $wpdb, $user_ID; 
     
    458468        } 
    459469 
    460     $log = "INSERT INTO ".$wpdb->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by) 
    461                 VALUES ('" . $original . "','" . $translation . "','" . $lang . "','".$loguser."')"; 
     470    $log = "INSERT INTO ".$wpdb->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) 
     471                VALUES ('" . $original . "','" . $translation . "','" . $lang . "','".$loguser."','".$source."')"; 
    462472 
    463473    $result = $wpdb->query($log); 
     
    465475    if($result === FALSE) 
    466476    { 
    467         logger("Error !!! failed to update transaction log:  $loguser, $original ,$translation, $lang" , 0); 
    468     } 
    469  
    470 } 
    471  
     477        logger("Error !!! failed to update transaction log:  $loguser, $original ,$translation, $lang, $source" , 0); 
     478    } 
     479} 
    472480 
    473481/* 
     
    510518} 
    511519 
    512  
    513520/* 
    514521 * Page generation completed - flush buffer. 
     
    518525    ob_flush(); 
    519526} 
    520  
    521527 
    522528/* 
     
    580586    return $qvars; 
    581587} 
    582  
    583588 
    584589/* 
     
    609614        dbDelta($sql); 
    610615 
     616                // TODO: remove this? 
    611617        //Verify that newly created table is ready for use. 
    612618        //$insert = "INSERT INTO " . $table_name . " (original, translated, lang) " . 
     
    634640                                                  translated VARCHAR(256), 
    635641                                                  translated_by VARCHAR(15), 
     642                                                  source TINYINT NOT NULL, 
    636643                                                  timestamp TIMESTAMP, 
    637644                                                  PRIMARY KEY (original, lang, timestamp)) "; 
  • trunk/WordPress/plugin/transposh/transposh_widget.php

    r59 r68  
    3636 
    3737                global $wp_rewrite; 
    38          
     38 
    3939                $ref=getenv('HTTP_REFERER'); 
    4040                $lang = $_POST[LANG_PARAM]; 
    4141 
    42         //remove existing language settings.  
     42        //remove existing language settings. 
    4343        $ref = cleanup_url($ref); 
    44          
     44 
    4545                if($lang != "none") 
    4646                { 
     
    100100 
    101101    $is_showing_languages = FALSE; 
    102      
     102 
    103103        echo $before_widget . $before_title . __(no_translate("Transposh")) . $after_title; 
    104              
     104 
    105105        switch ($options['style']) { 
    106106                case 1: // flags 
    107107            //keep the flags in the same direction regardless of the overall page direction 
    108             echo "<div style=\"text-align: left;\" class=\"" . NO_TRANSLATE_CLASS . "\" >";  
     108            echo "<div style=\"text-align: left;\" class=\"" . NO_TRANSLATE_CLASS . "\" >"; 
    109109 
    110110            global $plugin_url; 
    111111            $using_permalinks = $wp_rewrite->using_permalinks(); 
    112              
     112 
    113113                        foreach($languages as $code => $lang2) 
    114114                        { 
    115115                                list($language,$flag) = explode (",",$lang2); 
    116116 
    117                 //remove any language identifier  
     117                //remove any language identifier 
    118118                $page_url = cleanup_url($page_url); 
    119                  
     119 
    120120                                //Only show languages which are viewable or (editable and the user is a translator) 
    121121                                if(strstr($viewable_langs, $code) || 
     
    123123                                { 
    124124                                        $page_url = rewrite_url_lang_param($page_url, $code, $is_edit, !$using_permalinks); 
    125                      
     125 
    126126                                        echo "<a href=\"" . $page_url . "\"> 
    127127                         <img src=\"$plugin_url/flags/$flag.png\" title=\"$language\" alt=\"$language\" 
     
    131131                        } 
    132132            echo "</div>"; 
    133              
     133 
    134134                        // this is the form for the edit... 
    135135                        echo "<form action=\"$page_url\" method=\"post\">"; 
     
    139139 
    140140            echo "<form action=\"$page_url\" method=\"post\">"; 
    141             echo "<span class=\"" . NO_TRANSLATE_CLASS . "\" >"; 
     141            echo "<span class=\"" .NO_TRANSLATE_CLASS . "\" >"; 
    142142                        echo "<select name=\"lang\"     id=\"lang\" onchange=\"Javascript:this.form.submit();\">"; 
    143143                        echo "<option value=\"none\">[Language]</option>"; 
     
    171171                "\" onClick=\"this.form.submit();\"/>&nbsp;Edit Translation"; 
    172172        } 
    173          
     173 
    174174        echo "<input type=\"hidden\" name=\"transposh_widget_posted\" value=\"1\"/>"; 
    175175    } 
     
    181181 
    182182    echo "</form>"; 
     183    echo "<button onClick=\"do_auto_translate();\">translate all</button>"; 
    183184 
    184185    echo $after_widget; 
    185186} 
    186187 
    187  
    188 /* 
    189  *Remove from url any language (or editing) params that were added for our use. 
    190  *Return the scrubed url 
     188/* 
     189 * Remove from url any language (or editing) params that were added for our use. 
     190 * Return the scrubed url 
    191191 */ 
    192192function cleanup_url($url) 
    193193{ 
    194194    global $home_url, $home_url_quoted; 
    195      
     195 
    196196    //cleanup previous lang & edit parameter from url 
    197197    $url = preg_replace("/(" . LANG_PARAM . "|" . EDIT_PARAM . ")=[^&]*/i", "", $url); 
    198      
    199      
     198 
     199 
    200200    if(!$home_url) 
    201201    { 
     
    203203        init_global_vars(); 
    204204    } 
    205      
     205 
    206206    //cleanup lang identifier in permalinks 
    207207    $url = preg_replace("/$home_url_quoted\/(..\/)/", "$home_url/",  $url); 
     
    245245    echo '<option ' . ($style == 1 ? 'selected="selected"' : '') . 
    246246        'value="1">Flags</option>'; 
    247      
     247 
    248248    echo '</select></label></p> 
    249249          <input type="hidden" name="transposh-submit" id="transposh-submit" value="1" />'; 
    250      
    251 } 
    252  
     250 
     251} 
    253252 
    254253//Register callback for WordPress events 
     
    256255add_action('widgets_init', 'transposh_widget_init'); 
    257256 
    258  
    259257?> 
Note: See TracChangeset for help on using the changeset viewer.