Transposh WordPress Translation - Version 0.4.2

Version Description

This version provides Haitian support, auto translate with bing support

Download this release

Release Info

Developer oferwald
Plugin Icon 128x128 Transposh WordPress Translation
Version 0.4.2
Comparing to
See all releases

Code changes from version 0.4.1 to 0.4.2

core/constants.php CHANGED
@@ -50,6 +50,7 @@ $languages = array(
50
  "gl" => "Galician,Galego,galicia",
51
  "de" => "German,Deutsch,de",
52
  "el" => "Greek,Ελληνικά,gr",
 
53
  "he" => "Hebrew,עברית,il",
54
  "hi" => "Hindi,हिन्दी; हिंदी,in",
55
  "hu" => "Hungarian,magyar,hu",
@@ -91,12 +92,12 @@ $rtl_languages = array("ar", "he", "fa", "yi");
91
  //Google supported languages @updated 2009-Dec-21
92
  $google_languages = array("en", "af", "sq", "ar", "be", "bg", "ca", "zh", "zh-tw", "hr", "cs", "da", "nl", "et", "fi", "fr", "gl", "de", "el", "he", "hi", "hu", "id", "it", "is", "ga", "ja", "ko", "lv", "lt", "mk", "ms", "mt", "no", "fa", "pl", "pt", "ro", "ru", "sr", "sk", "sl", "es", "sw", "sv", "tl", "th", "tr", "uk", "vi", "cy", "yi");
93
  //Bing supported languages @updated 2009-Dec-21
94
- $bing_languages = array("en", "ar", "bg", "zh", "zh-tw", "cs", "da", "nl", "fi", "fr", "de", "gr", "he", "it", "ja", "ko", "pl", "pt", "ru", "es", "sv", "th");
95
 
96
  //Define the new capability that will be assigned to roles - translator
97
  define("TRANSLATOR", 'translator');
98
 
99
- define("TRANSPOSH_PLUGIN_VER",'0.4.1');
100
 
101
  //Define segment id prefix, will be included in span tag. also used as class identifier
102
  define("SPAN_PREFIX", "tr_");
50
  "gl" => "Galician,Galego,galicia",
51
  "de" => "German,Deutsch,de",
52
  "el" => "Greek,Ελληνικά,gr",
53
+ "ht" => "Haitian,Kreyòl ayisyen,ht",
54
  "he" => "Hebrew,עברית,il",
55
  "hi" => "Hindi,हिन्दी; हिंदी,in",
56
  "hu" => "Hungarian,magyar,hu",
92
  //Google supported languages @updated 2009-Dec-21
93
  $google_languages = array("en", "af", "sq", "ar", "be", "bg", "ca", "zh", "zh-tw", "hr", "cs", "da", "nl", "et", "fi", "fr", "gl", "de", "el", "he", "hi", "hu", "id", "it", "is", "ga", "ja", "ko", "lv", "lt", "mk", "ms", "mt", "no", "fa", "pl", "pt", "ro", "ru", "sr", "sk", "sl", "es", "sw", "sv", "tl", "th", "tr", "uk", "vi", "cy", "yi");
94
  //Bing supported languages @updated 2009-Dec-21
95
+ $bing_languages = array("en", "ar", "bg", "zh", "zh-tw", "cs", "da", "nl", "ht", "fi", "fr", "de", "gr", "he", "it", "ja", "ko", "pl", "pt", "ru", "es", "sv", "th");
96
 
97
  //Define the new capability that will be assigned to roles - translator
98
  define("TRANSLATOR", 'translator');
99
 
100
+ define("TRANSPOSH_PLUGIN_VER",'0.4.2');
101
 
102
  //Define segment id prefix, will be included in span tag. also used as class identifier
103
  define("SPAN_PREFIX", "tr_");
core/parser.php CHANGED
@@ -34,6 +34,8 @@ class parserstats {
34
  public $hidden_phrases;
35
  /** @var int Holds the number of phrases that are hidden and translated */
36
  public $hidden_translated_phrases;
 
 
37
 
38
  /** @var int Holds the number of phrases that are hidden and probably won't be viewed - such as meta keys */
39
  public $meta_phrases;
@@ -502,15 +504,15 @@ class parser {
502
  if ($source == 0) $this->stats->human_translated_phrases++;
503
  }
504
  if (($this->is_edit_mode || ($this->is_auto_translate && $translated_text == null))/* && $ep->inbody*/) {
505
- $span = $this->create_edit_span($ep->phrase, $translated_text, $source);
506
  $spanend = "</span>";
507
  if ($ep->inselect || !$ep->inbody) {
508
  $savedspan .= $this->create_edit_span($ep->phrase, $translated_text, $source,true).$spanend;
509
  $span = '';
510
  $spanend = '';
 
 
 
511
  }
512
- else
513
- if ($translated_text == null) $translated_text = $ep->phrase;
514
  }
515
  else {
516
  $span = '';
@@ -563,6 +565,7 @@ class parser {
563
  if (strpos($e->innertext,base64_url_encode($ep->phrase)) === false) {
564
  //no need to translate span the same hidden phrase more than once
565
  if (!in_array($ep->phrase, $hidden_phrases)) {
 
566
  $span .= $this->create_edit_span($ep->phrase, $translated_text, $source, true)."</span>";
567
  //
568
  $hidden_phrases[] = $ep->phrase;
34
  public $hidden_phrases;
35
  /** @var int Holds the number of phrases that are hidden and translated */
36
  public $hidden_translated_phrases;
37
+ /** @var int Holds the amounts of hidden spans created for translation */
38
+ public $hidden_translateable_phrases;
39
 
40
  /** @var int Holds the number of phrases that are hidden and probably won't be viewed - such as meta keys */
41
  public $meta_phrases;
504
  if ($source == 0) $this->stats->human_translated_phrases++;
505
  }
506
  if (($this->is_edit_mode || ($this->is_auto_translate && $translated_text == null))/* && $ep->inbody*/) {
 
507
  $spanend = "</span>";
508
  if ($ep->inselect || !$ep->inbody) {
509
  $savedspan .= $this->create_edit_span($ep->phrase, $translated_text, $source,true).$spanend;
510
  $span = '';
511
  $spanend = '';
512
+ } else {
513
+ $span = $this->create_edit_span($ep->phrase, $translated_text, $source);
514
+ if ($translated_text == null) $translated_text = $ep->phrase;
515
  }
 
 
516
  }
517
  else {
518
  $span = '';
565
  if (strpos($e->innertext,base64_url_encode($ep->phrase)) === false) {
566
  //no need to translate span the same hidden phrase more than once
567
  if (!in_array($ep->phrase, $hidden_phrases)) {
568
+ $this->stats->hidden_translateable_phrases++;
569
  $span .= $this->create_edit_span($ep->phrase, $translated_text, $source, true)."</span>";
570
  //
571
  $hidden_phrases[] = $ep->phrase;
css/transposh_flags.css CHANGED
@@ -1 +1 @@
1
- .transposh_flags{direction:ltr;line-height:0;}.transposh_flags a{display:inline;}.transposh_flags a:hover{background:transparent;}.transposh_flags a span,.transposh_flags a img{border-color:transparent;border-style:solid;border-width:1px 3px;padding:0;}.transposh_flags a span:hover,.transposh_flags a img:hover{border-color:blue;}.trf{background-image:url(../img/flags.png);height:11px;width:16px;background-repeat:no-repeat;overflow:hidden;display:inline-block;}.trf-za{background-position:-24px 0;}.trf-al{background-position:-48px 0;}.trf-sa{background-position:-72px 0;}.trf-by{background-position:-96px 0;}.trf-bg{background-position:-120px 0;}.trf-catalonia{background-position:-144px 0;}.trf-cn{background-position:-168px 0;}.trf-tw{background-position:-192px 0;}.trf-hr{background-position:-216px 0;}.trf-cz{background-position:-240px 0;}.trf-dk{background-position:-264px 0;}.trf-nl{background-position:-288px 0;}.trf-ee{background-position:-312px 0;}.trf-fi{background-position:-336px 0;}.trf-fr{background-position:-360px 0;}.trf-galicia{background-position:-384px 0;}.trf-de{background-position:-408px 0;}.trf-gr{background-position:-432px 0;}.trf-il{background-position:-456px 0;}.trf-in{background-position:-480px 0;}.trf-hu{background-position:-504px 0;}.trf-id{background-position:-528px 0;}.trf-it{background-position:-552px 0;}.trf-is{background-position:-576px 0;}.trf-ie{background-position:-600px 0;}.trf-jp{background-position:-624px 0;}.trf-kr{background-position:-648px 0;}.trf-lv{background-position:-672px 0;}.trf-lt{background-position:-696px 0;}.trf-mk{background-position:-720px 0;}.trf-my{background-position:-744px 0;}.trf-mt{background-position:-768px 0;}.trf-no{background-position:-792px 0;}.trf-ir{background-position:-816px 0;}.trf-pl{background-position:-840px 0;}.trf-pt{background-position:-864px 0;}.trf-ro{background-position:-888px 0;}.trf-ru{background-position:-912px 0;}.trf-rs{background-position:-936px 0;}.trf-sk{background-position:-960px 0;}.trf-sl{background-position:-984px 0;}.trf-es{background-position:-1008px 0;}.trf-ke{background-position:-1032px 0;}.trf-se{background-position:-1056px 0;}.trf-ph{background-position:-1080px 0;}.trf-th{background-position:-1104px 0;}.trf-tr{background-position:-1128px 0;}.trf-ua{background-position:-1152px 0;}.trf-vn{background-position:-1176px 0;}.trf-wales{background-position:-1200px 0;}.trf-europeanunion{background-position:-1224px 0;}
1
+ .transposh_flags{direction:ltr;line-height:0;}.transposh_flags a{display:inline;}.transposh_flags a:hover{background:transparent;}.transposh_flags a span,.transposh_flags a img{border-color:transparent;border-style:solid;border-width:1px 3px;padding:0;}.transposh_flags a span:hover,.transposh_flags a img:hover{border-color:blue;}.trf{background-image:url(../img/flags.png);height:11px;width:16px;background-repeat:no-repeat;overflow:hidden;display:inline-block;}.trf-za{background-position:-24px 0;}.trf-al{background-position:-48px 0;}.trf-sa{background-position:-72px 0;}.trf-by{background-position:-96px 0;}.trf-bg{background-position:-120px 0;}.trf-catalonia{background-position:-144px 0;}.trf-cn{background-position:-168px 0;}.trf-tw{background-position:-192px 0;}.trf-hr{background-position:-216px 0;}.trf-cz{background-position:-240px 0;}.trf-dk{background-position:-264px 0;}.trf-nl{background-position:-288px 0;}.trf-ee{background-position:-312px 0;}.trf-fi{background-position:-336px 0;}.trf-fr{background-position:-360px 0;}.trf-galicia{background-position:-384px 0;}.trf-de{background-position:-408px 0;}.trf-gr{background-position:-432px 0;}.trf-ht{background-position:-456px 0;}.trf-il{background-position:-480px 0;}.trf-in{background-position:-504px 0;}.trf-hu{background-position:-528px 0;}.trf-id{background-position:-552px 0;}.trf-it{background-position:-576px 0;}.trf-is{background-position:-600px 0;}.trf-ie{background-position:-624px 0;}.trf-jp{background-position:-648px 0;}.trf-kr{background-position:-672px 0;}.trf-lv{background-position:-696px 0;}.trf-lt{background-position:-720px 0;}.trf-mk{background-position:-744px 0;}.trf-my{background-position:-768px 0;}.trf-mt{background-position:-792px 0;}.trf-no{background-position:-816px 0;}.trf-ir{background-position:-840px 0;}.trf-pl{background-position:-864px 0;}.trf-pt{background-position:-888px 0;}.trf-ro{background-position:-912px 0;}.trf-ru{background-position:-936px 0;}.trf-rs{background-position:-960px 0;}.trf-sk{background-position:-984px 0;}.trf-sl{background-position:-1008px 0;}.trf-es{background-position:-1032px 0;}.trf-ke{background-position:-1056px 0;}.trf-se{background-position:-1080px 0;}.trf-ph{background-position:-1104px 0;}.trf-th{background-position:-1128px 0;}.trf-tr{background-position:-1152px 0;}.trf-ua{background-position:-1176px 0;}.trf-vn{background-position:-1200px 0;}.trf-wales{background-position:-1224px 0;}.trf-europeanunion{background-position:-1248px 0;}
img/flags.png CHANGED
Binary file
js/transposh.js CHANGED
@@ -1,18 +1,8 @@
1
- (function(){function m(){if(typeof google==="undefined"){j=function(){m()};jQuery.xLazyLoader({js:"http://www.google.com/jsapi",success:k})}else{jQuery(":button:contains('Suggest - Google')").attr("disabled","disabled").addClass("ui-state-disabled");google.language.translate(jQuery("#"+t_jp.prefix+"original").val(),"",t_jp.lang,function(a){a.error||jQuery("#"+t_jp.prefix+"translation").val(jQuery("<div>"+a.translation+"</div>").text()).keyup()})}}function n(){if(typeof Microsoft==="undefined")jQuery.xLazyLoader({js:"http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId="+
2
- t_jp.msnkey,success:function(){n()}});else{jQuery(":button:contains('Suggest - Bing')").attr("disabled","disabled").addClass("ui-state-disabled");var a=t_jp.lang;if(a==="zh")a="zh-chs";if(a==="zh-tw")a="zh-cht";try{Microsoft.Translator.translate(jQuery("#"+t_jp.prefix+"original").val(),"",a,function(e){jQuery("#"+t_jp.prefix+"translation").val(jQuery("<div>"+e+"</div>").text()).keyup()})}catch(b){alert("There was an error using Microsoft.Translator - probably a bad key or URL used in key. ("+b+")")}}}
3
- function u(a,b,e){var c=jQuery("#"+t_jp.prefix+e).attr("token"),d=a;if(jQuery.trim(a).length===0)d=jQuery("#"+t_jp.prefix+e).attr("orig");jQuery("*[token='"+c+"'][hidden!='y']").html(d).each(function(){var f=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1),g=jQuery("#"+t_jp.prefix+"img_"+f);jQuery("#"+t_jp.prefix+f).attr("source",b);g.removeClass("tr-icon-yellow").removeClass("tr-icon-green");if(jQuery.trim(a).length!==0)b===1?g.addClass("tr-icon-yellow"):g.addClass("tr-icon-green")});
4
- jQuery("*[token='"+c+"'][hidden='y']").attr("trans",d).each(function(){var f=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1),g=jQuery("#"+t_jp.prefix+"img_"+f);jQuery("#"+t_jp.prefix+f).attr("source",b);g.removeClass("tr-icon-yellow").removeClass("tr-icon-green");if(jQuery.trim(a).length!==0)b===1?g.addClass("tr-icon-yellow"):g.addClass("tr-icon-green")})}function o(a,b,e){clearTimeout(p);i.push(jQuery("#"+t_jp.prefix+e).attr("token"));l.push(a);u(a,b,e);p=setTimeout(function(){var c=
5
- {lang:t_jp.lang,source:b,translation_posted:"1",items:i.length},d;for(d=0;d<i.length;d+=1){c["tk"+d]=i[d];c["tr"+d]=l[d];if(b>0)q+=jQuery("*[token='"+i[d]+"']").size()}jQuery.ajax({type:"POST",url:t_jp.post_url,data:c,success:function(){t_jp.progress&&h>4&&b>0&&jQuery("#progress_bar2").progressbar("value",q/h*100)},error:function(f){b===0&&alert("Error !!! failed to translate.\n\nServer's message: "+f.statusText)}});l=[];i=[]},200)}function r(){var a=[],b;if(t_jp.progress){h=jQuery("."+t_jp.prefix+
6
- '[source=""]').size();if(h>4){jQuery("#"+t_jp.prefix+"credit").append('<div style="float: left;width: 90%;height: 10px" id="progress_bar"/><div style="margin-bottom:10px;float:left;width: 90%;height: 10px" id="progress_bar2"/>');jQuery("#progress_bar").progressbar({value:0});jQuery("#progress_bar2").progressbar({value:0});jQuery("#progress_bar2 > div").css({background:"#28F828",border:"#08A908 1px solid"})}b=0}jQuery("."+t_jp.prefix+'[source=""]').each(function(){var e=jQuery(this).attr("id"),c=jQuery(this).attr("orig");
7
- if(c===undefined)c=jQuery(this).html();if(a[c]!==1){a[c]=1;google.language.translate(c,"",t_jp.lang,function(d){if(!d.error){var f=e.substr(e.lastIndexOf("_")+1);o(jQuery("<div>"+d.translation+"</div>").text(),1,f);if(t_jp.progress){b=h-jQuery("."+t_jp.prefix+'[source=""]').size();h>4&&jQuery("#progress_bar").progressbar("value",b/h*100)}}})}})}function v(){jQuery('<div id="dial" title="Close without saving?"><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>You have made a change to the translation. Are you sure you want to discard it?</p></div>').appendTo("body").dialog({bgiframe:true,
8
- resizable:false,height:140,modal:true,overlay:{backgroundColor:"#000",opacity:0.5},buttons:{Discard:function(){jQuery("#"+t_jp.prefix+"translation").data("edit",{changed:false});jQuery(this).dialog("close");jQuery("#"+t_jp.prefix+"d-tabs").dialog("close")},Cancel:function(){jQuery(this).dialog("close")}}})}function s(a){var b={},e={};if(w.indexOf(t_jp.lang)>-1&&t_jp.msnkey!=="")b["Suggest - Bing"]=function(){n()};if(t.indexOf(t_jp.lang)>-1)b["Suggest - Google"]=function(){m()};b.Ok=function(){var c=
9
- jQuery("#"+t_jp.prefix+"translation").val();if(jQuery("#"+t_jp.prefix+"translation").data("edit").changed){o(c,0,a);jQuery("#"+t_jp.prefix+"translation").data("edit",{changed:false})}jQuery(this).dialog("close")};e={Close:function(){jQuery(this).dialog("close")}};jQuery("#"+t_jp.prefix+"d-tabs").remove();jQuery('<div id="'+t_jp.prefix+'d-tabs" title="Edit Translation"/>').appendTo("body");jQuery("#"+t_jp.prefix+"d-tabs").append("<ul/>").tabs({cache:true}).tabs("add","#"+t_jp.prefix+"d-tabs-1","Translate").tabs("add",
10
- t_jp.post_url+"?tr_token_hist="+jQuery("#"+t_jp.prefix+a).attr("token")+"&lang="+t_jp.lang,"History").css("text-align","left").css("padding",0).bind("tabsload",function(c,d){jQuery("table",d.panel).addClass("ui-widget ui-widget-content").css({width:"95%",padding:"0"});jQuery("table thead tr",d.panel).addClass("ui-widget-header");jQuery("table tbody td[source='1']",d.panel).append('<span title="computer" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-gear"></span>');jQuery("table tbody td[source='0']",
11
- d.panel).append('<span title="human" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-person"></span>')}).bind("tabsselect",function(c,d){jQuery(d.tab).text()==="Translate"?jQuery("#"+t_jp.prefix+"d-tabs").dialog("option","buttons",b):jQuery("#"+t_jp.prefix+"d-tabs").dialog("option","buttons",e)}).bind("dialogbeforeclose",function(){if(jQuery("#"+t_jp.prefix+"translation").data("edit").changed){v();return false}return true});jQuery("#"+t_jp.prefix+"d-tabs li").css("list-style-type",
12
- "none").css("list-style-position","outside");jQuery("#"+t_jp.prefix+"d-tabs-1").css("padding","1px").append('<form id="'+t_jp.prefix+'form"><fieldset><label for="original">Original Text</label><textarea cols="80" row="3" name="original" id="'+t_jp.prefix+'original" class="text ui-widget-content ui-corner-all" readonly="y"/><label for="translation">Translate To</label><textarea cols="80" row="3" name="translation" id="'+t_jp.prefix+'translation" value="" class="text ui-widget-content ui-corner-all"/></fieldset></form>');
13
- jQuery("#"+t_jp.prefix+"d-tabs-1 label").css("display","block");jQuery("#"+t_jp.prefix+"d-tabs-1 textarea.text").css({"margin-bottom":"12px",width:"95%",padding:".4em"});jQuery("#"+t_jp.prefix+"original").val(jQuery("#"+t_jp.prefix+a).attr("orig"));jQuery("#"+t_jp.prefix+"translation").val(jQuery("#"+t_jp.prefix+a).html());jQuery("#"+t_jp.prefix+a).attr("trans")&&jQuery("#"+t_jp.prefix+"translation").val(jQuery("#"+t_jp.prefix+a).attr("trans"));jQuery("#"+t_jp.prefix+"translation").data("edit",{changed:false});
14
- jQuery("#"+t_jp.prefix+"translation").keyup(function(){if(jQuery("#"+t_jp.prefix+a).text()!==jQuery(this).val()){jQuery(this).css("background","yellow");jQuery(this).data("edit",{changed:true})}else{jQuery(this).css("background","");jQuery(this).data("edit",{changed:false})}});jQuery("#"+t_jp.prefix+"d-tabs").dialog({bgiframe:true,modal:true,width:500,buttons:b})}var j,k,q=0,h=0,p,i=[],l=[],t="af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt",
15
- w="ar,bg,zh-chs,zh-cht,cs,da,nl,en,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw";jQuery.noConflict();k=function(){google.load("language","1",{callback:j})};jQuery(document).ready(function(){jQuery("#"+t_jp.prefix+"setdeflang").click(function(){jQuery.get(t_jp.post_url+"?tr_cookie="+Math.random());jQuery(this).hide("slow");return false});var a=window.eval("("+jQuery("meta[name=translation-stats]").attr("content")+")"),b;if(a!==undefined){a=a.total_phrases-a.translated_phrases-(a.meta_phrases-
16
- a.meta_translated_phrases);b=new Date;if((a>5||b.getHours()===4&&a>0)&&t.indexOf(t_jp.lang)>-1){jQuery.ajaxSetup({cache:true});j=function(){t_jp.progress?jQuery.getScript(t_jp.plugin_url+"/js/lazy.js",function(){jQuery.xLazyLoader({js:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",css:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",success:function(){r()}})}):r()};jQuery.getScript("http://www.google.com/jsapi",k)}}t_jp.edit&&jQuery("."+
17
- t_jp.prefix).each(function(){var e=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1),c;jQuery(this).after('<span id="'+t_jp.prefix+"img_"+e+'" class="tr-icon" title="'+jQuery(this).attr("orig")+'"></span>');c=jQuery("#"+t_jp.prefix+"img_"+e);c.click(function(){if(typeof jQuery.fn.tabs!=="function"){jQuery.ajaxSetup({cache:true});jQuery.getScript(t_jp.plugin_url+"/js/lazy.js",function(){jQuery.xLazyLoader({js:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",
18
- css:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",success:function(){s(e)}})})}else s(e);return false}).css({border:"0px",margin:"1px",padding:"0px"});if(jQuery(this).attr("source")==="1")c.addClass("tr-icon-yellow");else jQuery(this).attr("source")==="0"&&c.addClass("tr-icon-green");jQuery(this).attr("hidden")==="y"&&c.css({opacity:"0.6"})})})})();
1
+ (function(){function u(c,b){if(jQuery.trim(b).length!==0){var e=function(){var a=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1),n=jQuery("#"+d+"img_"+a);jQuery("#"+d+a).attr("source",1);n.removeClass("tr-icon-yellow").removeClass("tr-icon-green").addClass("tr-icon-yellow")};jQuery("*[token='"+c+"'][hidden!='y']").html(b).each(e);jQuery("*[token='"+c+"'][hidden='y']").attr("trans",b).each(e)}}function o(c,b){clearTimeout(p);g.push(c);k.push(b);u(c,b);p=setTimeout(function(){var e=
2
+ {ln0:t_jp.lang,sr0:q,translation_posted:"2",items:g.length},a;for(a=0;a<g.length;a+=1){e["tk"+a]=g[a];e["tr"+a]=k[a];r+=jQuery("*[token='"+g[a]+"']").size()}jQuery.ajax({type:"POST",url:t_jp.post_url,data:e,success:function(){jQuery("#"+i).progressbar("value",r/f*100)}});k=[];g=[]},200)}function v(){jQuery("#"+d+"credit").css({overflow:"auto"}).append('<div style="float: left;width: 90%;height: 10px" id="'+h+'"/><div style="margin-bottom:10px;float:left;width: 90%;height: 10px" id="'+i+'"/>');jQuery("#"+
3
+ h).progressbar({value:0});jQuery("#"+i).progressbar({value:0});jQuery("#"+i+" > div").css({background:"#28F828",border:"#08A908 1px solid"})}function s(){var c=[],b=t_jp.lang;jQuery("."+d+'[source=""]').each(function(){var e=jQuery(this).attr("token"),a=jQuery(this).attr("orig");if(a===undefined)a=jQuery(this).html();if(c[a]!==1){c[a]=1;if(typeof Microsoft!=="undefined"){if(b==="zh")b="zh-chs";else if(b==="zh-tw")b="zh-cht";try{Microsoft.Translator.translate(a,"",b,function(j){o(e,jQuery("<div>"+
4
+ j+"</div>").text());jQuery("#"+h).progressbar("value",(f-jQuery("."+d+'[source=""]').size())/f*100)})}catch(n){}}else google.language.translate(a,"",t_jp.lang,function(j){if(!j.error){o(e,jQuery("<div>"+j.translation+"</div>").text());jQuery("#"+h).progressbar("value",(f-jQuery("."+d+'[source=""]').size())/f*100)}})}})}var l,t,m,f,d=t_jp.prefix,h=d+"pbar",i=h+"_s",q=1,r=0,p,g=[],k=[];jQuery.noConflict();t=function(){google.load("language","1",{callback:l})};jQuery(document).ready(function(){jQuery("#"+
5
+ d+"setdeflang").click(function(){jQuery.get(t_jp.post_url+"?tr_cookie="+Math.random());jQuery(this).hide("slow");return false});var c;f=jQuery("."+d+'[source=""]').size();c=new Date;jQuery.ajaxSetup({cache:true});if((f>5||c.getHours()===4&&f>0)&&("af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt".indexOf(t_jp.lang)>-1||"ar,bg,zh-chs,zh-cht,cs,da,nl,en,ht,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw".indexOf(t_jp.lang)>
6
+ -1)){l=function(){if(t_jp.progress){var b=function(){jQuery.xLazyLoader({js:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",css:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",success:function(){v();s()}})};typeof jQuery.xLazyLoader==="function"?b():jQuery.getScript(t_jp.plugin_url+"/js/lazy.js",b)}else s()};if(("ar,bg,zh-chs,zh-cht,cs,da,nl,en,ht,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw".indexOf(t_jp.lang)>-1&&t_jp.preferred===
7
+ 2||"af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt".indexOf(t_jp.lang)<0)&&t_jp.msnkey!==""){q=2;m=function(){jQuery.getScript("http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId="+t_jp.msnkey,l)};t_jp.edit&&t_jp.progress?jQuery.getScript(t_jp.plugin_url+"/js/lazy.js",m):m()}else jQuery.getScript("http://www.google.com/jsapi",t)}t_jp.edit&&jQuery.getScript(t_jp.plugin_url+
8
+ "/js/transposhedit.js")})})();
 
 
 
 
 
 
 
 
 
 
js/transposhadmin.js CHANGED
@@ -1,6 +1,6 @@
1
  var timer,items=0,translations=[],tokens=[],langs=[];
2
- function ajax_translate_me(e,c,b){clearTimeout(timer);items++;tokens.push(e);translations.push(c);langs.push(b);timer=setTimeout(function(){for(var d={sr0:1,translation_posted:"2",items:items},a=0;a<items;a++){if(tokens[a]!=tokens[a-1])d["tk"+a]=tokens[a];if(langs[a]!=langs[a-1])d["ln"+a]=langs[a];if(translations[a]!=translations[a-1])d["tr"+a]=translations[a]}jQuery.ajax({type:"POST",url:transposh_params.post_url,data:d,success:function(){},error:function(){}});translations=[];tokens=[];langs=[]},
3
- 200)}jQuery.noConflict();google.load("language","1");var transposh_params=[],ext_langs="he|zh-tw|pt|fa|af|be|is|ga|mk|ms|sw|ws|cy|yi";jQuery("script[src*='transposhadmin.js']").each(function(){for(var e=unescape(this.src.substring(this.src.indexOf("?")+1)).split("&"),c=0;c<e.length;c++){var b=e[c].indexOf("=");if(b>0){var d=e[c].substring(0,b);b=e[c].substring(b+1);transposh_params[d]=b}}});
4
  jQuery(document).ready(function(){var e=0,c="",b=0;jQuery.getJSON(transposh_params.post_url+"?tr_phrases_post=y&post="+transposh_params.post+"&random="+Math.random(),function(d){if(d==null)jQuery("#tr_loading").replaceWith("Nothing left to translate");else{jQuery("#tr_loading").replaceWith('Translating<br/>Phrase: <span id="p"></span><div id="progress_bar"/>Target lanaguage: <span id="l"></span><div id="progress_bar2"/><span id="r"></span>');jQuery("#progress_bar").progressbar({value:0});jQuery("#progress_bar2").progressbar({value:0});
5
  jQuery.each(d.p,function(a,f){jQuery("#progress_bar2").progressbar("value",b/f.l.length*100);jQuery.each(f.l,function(i,g){google.language.translate(a,"",g,function(h){if(!h.error){if(c!=a){c=a;b=0;e++}jQuery("#progress_bar").progressbar("value",e/d.length*100);b++;jQuery("#progress_bar2").progressbar("value",b/f.l.length*100);jQuery("#p").text(jQuery("<div>"+a+"</div>").text());jQuery("#l").text(g);jQuery("#r").text(jQuery("<div>"+h.translation+"</div>").text());ajax_translate_me(f.t,jQuery("<div>"+
6
  h.translation+"</div>").text(),g)}})})})}})});
1
  var timer,items=0,translations=[],tokens=[],langs=[];
2
+ function ajax_translate_me(e,c,b){clearTimeout(timer);items++;tokens.push(e);translations.push(c);langs.push(b);timer=setTimeout(function(){for(var d={sr0:1,translation_posted:"2",items:items},a=0;a<items;a++){if(tokens[a]!=tokens[a-1])d["tk"+a]=tokens[a];if(langs[a]!=langs[a-1])d["ln"+a]=langs[a];if(translations[a]!=translations[a-1])d["tr"+a]=translations[a]}jQuery.ajax({type:"POST",url:transposh_params.post_url,data:d,success:function(){},error:function(){}});items=0;translations=[];tokens=[];
3
+ langs=[]},200)}jQuery.noConflict();google.load("language","1");var transposh_params=[],ext_langs="he|zh-tw|pt|fa|af|be|is|ga|mk|ms|sw|ws|cy|yi";jQuery("script[src*='transposhadmin.js']").each(function(){for(var e=unescape(this.src.substring(this.src.indexOf("?")+1)).split("&"),c=0;c<e.length;c++){var b=e[c].indexOf("=");if(b>0){var d=e[c].substring(0,b);b=e[c].substring(b+1);transposh_params[d]=b}}});
4
  jQuery(document).ready(function(){var e=0,c="",b=0;jQuery.getJSON(transposh_params.post_url+"?tr_phrases_post=y&post="+transposh_params.post+"&random="+Math.random(),function(d){if(d==null)jQuery("#tr_loading").replaceWith("Nothing left to translate");else{jQuery("#tr_loading").replaceWith('Translating<br/>Phrase: <span id="p"></span><div id="progress_bar"/>Target lanaguage: <span id="l"></span><div id="progress_bar2"/><span id="r"></span>');jQuery("#progress_bar").progressbar({value:0});jQuery("#progress_bar2").progressbar({value:0});
5
  jQuery.each(d.p,function(a,f){jQuery("#progress_bar2").progressbar("value",b/f.l.length*100);jQuery.each(f.l,function(i,g){google.language.translate(a,"",g,function(h){if(!h.error){if(c!=a){c=a;b=0;e++}jQuery("#progress_bar").progressbar("value",e/d.length*100);b++;jQuery("#progress_bar2").progressbar("value",b/f.l.length*100);jQuery("#p").text(jQuery("<div>"+a+"</div>").text());jQuery("#l").text(g);jQuery("#r").text(jQuery("<div>"+h.translation+"</div>").text());ajax_translate_me(f.t,jQuery("<div>"+
6
  h.translation+"</div>").text(),g)}})})})}})});
js/transposhedit.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(){function k(a,b){if(jQuery.trim(b).length===0)b=jQuery("[token='"+a+"']").attr("orig");var d=function(){var e=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1),c=jQuery("#"+t_jp.prefix+"img_"+e);jQuery("#"+t_jp.prefix+e).attr("source",0);c.removeClass("tr-icon-yellow").removeClass("tr-icon-green").addClass("tr-icon-green")};jQuery("*[token='"+a+"'][hidden!='y']").html(b).each(d);jQuery("*[token='"+a+"'][hidden='y']").attr("trans",b).each(d)}function l(a,b){k(a,
2
+ b);jQuery.ajax({type:"POST",url:t_jp.post_url,data:{ln0:t_jp.lang,sr0:0,translation_posted:"2",items:1,tk0:a,tr0:b},success:function(){},error:function(d){alert("Error !!! failed to translate.\n\nServer's message: "+d.statusText)}})}function f(){if(typeof google==="undefined"){g=function(){google.load("language","1",{callback:h})};h=function(){f()};jQuery.xLazyLoader({js:"http://www.google.com/jsapi",success:g})}else{jQuery(":button:contains('Suggest - Google')").attr("disabled","disabled").addClass("ui-state-disabled");
3
+ google.language.translate(jQuery("#"+t_jp.prefix+"original").val(),"",t_jp.lang,function(a){a.error||jQuery("#"+t_jp.prefix+"translation").val(jQuery("<div>"+a.translation+"</div>").text()).keyup()})}}function i(){if(typeof Microsoft==="undefined")jQuery.xLazyLoader({js:"http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId="+t_jp.msnkey,success:function(){i()}});else{jQuery(":button:contains('Suggest - Bing')").attr("disabled","disabled").addClass("ui-state-disabled");var a=t_jp.lang;if(a===
4
+ "zh")a="zh-chs";if(a==="zh-tw")a="zh-cht";try{Microsoft.Translator.translate(jQuery("#"+t_jp.prefix+"original").val(),"",a,function(d){jQuery("#"+t_jp.prefix+"translation").val(jQuery("<div>"+d+"</div>").text()).keyup()})}catch(b){alert("There was an error using Microsoft.Translator - probably a bad key or URL used in key. ("+b+")")}}}function m(){jQuery('<div id="dial" title="Close without saving?"><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>You have made a change to the translation. Are you sure you want to discard it?</p></div>').appendTo("body").dialog({bgiframe:true,
5
+ resizable:false,height:140,modal:true,overlay:{backgroundColor:"#000",opacity:0.5},buttons:{Discard:function(){jQuery("#"+t_jp.prefix+"translation").data("edit",{changed:false});jQuery(this).dialog("close");jQuery("#"+t_jp.prefix+"d-tabs").dialog("close")},Cancel:function(){jQuery(this).dialog("close")}}})}function j(a){var b={},d={};if(n.indexOf(t_jp.lang)>-1&&t_jp.msnkey!=="")b["Suggest - Bing"]=function(){i()};if(o.indexOf(t_jp.lang)>-1)b["Suggest - Google"]=function(){f()};b.Ok=function(){var e=
6
+ jQuery("#"+t_jp.prefix+"translation").val(),c=jQuery("#"+t_jp.prefix+a).attr("token");if(jQuery("#"+t_jp.prefix+"translation").data("edit").changed){l(c,e);jQuery("#"+t_jp.prefix+"translation").data("edit",{changed:false})}jQuery(this).dialog("close")};d={Close:function(){jQuery(this).dialog("close")}};jQuery("#"+t_jp.prefix+"d-tabs").remove();jQuery('<div id="'+t_jp.prefix+'d-tabs" title="Edit Translation"/>').appendTo("body");jQuery("#"+t_jp.prefix+"d-tabs").append("<ul/>").tabs({cache:true}).tabs("add",
7
+ "#"+t_jp.prefix+"d-tabs-1","Translate").tabs("add",t_jp.post_url+"?tr_token_hist="+jQuery("#"+t_jp.prefix+a).attr("token")+"&lang="+t_jp.lang,"History").css("text-align","left").css("padding",0).bind("tabsload",function(e,c){jQuery("table",c.panel).addClass("ui-widget ui-widget-content").css({width:"95%",padding:"0"});jQuery("table thead tr",c.panel).addClass("ui-widget-header");jQuery("table tbody td[source='2']",c.panel).append('<span title="computer" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-gear"></span>');
8
+ jQuery("table tbody td[source='1']",c.panel).append('<span title="computer" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-gear"></span>');jQuery("table tbody td[source='0']",c.panel).append('<span title="human" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-person"></span>')}).bind("tabsselect",function(e,c){jQuery(c.tab).text()==="Translate"?jQuery("#"+t_jp.prefix+"d-tabs").dialog("option","buttons",b):jQuery("#"+t_jp.prefix+"d-tabs").dialog("option",
9
+ "buttons",d)}).bind("dialogbeforeclose",function(){if(jQuery("#"+t_jp.prefix+"translation").data("edit").changed){m();return false}return true});jQuery("#"+t_jp.prefix+"d-tabs li").css("list-style-type","none").css("list-style-position","outside");jQuery("#"+t_jp.prefix+"d-tabs-1").css("padding","1px").append('<form id="'+t_jp.prefix+'form"><fieldset><label for="original">Original Text</label><textarea cols="80" row="3" name="original" id="'+t_jp.prefix+'original" class="text ui-widget-content ui-corner-all" readonly="y"/><label for="translation">Translate To</label><textarea cols="80" row="3" name="translation" id="'+
10
+ t_jp.prefix+'translation" value="" class="text ui-widget-content ui-corner-all"/></fieldset></form>');jQuery("#"+t_jp.prefix+"d-tabs-1 label").css("display","block");jQuery("#"+t_jp.prefix+"d-tabs-1 textarea.text").css({"margin-bottom":"12px",width:"95%",padding:".4em"});jQuery("#"+t_jp.prefix+"original").val(jQuery("#"+t_jp.prefix+a).attr("orig"));jQuery("#"+t_jp.prefix+"translation").val(jQuery("#"+t_jp.prefix+a).html());jQuery("#"+t_jp.prefix+a).attr("trans")&&jQuery("#"+t_jp.prefix+"translation").val(jQuery("#"+
11
+ t_jp.prefix+a).attr("trans"));jQuery("#"+t_jp.prefix+"translation").data("edit",{changed:false});jQuery("#"+t_jp.prefix+"translation").keyup(function(){if(jQuery("#"+t_jp.prefix+a).text()!==jQuery(this).val()){jQuery(this).css("background","yellow");jQuery(this).data("edit",{changed:true})}else{jQuery(this).css("background","");jQuery(this).data("edit",{changed:false})}});jQuery("#"+t_jp.prefix+"d-tabs").dialog({bgiframe:true,modal:true,width:500,buttons:b})}var g,h,o="af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt",
12
+ n="ar,bg,zh-chs,zh-cht,cs,da,nl,en,ht,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw";jQuery("."+t_jp.prefix).each(function(){var a=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1),b;jQuery(this).after('<span id="'+t_jp.prefix+"img_"+a+'" class="tr-icon" title="'+jQuery(this).attr("orig")+'"></span>');b=jQuery("#"+t_jp.prefix+"img_"+a);b.click(function(){if(typeof jQuery.fn.tabs!=="function"){jQuery.ajaxSetup({cache:true});jQuery.getScript(t_jp.plugin_url+"/js/lazy.js",
13
+ function(){jQuery.xLazyLoader({js:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",css:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",success:function(){j(a)}})})}else j(a);return false}).css({border:"0px",margin:"1px",padding:"0px"});if(jQuery(this).attr("source")==="0")b.addClass("tr-icon-green");else jQuery(this).attr("source")&&b.addClass("tr-icon-yellow");jQuery(this).attr("hidden")==="y"&&b.css({opacity:"0.6"})})})();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://transposh.org/donate/
4
  Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese, translate
5
  Requires at least: 2.7
6
  Tested up to: 2.9.1
7
- Stable tag: 0.4.1
8
 
9
  Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
10
 
@@ -159,12 +159,20 @@ images based on the current language
159
  5. Widget style selection box, with three basic appearances, flags below (in Hebrew), language selection on the top right and language list on the bottom right.
160
 
161
  == Upgrade Notice ==
 
 
162
  = 0.4.0 =
163
  This version provides integration with google-sitemaps-xml and wp-super-cache
164
  = 0.3.9 =
165
  This version allows sorting of languages within the widget
166
 
167
  == Changelog ==
 
 
 
 
 
 
168
  = 2010/01/13 - 0.4.1 =
169
  * Fixed a few redirection bugs (administrative pages, and referred pages)
170
  * Fixed documentation bug (regarding google-sitemap-generator patch requirement)
4
  Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese, translate
5
  Requires at least: 2.7
6
  Tested up to: 2.9.1
7
+ Stable tag: 0.4.2
8
 
9
  Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
10
 
159
  5. Widget style selection box, with three basic appearances, flags below (in Hebrew), language selection on the top right and language list on the bottom right.
160
 
161
  == Upgrade Notice ==
162
+ = 0.4.2 =
163
+ This version provides Haitian support, auto translate with bing support
164
  = 0.4.0 =
165
  This version provides integration with google-sitemaps-xml and wp-super-cache
166
  = 0.3.9 =
167
  This version allows sorting of languages within the widget
168
 
169
  == Changelog ==
170
+ = 2010/01/26 - 0.4.2 =
171
+ * Script split, reduced to 1.5k gzipped in common scenarios
172
+ * Haitian translation thanks to Bing translator
173
+ * Ability to choose preferred translator, auto translate now in own section in settings page
174
+ * Revert to new post format for translations, remove old format code
175
+ * Fix bug with admin side translation on slow connections
176
  = 2010/01/13 - 0.4.1 =
177
  * Fixed a few redirection bugs (administrative pages, and referred pages)
178
  * Fixed documentation bug (regarding google-sitemap-generator patch requirement)
transposh.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin URI: http://transposh.org/
5
  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>.
6
  Author: Team Transposh
7
- Version: 0.4.1
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
@@ -127,7 +127,7 @@ class transposh_plugin {
127
  * @return boolean Is it a special page?
128
  */
129
  function is_special_page($url) {
130
- return (stripos($url,'/wp-login.php') !== FALSE ||
131
  stripos($url,'/wp-admin/') !== FALSE ||
132
  stripos($url,'/xmlrpc.php') !== FALSE);
133
  }
@@ -486,7 +486,7 @@ class transposh_plugin {
486
  wp_deregister_script('jquery');
487
  wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');
488
  // toying around - for later...
489
- //wp_enqueue_script("jquery","http://code.jquery.com/jquery-1.4rc1.js",array(),'1.4rc');
490
  }
491
  }
492
 
@@ -508,6 +508,7 @@ class transposh_plugin {
508
  echo "t_jp.lang='{$this->target_language}';";
509
  echo "t_jp.prefix='".SPAN_PREFIX."';";
510
  echo "t_jp.msnkey='{$this->options->get_msn_key()}';";
 
511
  echo "t_jp.progress=".($this->edit_mode || $this->options->get_widget_progressbar() ? 'true' : 'false').";";
512
 
513
  /*
4
  Plugin URI: http://transposh.org/
5
  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>.
6
  Author: Team Transposh
7
+ Version: 0.4.2
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
127
  * @return boolean Is it a special page?
128
  */
129
  function is_special_page($url) {
130
+ return ( stripos($url,'/wp-login.php') !== FALSE ||
131
  stripos($url,'/wp-admin/') !== FALSE ||
132
  stripos($url,'/xmlrpc.php') !== FALSE);
133
  }
486
  wp_deregister_script('jquery');
487
  wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');
488
  // toying around - for later...
489
+ // wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js",array(),'1.4.1');
490
  }
491
  }
492
 
508
  echo "t_jp.lang='{$this->target_language}';";
509
  echo "t_jp.prefix='".SPAN_PREFIX."';";
510
  echo "t_jp.msnkey='{$this->options->get_msn_key()}';";
511
+ echo "t_jp.preferred='{$this->options->get_preferred_translator()}';";
512
  echo "t_jp.progress=".($this->edit_mode || $this->options->get_widget_progressbar() ? 'true' : 'false').";";
513
 
514
  /*
wp/transposh_admin.php CHANGED
@@ -116,6 +116,7 @@ class transposh_plugin_admin {
116
  $this->transposh->options->set_enable_default_translate($_POST[ENABLE_DEFAULT_TRANSLATE]);
117
  $this->transposh->options->set_enable_search_translate($_POST[ENABLE_SEARCH_TRANSLATE]);
118
  $this->transposh->options->set_enable_msn_translate($_POST[ENABLE_MSN_TRANSLATE]);
 
119
  $this->transposh->options->set_msn_key($_POST[MSN_TRANSLATE_KEY]);
120
  $this->transposh->options->update_options();
121
  }
@@ -168,6 +169,7 @@ class transposh_plugin_admin {
168
  add_meta_box('transposh-sidebox-stats', 'Plugin stats', array(&$this, 'on_sidebox_stats_content'), $this->pagehook, 'side', 'core');
169
  add_meta_box('transposh-contentbox-languages', 'Supported languages', array(&$this, 'on_contentbox_languages_content'), $this->pagehook, 'normal', 'core');
170
  add_meta_box('transposh-contentbox-translation', 'Translation settings', array(&$this, 'on_contentbox_translation_content'), $this->pagehook, 'normal', 'core');
 
171
  add_meta_box('transposh-contentbox-general', 'Generic settings', array(&$this, 'on_contentbox_generic_content'), $this->pagehook, 'normal', 'core');
172
  }
173
 
@@ -406,6 +408,27 @@ class transposh_plugin_admin {
406
  //Add our own custom role
407
  echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" '. $this->can_translate('anonymous') . '/> Anonymous';
408
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  /*
410
  * Insert the option to enable/disable automatic translation.
411
  * Enabled by default.
@@ -426,27 +449,21 @@ class transposh_plugin_admin {
426
  * Insert the option to enable/disable msn translations.
427
  * Disabled by default because an API key is needed.
428
  */
429
- echo '<h4>Support for Bing (MSN) translation hinting (experimental)</h4>';
430
  echo '<input type="checkbox" value="1" name="'.ENABLE_MSN_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_msn_translate()).'/> '.
431
  'Allow MSN (Bing) translator hinting (get key from <a href="http://www.microsofttranslator.com/Dev/Ajax/Default.aspx">here</a>)<br/>'.
432
  'Key: <input type="text" size="35" class="regular-text" value="'.$this->transposh->options->get_msn_key().'" id="'.MSN_TRANSLATE_KEY.'" name="'.MSN_TRANSLATE_KEY.'"/>';
433
 
434
  /*
435
- * Insert the option to enable/disable default language translation.
436
- * Disabled by default.
437
  */
438
- echo '<h4>Enable default language translation</h4>';
439
- echo '<input type="checkbox" value="1" name="'.ENABLE_DEFAULT_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_default_translate()).'/> '.
440
- 'Allow translation of default language - useful for sites with more than one major language';
441
-
442
- /**
443
- * Insert the option to enable search in translated languages
444
- * Enabled by default.
445
- * @since 0.3.6
446
- */
447
- echo '<h4>Enable search in translated languages</h4>';
448
- echo '<input type="checkbox" value="1" name="'.ENABLE_SEARCH_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_search_translate()).'/> '.
449
- 'Allow search of translated languages, in those languages (and the original language)';
450
 
451
  }
452
 
116
  $this->transposh->options->set_enable_default_translate($_POST[ENABLE_DEFAULT_TRANSLATE]);
117
  $this->transposh->options->set_enable_search_translate($_POST[ENABLE_SEARCH_TRANSLATE]);
118
  $this->transposh->options->set_enable_msn_translate($_POST[ENABLE_MSN_TRANSLATE]);
119
+ $this->transposh->options->set_preferred_translator($_POST[PREFERRED_TRANSLATOR]);
120
  $this->transposh->options->set_msn_key($_POST[MSN_TRANSLATE_KEY]);
121
  $this->transposh->options->update_options();
122
  }
169
  add_meta_box('transposh-sidebox-stats', 'Plugin stats', array(&$this, 'on_sidebox_stats_content'), $this->pagehook, 'side', 'core');
170
  add_meta_box('transposh-contentbox-languages', 'Supported languages', array(&$this, 'on_contentbox_languages_content'), $this->pagehook, 'normal', 'core');
171
  add_meta_box('transposh-contentbox-translation', 'Translation settings', array(&$this, 'on_contentbox_translation_content'), $this->pagehook, 'normal', 'core');
172
+ add_meta_box('transposh-contentbox-autotranslation', 'Automatic translation settings', array(&$this, 'on_contentbox_auto_translation_content'), $this->pagehook, 'normal', 'core');
173
  add_meta_box('transposh-contentbox-general', 'Generic settings', array(&$this, 'on_contentbox_generic_content'), $this->pagehook, 'normal', 'core');
174
  }
175
 
408
  //Add our own custom role
409
  echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" '. $this->can_translate('anonymous') . '/> Anonymous';
410
 
411
+ /*
412
+ * Insert the option to enable/disable default language translation.
413
+ * Disabled by default.
414
+ */
415
+ echo '<h4>Enable default language translation</h4>';
416
+ echo '<input type="checkbox" value="1" name="'.ENABLE_DEFAULT_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_default_translate()).'/> '.
417
+ 'Allow translation of default language - useful for sites with more than one major language';
418
+
419
+ /**
420
+ * Insert the option to enable search in translated languages
421
+ * Enabled by default.
422
+ * @since 0.3.6
423
+ */
424
+ echo '<h4>Enable search in translated languages</h4>';
425
+ echo '<input type="checkbox" value="1" name="'.ENABLE_SEARCH_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_search_translate()).'/> '.
426
+ 'Allow search of translated languages, in those languages (and the original language)';
427
+
428
+ }
429
+
430
+ function on_contentbox_auto_translation_content($data) {
431
+
432
  /*
433
  * Insert the option to enable/disable automatic translation.
434
  * Enabled by default.
449
  * Insert the option to enable/disable msn translations.
450
  * Disabled by default because an API key is needed.
451
  */
452
+ echo '<h4>Support for Bing (MSN) translation</h4>';
453
  echo '<input type="checkbox" value="1" name="'.ENABLE_MSN_TRANSLATE.'" '.$this->checked($this->transposh->options->get_enable_msn_translate()).'/> '.
454
  'Allow MSN (Bing) translator hinting (get key from <a href="http://www.microsofttranslator.com/Dev/Ajax/Default.aspx">here</a>)<br/>'.
455
  'Key: <input type="text" size="35" class="regular-text" value="'.$this->transposh->options->get_msn_key().'" id="'.MSN_TRANSLATE_KEY.'" name="'.MSN_TRANSLATE_KEY.'"/>';
456
 
457
  /*
458
+ * TODO
 
459
  */
460
+ echo '<h4>Select preferred translatation engine</h4>';
461
+ echo '<label for="'.PREFERRED_TRANSLATOR.'">Translation engine:'.
462
+ '<select name="'.PREFERRED_TRANSLATOR.'">'.
463
+ '<option value="1"' . ($this->transposh->options->get_preferred_translator() == 1 ? ' selected="selected"' : '').'>Google</option>'.
464
+ '<option value="2"' . ($this->transposh->options->get_preferred_translator() == 2 ? ' selected="selected"' : '').'>Bing</option>'.
465
+ '</select>'.
466
+ '</label>';
 
 
 
 
 
467
 
468
  }
469
 
wp/transposh_ajax.php CHANGED
@@ -44,9 +44,6 @@ if (isset($_POST['translation_posted'])) {
44
  }
45
 
46
  if ($_POST['translation_posted'] == 2) {
47
- $my_transposh_plugin->database->update_translation_new();
48
- }
49
- else {
50
  $my_transposh_plugin->database->update_translation();
51
  }
52
  }
44
  }
45
 
46
  if ($_POST['translation_posted'] == 2) {
 
 
 
47
  $my_transposh_plugin->database->update_translation();
48
  }
49
  }
wp/transposh_db.php CHANGED
@@ -96,113 +96,14 @@ class transposh_database {
96
  return $translated;
97
  }
98
 
99
- /*
100
- * A new translation has been posted, update the translation database.
101
- * This has changed since we now accept multiple translations at once
102
- */
103
- function update_translation() {
104
-
105
- $ref=getenv('HTTP_REFERER');
106
- $items = $_POST['items'];
107
- $lang = $_POST['lang'];
108
- $source = $_POST['source'];
109
- // check params
110
-
111
- if(!isset($items) || !isset($lang)) {
112
-
113
- return;
114
- }
115
-
116
- //Check permissions, first the lanugage must be on the edit list. Then either the user
117
- //is a translator or automatic translation if it is enabled.
118
- if(!($this->transposh->options->is_editable_language($lang) &&
119
- ($this->transposh->is_translator() || ($source == 1 && $this->transposh->options->get_enable_auto_translate())))) {
120
-
121
- header("HTTP/1.0 401 Unauthorized translation");
122
- exit;
123
- }
124
-
125
- //add our own custom header - so we will know that we got here
126
- header("Transposh: v-".TRANSPOSH_PLUGIN_VER." db_version-". DB_VERSION);
127
-
128
- // transaction log stuff
129
- global $user_ID;
130
- get_currentuserinfo();
131
-
132
- // log either the user ID or his IP
133
- if ('' == $user_ID) {
134
- $loguser = $_SERVER['REMOTE_ADDR'];
135
- }
136
- else {
137
- $loguser = $user_ID;
138
- }
139
- // end tl
140
-
141
- // We are now passing all posted items
142
- for ($i=0;$i<$items;$i++) {
143
- $original = base64_url_decode($_POST["tk$i"]);
144
- $translation = $_POST["tr$i"];
145
- //Decode & remove already escaped character to avoid double escaping
146
- $translation = $GLOBALS['wpdb']->escape(htmlspecialchars(stripslashes(urldecode($translation))));
147
-
148
- //The original content is encoded as base64 before it is sent (i.e. token), after we
149
- //decode it should just the same after it was parsed.
150
- $original = $GLOBALS['wpdb']->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
151
-
152
- //Here we check we are not redoing stuff
153
- list($translated_text, $old_source) = $this->fetch_translation($original, $lang);
154
- if ($translated_text) {
155
- if ($source == 1) {
156
-
157
- return;
158
- }
159
- if ($translation == $GLOBALS['wpdb']->escape(htmlspecialchars(stripslashes(urldecode($translated_text)))) && $old_source == $source) {
160
-
161
- return;
162
- }
163
- }
164
- // Setting the values string for the database (notice how concatanation is handled)
165
- $values .= "('" . $original . "','" . $translation . "','" . $lang . "','" . $source . "')".(($items != $i+1) ?', ':'');
166
- // Setting the transaction log records
167
- $logvalues .= "('" . $original . "','" . $translation . "','" . $lang . "','".$loguser."','".$source."')".(($items != $i+1) ?', ':'');
168
-
169
- // If we have caching - we remove previous entry from cache
170
- if(ENABLE_APC && function_exists('apc_store')) {
171
- apc_delete($original .'___'. $lang);
172
- }
173
- }
174
-
175
- // perform insertion to the database, with one query :)
176
- $update = "REPLACE INTO ".$GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE." (original, translated, lang, source)
177
- VALUES $values";
178
-
179
-
180
- $result = $GLOBALS['wpdb']->query($update);
181
-
182
- if($result !== FALSE) {
183
- // update the transaction log too
184
- $log = "INSERT INTO ".$GLOBALS['wpdb']->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) ".
185
- "VALUES $logvalues";
186
- $result = $GLOBALS['wpdb']->query($log);
187
-
188
-
189
- }
190
- else {
191
-
192
-
193
- header("HTTP/1.0 404 Failed to update language database ".mysql_error());
194
- }
195
- // this is a termination for the ajax sequence
196
- exit;
197
- }
198
-
199
  /**
200
  * A new translation has been posted, update the translation database.
201
  * This has changed since we now accept multiple translations at once
202
  * This function accepts a new more "versatile" format
 
203
  * @global <type> $user_ID - TODO
204
  */
205
- function update_translation_new() {
206
 
207
  $ref=getenv('HTTP_REFERER');
208
  $items = $_POST['items'];
96
  return $translated;
97
  }
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  /**
100
  * A new translation has been posted, update the translation database.
101
  * This has changed since we now accept multiple translations at once
102
  * This function accepts a new more "versatile" format
103
+ * TODO - return some info?
104
  * @global <type> $user_ID - TODO
105
  */
106
+ function update_translation() {
107
 
108
  $ref=getenv('HTTP_REFERER');
109
  $items = $_POST['items'];
wp/transposh_options.php CHANGED
@@ -60,6 +60,8 @@ define("ENABLE_AUTO_POST_TRANSLATE", "enable_autoposttranslate");
60
  define("ENABLE_MSN_TRANSLATE", "enable_msntranslate");
61
  //Option to store the msn API key
62
  define("MSN_TRANSLATE_KEY", "msn_key");
 
 
63
  //Option to enable/disable default language translation
64
  define("ENABLE_DEFAULT_TRANSLATE", "enable_default_translate");
65
  //Option to enable/disable default language translation @since 0.3.6
@@ -224,6 +226,11 @@ class transposh_plugin_options {
224
  return $this->options[MSN_TRANSLATE_KEY];
225
  }
226
 
 
 
 
 
 
227
  /**
228
  * Gets the default language setting, i.e. the source language which normally should not be translated.
229
  * @return string Default language
@@ -337,6 +344,10 @@ class transposh_plugin_options {
337
  $this->set_value($val, $this->options[MSN_TRANSLATE_KEY]);
338
  }
339
 
 
 
 
 
340
  /**
341
  * Sets the default language setting, i.e. the source language which
342
  * should not be translated.
60
  define("ENABLE_MSN_TRANSLATE", "enable_msntranslate");
61
  //Option to store the msn API key
62
  define("MSN_TRANSLATE_KEY", "msn_key");
63
+ //Option to store translator preference @since 0.4.2
64
+ define("PREFERRED_TRANSLATOR", "preferred_translator");
65
  //Option to enable/disable default language translation
66
  define("ENABLE_DEFAULT_TRANSLATE", "enable_default_translate");
67
  //Option to enable/disable default language translation @since 0.3.6
226
  return $this->options[MSN_TRANSLATE_KEY];
227
  }
228
 
229
+ function get_preferred_translator() {
230
+ if (!isset($this->options[PREFERRED_TRANSLATOR])) return 1; // default is google (2 is msn)
231
+ return $this->options[PREFERRED_TRANSLATOR];
232
+ }
233
+
234
  /**
235
  * Gets the default language setting, i.e. the source language which normally should not be translated.
236
  * @return string Default language
344
  $this->set_value($val, $this->options[MSN_TRANSLATE_KEY]);
345
  }
346
 
347
+ function set_preferred_translator($val) {
348
+ $this->set_value($val, $this->options[PREFERRED_TRANSLATOR]);
349
+ }
350
+
351
  /**
352
  * Sets the default language setting, i.e. the source language which
353
  * should not be translated.