Changeset 167


Ignore:
Timestamp:
04/30/2009 03:59:54 PM (3 years ago)
Author:
ofer
Message:

Preparing for 0.1.4, improve support for non auto translatable languages

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

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/build.sh

    r148 r167  
    8383fi 
    8484 
     85echo "Minify .js files" 
     86for file in `find . -maxdepth 2 -iname '*.js'`; do  
     87  echo "minifying $file" 
     88  java -jar /root/yui/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar $file > $TRANSPOSH_DIR/$file 
     89done; 
     90 
    8591# Remove .svn dirs 
    8692find $TRANSPOSH_DIR -name "*.svn*" -exec rm -rf {} 2>/dev/null \; 
  • trunk/WordPress/plugin/transposh/core/constants.php

    r125 r167  
    3030 
    3131//Supported languages, new languages can be added here 
    32 //the array directs from language code to - Native name, flag 
    33 $languages = array("en" => "English,us", 
    34                                         "sq" => "Shqip,al", 
    35                                         "ar" => "العرؚية,sa", 
    36                                         "bg" => "БългарскО,bg", 
    37                                         "ca" => "Català,catalonia", 
    38                                         "zh" => "äž­æ–‡(简䜓),cn", 
    39                                         "zh-tw" => "äž­æ–‡(挢字),tw", 
    40                                         "hr" => "Hrvatski,hr", 
    41                                         "cs" => "čeÅ¡tina,cz", 
    42                                         "da" => "dansk,dk", 
    43                                         "nl" => "Nederlands,nl", 
    44                                         "et" => "Eesti keel,ee", 
    45                                         "fi" => "Suomi,fi", 
    46                                         "fr" => "Français,fr", 
    47                                         "gl" => "Galego,galicia", 
    48                                         "de" => "Deutsch,de", 
    49                                         "el" => "ΕλληΜικά,gr", 
    50                                         "he" => "עבךית,il", 
    51                                         "hi" => "à€¹à€¿à€šà¥à€Šà¥€; à€¹à€¿à€‚à€Šà¥€,in", 
    52                                         "hu" => "magyar,hu", 
    53                                         "id" => "Bahasa Indonesia,id", 
    54                                         "it" => "Italiano,it", 
    55                                         "ja" => "日本語 (にほんごにっぜんご),jp", 
    56                                         "ko" => "우늬말,kr", 
    57                                         "lv" => "latvieÅ¡u valoda,lv", 
    58                                         "lt" => "lietuvių kalba,lt", 
    59                                         "mt" => "Malti,mt", 
    60                                         "no" => "Norsk,no", 
    61                                         "pl" => "Polski,pl", 
    62                                         "pt" => "Português,pt", 
    63                                         "ro" => "Română,ro", 
    64                                         "ru" => "РусскОй,ru", 
    65                                         "sr" => "српскО језОк,rs", 
    66                                         "sk" => "slovenčina,sk", 
    67                                         "sl" => "slovenščina,sl", 
    68                                         "es" => "Español,es", 
    69                                         "sv" => "svenska,se", 
    70                                         "tl" => "Tagalog,ph", 
    71                                         "th" => "àž àž²àž©àž²à¹„àž—àž¢,th", 
    72                                         "tr" => "TÃŒrkçe,tr", 
    73                                         "uk" => "УкраїМська,ua", 
    74                                         "vi" => "Tiếng Việt,vn"); 
     32//the array directs from language code to - Native name, flag, auto-translatable 
     33$languages = array("en" => "English,us,1", 
     34                                        "sq" => "Shqip,al,1", 
     35                                        "ar" => "العرؚية,sa,1", 
     36                                        "bg" => "БългарскО,bg,1", 
     37                                        "ca" => "Català,catalonia,1", 
     38                                        "zh" => "äž­æ–‡(简䜓),cn,1", 
     39                                        "zh-tw" => "äž­æ–‡(挢字),tw,1", 
     40                                        "hr" => "Hrvatski,hr,1", 
     41                                        "cs" => "čeÅ¡tina,cz,1", 
     42                                        "da" => "dansk,dk,1", 
     43                                        "nl" => "Nederlands,nl,1", 
     44                                        "et" => "Eesti keel,ee,1", 
     45                                        "fi" => "Suomi,fi,1", 
     46                                        "fr" => "Français,fr,1", 
     47                                        "gl" => "Galego,galicia,1", 
     48                                        "de" => "Deutsch,de,1", 
     49                                        "el" => "ΕλληΜικά,gr,1", 
     50                                        "he" => "עבךית,il,1", 
     51                                        "hi" => "à€¹à€¿à€šà¥à€Šà¥€; à€¹à€¿à€‚à€Šà¥€,in,1", 
     52                                        "hu" => "magyar,hu,1", 
     53                                        "id" => "Bahasa Indonesia,id,1", 
     54                                        "it" => "Italiano,it,1", 
     55                                        "is" => "íslenska,is,0", 
     56                                        "ja" => "日本語 (にほんごにっぜんご),jp,1", 
     57                                        "ko" => "우늬말,kr,1", 
     58                                        "lv" => "latvieÅ¡u valoda,lv,1", 
     59                                        "lt" => "lietuvių kalba,lt,1", 
     60                                        "mt" => "Malti,mt,1", 
     61                                        "no" => "Norsk,no,1", 
     62                                        "pl" => "Polski,pl,1", 
     63                                        "pt" => "Português,pt,1", 
     64                                        "ro" => "Română,ro,1", 
     65                                        "ru" => "РусскОй,ru,1", 
     66                                        "sr" => "српскО језОк,rs,1", 
     67                                        "sk" => "slovenčina,sk,1", 
     68                                        "sl" => "slovenščina,sl,1", 
     69                                        "es" => "Español,es,1", 
     70                                        "sv" => "svenska,se,1", 
     71                                        "tl" => "Tagalog,ph,1", 
     72                                        "th" => "àž àž²àž©àž²à¹„àž—àž¢,th,1", 
     73                                        "tr" => "TÃŒrkçe,tr,1", 
     74                                        "uk" => "УкраїМська,ua,1", 
     75                                        "vi" => "Tiếng Việt,vn,1"); 
    7576 
    7677//Language which are read from right to left (rtl) 
     
    103104//Define segment id prefix, will be included in span tag. also used as class identifier 
    104105define("SPAN_PREFIX", "tr_"); 
    105  
    106 //Define segment id prefix, will be included in img tag. 
    107 define("IMG_PREFIX", "tr_img_"); 
    108  
    109106?> 
  • trunk/WordPress/plugin/transposh/core/globals.php

    r126 r167  
    3131$home_url_quoted; 
    3232 
    33 //The url pointing to the base of the plugin. Used for generatint urls to resources 
     33//The url pointing to the base of the plugin. Used for generating urls to resources 
    3434$plugin_url; 
    3535 
  • trunk/WordPress/plugin/transposh/core/parser.php

    r165 r167  
    833833                update_translated_page($start, $end, $span); 
    834834 
    835  
    836                 //Insert image to allow editing this segment (only in explicit edit) 
    837                 // TODO: check removal 
    838                 /*if($is_edit_mode) { 
    839                         $img = get_img_tag($original_text, $translated_text, $source, $segment_id, $is_translated); 
    840                         update_translated_page($end + 1, - 1, $img); 
    841                 }*/ 
    842835                //Increment only after both text and image are generated so they 
    843836                //will be the same for each translated segement 
     
    944937        logger(__METHOD__ . " $home_url href: $href"); 
    945938} 
    946 /* 
    947  * Return the img tag that will added to enable editing a translatable 
    948  * item on the page. 
    949  * param segement_id The id (number) identifying this segment. Needs to be 
    950  * placed within the img tag for use on client side operation (jquery) 
    951  */ 
    952 /*function get_img_tag($original, $translation, $source, $segment_id, $is_translated = FALSE) 
    953 { 
    954         global $plugin_url, $lang, $home_url; 
    955         $url = $home_url . '/index.php'; 
    956  
    957         //For use in javascript, make the following changes: 
    958         //1. Add slashes to escape the inner text 
    959         //2. Convert the html special characters 
    960         //The browser will take decode step 2 and pass it to the js engine which decode step 1 - a bit tricky 
    961         $translation = htmlspecialchars(addslashes($translation)); 
    962         //TODO: Need to check this one delicate point 
    963         // $original    = htmlspecialchars(addslashes($original)); 
    964  
    965         if ($is_translated) 
    966         { 
    967                 $add_img = "_fix"; 
    968         } 
    969  
    970         if ($source == 1) { 
    971                 $add_img = "_auto"; 
    972         } 
    973  
    974         $img = "<img src=\"$plugin_url/img/translate$add_img.png\" alt=\"translate\" class=\"".IMG_PREFIX."\" id=\"" . IMG_PREFIX . "$segment_id\" ". 
    975            "onclick=\"translate_dialog('$segment_id'); return false;\" ". 
    976                    "title=\"$original\"". 
    977            //"onmouseover=\"hint('$original'); return true;\" ". 
    978            //"onmouseout=\"nd()\" 
    979            "/>"; 
    980  
    981         return $img; 
    982 }*/ 
    983  
    984939?> 
  • trunk/WordPress/plugin/transposh/js/transposh.js

    r165 r167  
    2020{ 
    2121        jQuery(":button:contains('Suggest - Google')").attr("disabled","disabled").addClass("ui-state-disabled"); 
    22         google.language.translate(jQuery("#"+transposh_params['prefix']+"original").val(), "", transposh_params['lang'], function(result) { 
     22        google.language.translate(jQuery("#"+transposh_params.prefix+"original").val(), "", transposh_params.lang, function(result) { 
    2323                if (!result.error) { 
    24                         jQuery("#"+transposh_params['prefix']+"translation").val(jQuery("<div>"+result.translation+"</div>").text()) 
     24                        jQuery("#"+transposh_params.prefix+"translation").val(jQuery("<div>"+result.translation+"</div>").text()) 
    2525                        .keyup(); 
    2626                }  
     
    3434    jQuery.ajax({   
    3535        type: "POST", 
    36         url: transposh_params['post_url'], 
    37         data: {token: jQuery("#"+transposh_params['prefix'] + segment_id).attr('token'), 
     36        url: transposh_params.post_url, 
     37        data: {token: jQuery("#"+transposh_params.prefix + segment_id).attr('token'), 
    3838                                translation: translation, 
    39                                 lang: transposh_params['lang'], 
     39                                lang: transposh_params.lang, 
    4040                                source: source, 
    4141                                translation_posted: "1"}, 
    4242        success: function(req) { 
    43                 var pre_translated = jQuery("#"+transposh_params['prefix'] + segment_id).html(); 
     43                var pre_translated = jQuery("#"+transposh_params.prefix + segment_id).html(); 
    4444                var new_text = translation; 
    4545                //reset to the original content - the unescaped version if translation is empty 
     
    4848            } 
    4949            // rewrite text for all matching items at once 
    50                 jQuery("."+transposh_params['prefix']+"t,."+transposh_params['prefix']+"u").filter(function() {return jQuery(this).html() == pre_translated;}).html(new_text) 
     50                jQuery("."+transposh_params.prefix+"t,."+transposh_params.prefix+"u").filter(function() {return jQuery(this).html() == pre_translated;}).html(new_text) 
    5151                        .each(function (i) { // handle the image changes 
    5252                                var img_segment_id = jQuery(this).attr('id').substr(jQuery(this).attr('id').lastIndexOf('_')+1); 
    53                                 jQuery("#"+transposh_params['prefix']+"img_" + img_segment_id).removeClass('tr-icon-yellow').removeClass('tr-icon-green'); 
     53                                jQuery("#"+transposh_params.prefix+"img_" + img_segment_id).removeClass('tr-icon-yellow').removeClass('tr-icon-green'); 
    5454                        if(jQuery.trim(translation).length != 0) { 
    5555                                if (source == 1) { 
    5656                                        //switch to the auto img 
    57                                         jQuery("#"+transposh_params['prefix']+"img_" + img_segment_id).addClass('tr-icon-yellow');                               
     57                                        jQuery("#"+transposh_params.prefix+"img_" + img_segment_id).addClass('tr-icon-yellow'); 
    5858                                } else { 
    5959                                //      switch to the fix img 
    60                                         jQuery("#"+transposh_params['prefix']+"img_" + img_segment_id).addClass('tr-icon-green');                                
     60                                        jQuery("#"+transposh_params.prefix+"img_" + img_segment_id).addClass('tr-icon-green'); 
    6161                                } 
    6262                        } 
     
    6464 
    6565            // Progress bar of saving 
    66             if (transposh_params['progress']) { 
     66            if (transposh_params.progress) { 
    6767                    done_p++; 
    6868                    if (togo > 4) { 
     
    7171                } 
    7272 
    73             //TODO: fix close dialog 
    74                 /*if (typeof cClick == 'function' && source == 0) { 
    75                         cClick(); 
    76                 }*/ 
    7773        }, 
    7874                 
     
    8783//function for auto translation 
    8884function do_auto_translate() { 
    89     if (transposh_params['progress']) { 
    90         togo = jQuery("."+transposh_params['prefix']+"u").size(); 
     85    if (transposh_params.progress) { 
     86        togo = jQuery("."+transposh_params.prefix+"u").size(); 
    9187        // progress bar is for alteast 5 items 
    9288        if (togo > 4) { 
    93             jQuery("#"+transposh_params['prefix']+"credit").after('<div style="float: left;width: 90%;height: 10px" id="progress_bar"/><div style="float:left;width: 90%;height: 10px" id="progress_bar2"/>') 
     89            jQuery("#"+transposh_params.prefix+"credit").after('<div style="float: left;width: 90%;height: 10px" id="progress_bar"/><div style="float:left;width: 90%;height: 10px" id="progress_bar2"/>') 
    9490            jQuery("#progress_bar").progressbar({ 
    9591                value: 0 
     
    10399        var done = 0; 
    104100    } 
    105         jQuery("."+transposh_params['prefix']+"u").each(function (i) { 
     101        jQuery("."+transposh_params.prefix+"u").each(function (i) { 
    106102                var translated_id = jQuery(this).attr('id'); 
    107                 google.language.translate(jQuery(this).text(), "", transposh_params['lang'], function(result) { 
     103                google.language.translate(jQuery(this).text(), "", transposh_params.lang, function(result) { 
    108104                        if (!result.error) { 
    109105                                var segment_id = translated_id.substr(translated_id.lastIndexOf('_')+1); 
    110106                        ajax_translate(jQuery("#"+translated_id).text(),jQuery("<div>"+result.translation+"</div>").text(),1,segment_id); 
    111                         jQuery("#"+translated_id).addClass(transposh_params['prefix']+"t").removeClass(transposh_params['prefix']+"u"); 
    112                 if (transposh_params['progress']) { 
    113                     done = togo - jQuery("."+transposh_params['prefix']+"u").size(); 
     107                        jQuery("#"+translated_id).addClass(transposh_params.prefix+"t").removeClass(transposh_params.prefix+"u"); 
     108                if (transposh_params.progress) { 
     109                    done = togo - jQuery("."+transposh_params.prefix+"u").size(); 
    114110                    if (togo > 4) { 
    115111                        jQuery("#progress_bar").progressbar('value' , done/togo*100); 
     
    133129                        buttons: { 
    134130                                'Discard': function() { 
    135                                         jQuery("#"+transposh_params['prefix']+"translation").data("edit", { changed: false}); 
     131                                        jQuery("#"+transposh_params.prefix+"translation").data("edit", { changed: false}); 
    136132                                        jQuery(this).dialog('close'); 
    137                                         jQuery("#"+transposh_params['prefix']+"d-tabs").dialog('close'); 
     133                                        jQuery("#"+transposh_params.prefix+"d-tabs").dialog('close'); 
    138134                                }, 
    139135                                Cancel: function() { 
     
    146142//Open translation dialog  
    147143function translate_dialog(segment_id) { 
    148         jQuery("#"+transposh_params['prefix']+"d-tabs").remove(); 
    149         jQuery('<div id="'+transposh_params['prefix']+'d-tabs" title="Edit Translation"/>').appendTo("body"); 
    150         jQuery("#"+transposh_params['prefix']+"d-tabs").append('<ul/>').tabs({ cache: true }) 
    151                 .tabs('add',"#"+transposh_params['prefix']+"d-tabs-1",'Translate') 
    152                 .tabs('add',transposh_params['post_url']+'?tr_token_hist='+jQuery("#"+transposh_params['prefix'] + segment_id).attr('token')+'&lang='+transposh_params['lang'],'History') 
     144        jQuery("#"+transposh_params.prefix+"d-tabs").remove(); 
     145        jQuery('<div id="'+transposh_params.prefix+'d-tabs" title="Edit Translation"/>').appendTo("body"); 
     146        jQuery("#"+transposh_params.prefix+"d-tabs").append('<ul/>').tabs({ cache: true }) 
     147                .tabs('add',"#"+transposh_params.prefix+"d-tabs-1",'Translate') 
     148                .tabs('add',transposh_params.post_url+'?tr_token_hist='+jQuery("#"+transposh_params.prefix + segment_id).attr('token')+'&lang='+transposh_params.lang,'History') 
    153149                .css("text-align","left") 
    154150                .css("padding",0) 
     
    156152                        //TODO, formatting here, not server side 
    157153                        jQuery("table",ui.panel).addClass("ui-widget ui-widget-content").css({'width' : '95%', 'padding' : '0'}); 
    158                         jQuery("table thead th:last",ui.panel).after("<th/>"); 
     154                        //jQuery("table thead th:last",ui.panel).after("<th/>"); 
    159155                        jQuery("table thead tr",ui.panel).addClass("ui-widget-header"); 
    160                         jQuery("table tbody tr",ui.panel).append('<td/>'); 
    161                         jQuery("table tbody td[source='1']",ui.panel).append('<img size="16x16" src="'+transposh_params['post_url']+'?tp_gif=y" title="computer" style="display: inline; margin-right: 0.3em;" class="ui-icon ui-icon-gear"/>'); 
    162                         jQuery("table tbody td[source='0']",ui.panel).append('<img size="16x16" src="'+transposh_params['post_url']+'?tp_gif=y" title="human" style="display: inline; margin-right: 0.3em;" class="ui-icon ui-icon-person"/>'); 
    163                         //jQuery("table tbody tr:first td:last",ui.panel).append('<span title="remove this translation" id="'+transposh_params['prefix']+'revert" style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-scissors"/>'); 
    164                         jQuery("#"+transposh_params['prefix']+"revert").click(function () {  
    165                       alert ('hi');  
    166                         }); 
     156                        //jQuery("table tbody tr",ui.panel).append('<td/>'); 
     157                        jQuery("table tbody td[source='1']",ui.panel).append('<img size="16x16" src="'+transposh_params.post_url+'?tp_gif=y" title="computer" style="display: inline; margin-right: 0.3em;" class="ui-icon ui-icon-gear"/>'); 
     158                        jQuery("table tbody td[source='0']",ui.panel).append('<img size="16x16" src="'+transposh_params.post_url+'?tp_gif=y" title="human" style="display: inline; margin-right: 0.3em;" class="ui-icon ui-icon-person"/>'); 
     159                        //jQuery("table tbody tr:first td:last",ui.panel).append('<span title="remove this translation" id="'+transposh_params.prefix+'revert" style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-scissors"/>'); 
     160                        //jQuery("#"+transposh_params.prefix+"revert").click(function () { 
     161                      //alert ('hi'); 
     162                        //}); 
    167163                }) 
    168164                .bind('tabsselect', function(event, ui) { 
    169165                        // Change buttons 
    170166                        if (jQuery(ui.tab).text() == 'Translate') { 
    171                                 jQuery("#"+transposh_params['prefix']+"d-tabs").dialog('option', 'buttons', tButtons); 
     167                                jQuery("#"+transposh_params.prefix+"d-tabs").dialog('option', 'buttons', tButtons); 
    172168                        } else { 
    173                                 jQuery("#"+transposh_params['prefix']+"d-tabs").dialog('option', 'buttons', hButtons); 
     169                                jQuery("#"+transposh_params.prefix+"d-tabs").dialog('option', 'buttons', hButtons); 
    174170                        } 
    175171                }) 
    176172                .bind('dialogbeforeclose', function(event, ui) { 
    177                         if(jQuery("#"+transposh_params['prefix']+"translation").data("edit").changed) { 
     173                        if(jQuery("#"+transposh_params.prefix+"translation").data("edit").changed) { 
    178174                                confirm_close(); 
    179175                                return false; 
     
    182178                }); 
    183179        // fix for templates messing with li 
    184         jQuery("#"+transposh_params['prefix']+"d-tabs li").css("list-style-type","none").css("list-style-position","outside"); 
    185         jQuery("#"+transposh_params['prefix']+"d-tabs-1").append( 
    186                         '<form id="'+transposh_params['prefix']+'form">' +       
     180        jQuery("#"+transposh_params.prefix+"d-tabs li").css("list-style-type","none").css("list-style-position","outside"); 
     181        jQuery("#"+transposh_params.prefix+"d-tabs-1").append( 
     182                        '<form id="'+transposh_params.prefix+'form">' + 
    187183                        '<fieldset>' + 
    188184                        '<label for="original">Original Text</label>' + 
    189                         '<textarea cols="80" row="3" name="original" id="'+transposh_params['prefix']+'original" class="text ui-widget-content ui-corner-all" readonly="y"/>' + 
     185                        '<textarea cols="80" row="3" name="original" id="'+transposh_params.prefix+'original" class="text ui-widget-content ui-corner-all" readonly="y"/>' + 
    190186                        '<label for="translation">Translate To</label>' + 
    191                         '<textarea cols="80" row="3" name="translation" id="'+transposh_params['prefix']+'translation" value="" class="text ui-widget-content ui-corner-all"/>' + 
     187                        '<textarea cols="80" row="3" name="translation" id="'+transposh_params.prefix+'translation" value="" class="text ui-widget-content ui-corner-all"/>' + 
    192188                        '</fieldset>' + 
    193189                        '</form>'); 
    194         jQuery("#"+transposh_params['prefix']+"d-tabs-1 label").css("display","block"); 
    195         jQuery("#"+transposh_params['prefix']+"d-tabs-1 textarea.text").css({'margin-bottom':'12px', 'width' : '95%', 'padding' : '.4em'}); 
    196         jQuery("#"+transposh_params['prefix']+"original").val(jQuery("#"+transposh_params['prefix'] + segment_id).attr('orig')); 
    197         jQuery("#"+transposh_params['prefix']+"translation").val(jQuery("#"+transposh_params['prefix'] + segment_id).html()); 
    198         jQuery("#"+transposh_params['prefix']+"translation").data("edit", { changed: false}); 
    199         jQuery("#"+transposh_params['prefix']+"translation").keyup(function(e){ 
    200                 if (jQuery("#"+transposh_params['prefix'] + segment_id).text() != jQuery(this).val()) { 
     190        jQuery("#"+transposh_params.prefix+"d-tabs-1 label").css("display","block"); 
     191        jQuery("#"+transposh_params.prefix+"d-tabs-1 textarea.text").css({'margin-bottom':'12px', 'width' : '95%', 'padding' : '.4em'}); 
     192        jQuery("#"+transposh_params.prefix+"original").val(jQuery("#"+transposh_params.prefix + segment_id).attr('orig')); 
     193        jQuery("#"+transposh_params.prefix+"translation").val(jQuery("#"+transposh_params.prefix + segment_id).html()); 
     194        jQuery("#"+transposh_params.prefix+"translation").data("edit", { changed: false}); 
     195        jQuery("#"+transposh_params.prefix+"translation").keyup(function(e){ 
     196                if (jQuery("#"+transposh_params.prefix + segment_id).text() != jQuery(this).val()) { 
    201197                        jQuery(this).css("background","yellow"); 
    202198                        jQuery(this).data("edit", { changed: true}); 
     
    206202                } 
    207203    }); 
    208         var tButtons =  { 
     204    var tButtons; 
     205    if (google.language.isTranslatable(transposh_params.lang) || transposh_params.lang == 'he') { 
     206        tButtons =      { 
    209207                        'Suggest - Google': function() { 
    210208                                getgt(); 
    211209                        }, 
    212210                        Ok: function() { 
    213                                 var translation = jQuery('#'+transposh_params['prefix']+'translation').val(); 
    214                                 if(jQuery('#'+transposh_params['prefix']+'translation').data("edit").changed) { 
    215                                         ajax_translate(jQuery("#"+transposh_params['prefix'] + segment_id).attr('orig'),translation,0,segment_id); 
    216                                         jQuery("#"+transposh_params['prefix']+"translation").data("edit", { changed: false}); 
     211                                var translation = jQuery('#'+transposh_params.prefix+'translation').val(); 
     212                                if(jQuery('#'+transposh_params.prefix+'translation').data("edit").changed) { 
     213                                        ajax_translate(jQuery("#"+transposh_params.prefix + segment_id).attr('orig'),translation,0,segment_id); 
     214                                        jQuery("#"+transposh_params.prefix+"translation").data("edit", { changed: false}); 
    217215                                } 
    218216                                jQuery(this).dialog('close'); 
    219217                        } 
    220218                };  
     219    }  else { 
     220        tButtons =      { 
     221                        Ok: function() { 
     222                                var translation = jQuery('#'+transposh_params.prefix+'translation').val(); 
     223                                if(jQuery('#'+transposh_params.prefix+'translation').data("edit").changed) { 
     224                                        ajax_translate(jQuery("#"+transposh_params.prefix + segment_id).attr('orig'),translation,0,segment_id); 
     225                                        jQuery("#"+transposh_params.prefix+"translation").data("edit", { changed: false}); 
     226                                } 
     227                                jQuery(this).dialog('close'); 
     228                        } 
     229                }; 
     230    } 
    221231        var hButtons =  { 
    222232                        Close: function() { 
     
    224234                        } 
    225235                };  
    226         jQuery("#"+transposh_params['prefix']+"d-tabs").dialog({ 
     236        jQuery("#"+transposh_params.prefix+"d-tabs").dialog({ 
    227237                bgiframe: true, 
    228238                modal: true, 
     
    254264        function() { 
    255265        // an implicit param 
    256         if (typeof(jQuery().progressbar) != 'undefined') 
    257             transposh_params['progress'] = true; 
    258          
    259                 do_auto_translate(); 
    260                 if (transposh_params['edit']) { 
     266        if (typeof(jQuery().progressbar) != 'undefined') { 
     267            transposh_params.progress = true; 
     268        } 
     269        // TODO: he, iw? :) 
     270        if (google.language.isTranslatable(transposh_params.lang) || transposh_params.lang == 'he') { 
     271            do_auto_translate(); 
     272        } 
     273                if (transposh_params.edit) { 
    261274                        // lets add the images 
    262                         jQuery("."+transposh_params['prefix']+"t,."+transposh_params['prefix']+"u").each(function (i) { 
     275                        jQuery("."+transposh_params.prefix+"t,."+transposh_params.prefix+"u").each(function (i) { 
    263276                                var translated_id = jQuery(this).attr('id').substr(jQuery(this).attr('id').lastIndexOf('_')+1); 
    264                                 jQuery(this).after('<img id="'+transposh_params['prefix']+'img_'+translated_id+'" class="tr-icon" size="12x12" title="'+jQuery(this).attr('orig')+'" src="'+transposh_params['post_url']+'?tp_gif=y"/>'); 
    265                                 jQuery('#'+transposh_params['prefix']+'img_'+translated_id).click(function () { 
     277                                jQuery(this).after('<img id="'+transposh_params.prefix+'img_'+translated_id+'" class="tr-icon" size="12x12" title="'+jQuery(this).attr('orig')+'" src="'+transposh_params.post_url+'?tp_gif=y"/>'); 
     278                                jQuery('#'+transposh_params.prefix+'img_'+translated_id).click(function () { 
    266279                                      translate_dialog(translated_id); 
    267280                                      return false; 
    268                                       }); 
    269                                 if (jQuery(this).hasClass(transposh_params['prefix']+'t')) { 
     281                                      }).css({'border':'0px','margin':'1px','padding':'0px'}); 
     282                                if (jQuery(this).hasClass(transposh_params.prefix+'t')) { 
    270283                                if (jQuery(this).attr('source') == '1') 
    271                                         jQuery('#'+transposh_params['prefix']+'img_'+translated_id).addClass('tr-icon-yellow'); 
     284                                        jQuery('#'+transposh_params.prefix+'img_'+translated_id).addClass('tr-icon-yellow'); 
    272285                                else 
    273                                         jQuery('#'+transposh_params['prefix']+'img_'+translated_id).addClass('tr-icon-green'); 
     286                                        jQuery('#'+transposh_params.prefix+'img_'+translated_id).addClass('tr-icon-green'); 
    274287                                } 
    275288                        }); 
  • trunk/WordPress/plugin/transposh/readme.txt

    r149 r167  
    81811. Enabling automatic translation will automatically translate a page (without requiring entering edit mode) for EVERYONE viewing the page regardless of the their role. However it will only take place for languages marked as editable. 
    8282 
    83 If everything is setup correctly and still nothing happens, please contact us. 
     83Also - please take extra care to validate your html, adding extra tags that are unclosed in the template may lead to our parser breaking. Use the w3c validator service for more details. If everything is setup correctly and still nothing happens, please contact us. 
    8484 
    8585== Screenshots == 
     
    9393== Release notes == 
    9494 
     95* 2009/04/30 - 0.1.4 
     96 * Moved to jQuery UI instead of overlibmws 
     97 * Reduced code generated for faster page loading 
     98 * History is now visible for translated phrases 
     99 * An optional progress bar shows advancing auto-translation 
     100 * Script is now minified by default 
     101 * Better support for not-auto-translatable languages, added islandic 
    95102* 2009/04/02 - 0.1.3 
    96103 * Fix for mysql 4.1 (thanks [Amit](http://landscaping-blog.com/)) 
  • trunk/WordPress/plugin/transposh/transposh.php

    r165 r167  
    22/* 
    33        Plugin Name: Transposh Translation Filter 
    4         Plugin URI: http://transposh.org/# 
     4        Plugin URI: http://transposh.org/ 
    55        Description: Translation filter for WordPress, After enabling please set languages at the <a href="options-general.php?page=Transposh">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>. 
    66        Author: Team Transposh 
  • trunk/WordPress/plugin/transposh/transposh_admin.php

    r140 r167  
    9191        { 
    9292                echo '<th>Language</th><th>Viewable</th><th>Translatable</th>'. 
    93              '<th>Default</th><th style="padding-right: 80px"></th>'; 
     93             '<th>Default</th><th>Auto?</th><th style="padding-right: 80px"></th>'; 
    9494        } 
    9595 
     
    9898        foreach($languages as $code => $lang) 
    9999        { 
    100                 list ($language,$flag) = explode (",",$lang); 
     100                list ($language,$flag,$autot) = explode (",",$lang); 
    101101                if($i % $columns == 0) 
    102102                { 
     
    116116                echo "<td align=\"center\"><input type=\"radio\" name=\"default_lang\" value=\"$code\" " . 
    117117                is_default_lang($code). "/></td>"; 
     118        // TODO: Add icons? 
     119        if ($autot) { 
     120            echo "<td>Y</td>"; 
     121        } else { 
     122            echo "<td>N</td>"; 
     123        } 
    118124 
    119125                if($i % $columns == 0) 
  • trunk/WordPress/plugin/transposh/transposh_widget.php

    r165 r167  
    113113 
    114114    $is_showing_languages = FALSE; 
     115    //TODO: improve this shortening 
     116    $plugpath = parse_url($plugin_url, PHP_URL_PATH); 
    115117 
    116118        echo $before_widget . $before_title . __("Translation") . $after_title; 
     
    137139                                        $page_url2 = $page_url; 
    138140                                } 
    139  
    140                                         echo "<a href=\"" . $page_url2 . "\">". 
    141                          "<img src=\"$plugin_url/img/flags/$flag.png\" title=\"$language\" alt=\"$language\"". 
    142                          " style=\"padding: 1px 3px\"/></a>"; 
     141                    //TODO: improve this hacky! shortening 
     142                    $urlpath = parse_url($page_url2, PHP_URL_PATH); 
     143                    if (trim(parse_url($page_url2, PHP_URL_QUERY)) != '') 
     144                        $urlpath .= '?'.parse_url($page_url2, PHP_URL_QUERY); 
     145                    if (trim(parse_url($page_url2, PHP_URL_FRAGMENT)) != '') 
     146                        $urlpath .= '#'.parse_url($page_url2, PHP_URL_FRAGMENT); 
     147 
     148                                        echo "<a href=\"" . $urlpath . "\">". 
     149                         "<img src=\"$plugpath/img/flags/$flag.png\" title=\"$language\" alt=\"$language\"". 
     150                         " style=\"padding: 1px 3px;border: 0px\"/></a>"; 
    143151                    $is_showing_languages = TRUE; 
    144152                                } 
     
    148156                        // this is the form for the edit... 
    149157                        echo "<form action=\"$page_url\" method=\"post\">"; 
    150                         echo "<input type=\"hidden\" name=\"lang\"      id=\"lang\" value=\"$lang\"/>"; 
     158                        echo "<input type=\"hidden\" name=\"lang\" id=\"lang\" value=\"$lang\"/>"; 
    151159                        break; 
    152160                default: // language list 
     
    197205    echo "</form>"; 
    198206    //echo "<button onClick=\"do_auto_translate();\">translate all</button>"; 
    199         echo "<div id=\"".SPAN_PREFIX."credit\">by <a href=\"http://transposh.org\"><img src=\"$plugin_url/img/tplogo.png\" title=\"Transposh\" alt=\"Transposh\"/></a></div>"; 
     207        echo "<div id=\"".SPAN_PREFIX."credit\">by <a href=\"http://transposh.org\"><img src=\"$plugpath/img/tplogo.png\" title=\"Transposh\" alt=\"Transposh\"/></a></div>"; 
    200208    echo $after_widget; 
    201209} 
Note: See TracChangeset for help on using the changeset viewer.