Transposh WordPress Translation - Version 0.3.1

Version Description

Download this release

Release Info

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

Code changes from version 0.3.0 to 0.3.1

core/utils.php CHANGED
@@ -141,8 +141,8 @@ function rewrite_url_lang_param($url, $lang, $is_edit, $use_params_only=FALSE) {
141
  else {
142
  if (!$parsedurl['path']) $parsedurl['path'] = "/";
143
  $parsedurl['path'] = "/".$lang.$parsedurl['path'];
144
- if ($gluebackhome) $parsedurl['path'] = $home_path.$parsedurl['path'];
145
  }
 
146
 
147
  //insert params to url
148
  if(isset($params) && $params) {
141
  else {
142
  if (!$parsedurl['path']) $parsedurl['path'] = "/";
143
  $parsedurl['path'] = "/".$lang.$parsedurl['path'];
 
144
  }
145
+ if ($gluebackhome) $parsedurl['path'] = $home_path.$parsedurl['path'];
146
 
147
  //insert params to url
148
  if(isset($params) && $params) {
js/transposh.js CHANGED
@@ -1 +1 @@
1
- function getgt(){jQuery(":button:contains('Suggest - Google')").attr("disabled","disabled").addClass("ui-state-disabled");google.language.translate(jQuery("#"+transposh_params.prefix+"original").val(),"",transposh_params.lang,function(a){if(!a.error){jQuery("#"+transposh_params.prefix+"translation").val(jQuery("<div>"+a.translation+"</div>").text()).keyup()}})}function getbt(){jQuery(":button:contains('Suggest - Bing')").attr("disabled","disabled").addClass("ui-state-disabled");var a=transposh_params.lang;if(a=="zh"){a="zh-chs"}if(a=="zh-tw"){a="zh-cht"}Microsoft.Translator.translate(jQuery("#"+transposh_params.prefix+"original").val(),"",a,function(b){jQuery("#"+transposh_params.prefix+"translation").val(jQuery("<div>"+b+"</div>").text()).keyup()})}var done_p=0;var togo=0;function ajax_translate(c,b,a){jQuery.ajax({type:"POST",url:transposh_params.post_url,data:{token:jQuery("#"+transposh_params.prefix+a).attr("token"),translation:c,lang:transposh_params.lang,source:b,translation_posted:"1"},success:function(e){fix_page(c,b,a);if(transposh_params.progress){var d=jQuery("#"+transposh_params.prefix+a).attr("token");done_p+=jQuery("*[token='"+d+"']").size();if(togo>4){jQuery("#progress_bar2").progressbar("value",done_p/togo*100)}}},error:function(d){if(b==0){alert("Error !!! failed to translate.\n\nServer's message: "+d.statusText)}}})}function fix_page(e,d,c){var b=jQuery("#"+transposh_params.prefix+c).attr("token");var a=e;if(jQuery.trim(e).length===0){a=jQuery("#"+transposh_params.prefix+c).attr("orig")}jQuery("*[token='"+b+"'][hidden!='y']").html(a).each(function(g){var h=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1);jQuery("#"+transposh_params.prefix+h).attr("source",d);var f=jQuery("#"+transposh_params.prefix+"img_"+h);f.removeClass("tr-icon-yellow").removeClass("tr-icon-green");if(jQuery.trim(e).length!==0){if(d==1){f.addClass("tr-icon-yellow")}else{f.addClass("tr-icon-green")}}});jQuery("*[token='"+b+"'][hidden='y']").attr("trans",a).each(function(g){var h=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1);jQuery("#"+transposh_params.prefix+h).attr("source",d);var f=jQuery("#"+transposh_params.prefix+"img_"+h);f.removeClass("tr-icon-yellow").removeClass("tr-icon-green");if(jQuery.trim(e).length!==0){if(d==1){f.addClass("tr-icon-yellow")}else{f.addClass("tr-icon-green")}}})}function do_auto_translate(){if(transposh_params.progress){togo=jQuery("."+transposh_params.prefix+'[source=""]').size();if(togo>4){jQuery("#"+transposh_params.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"})}var a=0}var b=new Array();jQuery("."+transposh_params.prefix+'[source=""]').each(function(d){var c=jQuery(this).attr("id");var e=jQuery(this).attr("orig");if(e==undefined){e=jQuery(this).html()}if(!(b[e]==1)){b[e]=1;google.language.translate(e,"",transposh_params.lang,function(f){if(!f.error){var g=c.substr(c.lastIndexOf("_")+1);fix_page(jQuery("<div>"+f.translation+"</div>").text(),1,g);ajax_translate(jQuery("<div>"+f.translation+"</div>").text(),1,g);if(transposh_params.progress){a=togo-jQuery("."+transposh_params.prefix+'[source=""]').size();if(togo>4){jQuery("#progress_bar").progressbar("value",a/togo*100)}}}})}})}function confirm_close(){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,resizable:false,height:140,modal:true,overlay:{backgroundColor:"#000",opacity:0.5},buttons:{Discard:function(){jQuery("#"+transposh_params.prefix+"translation").data("edit",{changed:false});jQuery(this).dialog("close");jQuery("#"+transposh_params.prefix+"d-tabs").dialog("close")},Cancel:function(){jQuery(this).dialog("close")}}})}function translate_dialog(b){jQuery("#"+transposh_params.prefix+"d-tabs").remove();jQuery('<div id="'+transposh_params.prefix+'d-tabs" title="Edit Translation"/>').appendTo("body");jQuery("#"+transposh_params.prefix+"d-tabs").append("<ul/>").tabs({cache:true}).tabs("add","#"+transposh_params.prefix+"d-tabs-1","Translate").tabs("add",transposh_params.post_url+"?tr_token_hist="+jQuery("#"+transposh_params.prefix+b).attr("token")+"&lang="+transposh_params.lang,"History").css("text-align","left").css("padding",0).bind("tabsload",function(d,e){jQuery("table",e.panel).addClass("ui-widget ui-widget-content").css({width:"95%",padding:"0"});jQuery("table thead tr",e.panel).addClass("ui-widget-header");jQuery("table tbody td[source='1']",e.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']",e.panel).append('<span title="human" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-person"></span>')}).bind("tabsselect",function(d,e){if(jQuery(e.tab).text()=="Translate"){jQuery("#"+transposh_params.prefix+"d-tabs").dialog("option","buttons",a)}else{jQuery("#"+transposh_params.prefix+"d-tabs").dialog("option","buttons",c)}}).bind("dialogbeforeclose",function(d,e){if(jQuery("#"+transposh_params.prefix+"translation").data("edit").changed){confirm_close();return false}return true});jQuery("#"+transposh_params.prefix+"d-tabs li").css("list-style-type","none").css("list-style-position","outside");jQuery("#"+transposh_params.prefix+"d-tabs-1").css("padding","1px").append('<form id="'+transposh_params.prefix+'form"><fieldset><label for="original">Original Text</label><textarea cols="80" row="3" name="original" id="'+transposh_params.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="'+transposh_params.prefix+'translation" value="" class="text ui-widget-content ui-corner-all"/></fieldset></form>');jQuery("#"+transposh_params.prefix+"d-tabs-1 label").css("display","block");jQuery("#"+transposh_params.prefix+"d-tabs-1 textarea.text").css({"margin-bottom":"12px",width:"95%",padding:".4em"});jQuery("#"+transposh_params.prefix+"original").val(jQuery("#"+transposh_params.prefix+b).attr("orig"));jQuery("#"+transposh_params.prefix+"translation").val(jQuery("#"+transposh_params.prefix+b).html());if(jQuery("#"+transposh_params.prefix+b).attr("trans")){jQuery("#"+transposh_params.prefix+"translation").val(jQuery("#"+transposh_params.prefix+b).attr("trans"))}jQuery("#"+transposh_params.prefix+"translation").data("edit",{changed:false});jQuery("#"+transposh_params.prefix+"translation").keyup(function(d){if(jQuery("#"+transposh_params.prefix+b).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})}});var a={};if(binglangs.indexOf(transposh_params.lang+",",0)>-1){a["Suggest - Bing"]=function(){getbt()}}if(google.language.isTranslatable(transposh_params.lang)||"he|zh-tw|pt|fa".indexOf(transposh_params.lang)>-1){a["Suggest - Google"]=function(){getgt()}}a.Ok=function(){var d=jQuery("#"+transposh_params.prefix+"translation").val();if(jQuery("#"+transposh_params.prefix+"translation").data("edit").changed){ajax_translate(d,0,b);jQuery("#"+transposh_params.prefix+"translation").data("edit",{changed:false})}jQuery(this).dialog("close")};var c={Close:function(){jQuery(this).dialog("close")}};jQuery("#"+transposh_params.prefix+"d-tabs").dialog({bgiframe:true,modal:true,width:500,buttons:a})}jQuery.noConflict();var transposh_params=new Array();jQuery("script[src*='transposh.js']").each(function(a){var e=unescape(this.src.substring(this.src.indexOf("?")+1));var d=e.split("&");for(var c=0;c<d.length;c++){var g=d[c].indexOf("=");if(g>0){var b=d[c].substring(0,g);var f=d[c].substring(g+1);transposh_params[b]=f}}});google.load("language","1");var binglangs="";if(typeof(Microsoft)!="undefined"){try{binglangs=String(Microsoft.Translator.GetLanguages())+",zh,zh-tw,"}catch(err){alert("There was an error using Microsoft.Translator - probably a bad key or URL used in key. ("+err+")")}}jQuery(document).ready(function(){if(typeof(jQuery().progressbar)!="undefined"){transposh_params.progress=true}if(google.language.isTranslatable(transposh_params.lang)||"he|zh-tw|pt|fa".indexOf(transposh_params.lang)>-1){do_auto_translate()}if(transposh_params.edit){jQuery("."+transposh_params.prefix).each(function(c){var a=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1);jQuery(this).after('<span id="'+transposh_params.prefix+"img_"+a+'" class="tr-icon" title="'+jQuery(this).attr("orig")+'"></span>');var b=jQuery("#"+transposh_params.prefix+"img_"+a);b.click(function(){translate_dialog(a);return false}).css({border:"0px",margin:"1px",padding:"0px"});if(jQuery(this).attr("source")=="1"){b.addClass("tr-icon-yellow")}else{if(jQuery(this).attr("source")=="0"){b.addClass("tr-icon-green")}}if(jQuery(this).attr("hidden")=="y"){b.css({opacity:"0.6"})}})}});
1
+ function getgt(){jQuery(":button:contains('Suggest - Google')").attr("disabled","disabled").addClass("ui-state-disabled");google.language.translate(jQuery("#"+transposh_params.prefix+"original").val(),"",transposh_params.lang,function(a){if(!a.error){jQuery("#"+transposh_params.prefix+"translation").val(jQuery("<div>"+a.translation+"</div>").text()).keyup()}})}function getbt(){jQuery(":button:contains('Suggest - Bing')").attr("disabled","disabled").addClass("ui-state-disabled");var a=transposh_params.lang;if(a=="zh"){a="zh-chs"}if(a=="zh-tw"){a="zh-cht"}Microsoft.Translator.translate(jQuery("#"+transposh_params.prefix+"original").val(),"",a,function(b){jQuery("#"+transposh_params.prefix+"translation").val(jQuery("<div>"+b+"</div>").text()).keyup()})}var done_p=0;var togo=0;var timer;function do_timer(a){alert("timer..."+a)}var tokens=new Array();var translations=new Array();function ajax_translate(c,b,a){clearTimeout(timer);tokens.push(jQuery("#"+transposh_params.prefix+a).attr("token"));translations.push(c);fix_page(c,b,a);timer=setTimeout(function(){var e={lang:transposh_params.lang,source:b,translation_posted:"1",items:tokens.length};for(var d=0;d<tokens.length;d++){e["tk"+d]=tokens[d];e["tr"+d]=translations[d];done_p+=jQuery("*[token='"+tokens[d]+"']").size()}jQuery.ajax({type:"POST",url:transposh_params.post_url,data:e,success:function(){if(transposh_params.progress){if(togo>4){jQuery("#progress_bar2").progressbar("value",done_p/togo*100)}}},error:function(f){if(b==0){alert("Error !!! failed to translate.\n\nServer's message: "+f.statusText)}}});translations=[];tokens=[]},200)}function fix_page(e,d,c){var b=jQuery("#"+transposh_params.prefix+c).attr("token");var a=e;if(jQuery.trim(e).length===0){a=jQuery("#"+transposh_params.prefix+c).attr("orig")}jQuery("*[token='"+b+"'][hidden!='y']").html(a).each(function(g){var h=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1);jQuery("#"+transposh_params.prefix+h).attr("source",d);var f=jQuery("#"+transposh_params.prefix+"img_"+h);f.removeClass("tr-icon-yellow").removeClass("tr-icon-green");if(jQuery.trim(e).length!==0){if(d==1){f.addClass("tr-icon-yellow")}else{f.addClass("tr-icon-green")}}});jQuery("*[token='"+b+"'][hidden='y']").attr("trans",a).each(function(g){var h=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1);jQuery("#"+transposh_params.prefix+h).attr("source",d);var f=jQuery("#"+transposh_params.prefix+"img_"+h);f.removeClass("tr-icon-yellow").removeClass("tr-icon-green");if(jQuery.trim(e).length!==0){if(d==1){f.addClass("tr-icon-yellow")}else{f.addClass("tr-icon-green")}}})}function do_auto_translate(){if(transposh_params.progress){togo=jQuery("."+transposh_params.prefix+'[source=""]').size();if(togo>4){jQuery("#"+transposh_params.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"})}var a=0}var b=new Array();jQuery("."+transposh_params.prefix+'[source=""]').each(function(d){var c=jQuery(this).attr("id");var e=jQuery(this).attr("orig");if(e==undefined){e=jQuery(this).html()}if(!(b[e]==1)){b[e]=1;google.language.translate(e,"",transposh_params.lang,function(f){if(!f.error){var g=c.substr(c.lastIndexOf("_")+1);ajax_translate(jQuery("<div>"+f.translation+"</div>").text(),1,g);if(transposh_params.progress){a=togo-jQuery("."+transposh_params.prefix+'[source=""]').size();if(togo>4){jQuery("#progress_bar").progressbar("value",a/togo*100)}}}})}})}function confirm_close(){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,resizable:false,height:140,modal:true,overlay:{backgroundColor:"#000",opacity:0.5},buttons:{Discard:function(){jQuery("#"+transposh_params.prefix+"translation").data("edit",{changed:false});jQuery(this).dialog("close");jQuery("#"+transposh_params.prefix+"d-tabs").dialog("close")},Cancel:function(){jQuery(this).dialog("close")}}})}function translate_dialog(b){jQuery("#"+transposh_params.prefix+"d-tabs").remove();jQuery('<div id="'+transposh_params.prefix+'d-tabs" title="Edit Translation"/>').appendTo("body");jQuery("#"+transposh_params.prefix+"d-tabs").append("<ul/>").tabs({cache:true}).tabs("add","#"+transposh_params.prefix+"d-tabs-1","Translate").tabs("add",transposh_params.post_url+"?tr_token_hist="+jQuery("#"+transposh_params.prefix+b).attr("token")+"&lang="+transposh_params.lang,"History").css("text-align","left").css("padding",0).bind("tabsload",function(d,e){jQuery("table",e.panel).addClass("ui-widget ui-widget-content").css({width:"95%",padding:"0"});jQuery("table thead tr",e.panel).addClass("ui-widget-header");jQuery("table tbody td[source='1']",e.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']",e.panel).append('<span title="human" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-person"></span>')}).bind("tabsselect",function(d,e){if(jQuery(e.tab).text()=="Translate"){jQuery("#"+transposh_params.prefix+"d-tabs").dialog("option","buttons",a)}else{jQuery("#"+transposh_params.prefix+"d-tabs").dialog("option","buttons",c)}}).bind("dialogbeforeclose",function(d,e){if(jQuery("#"+transposh_params.prefix+"translation").data("edit").changed){confirm_close();return false}return true});jQuery("#"+transposh_params.prefix+"d-tabs li").css("list-style-type","none").css("list-style-position","outside");jQuery("#"+transposh_params.prefix+"d-tabs-1").css("padding","1px").append('<form id="'+transposh_params.prefix+'form"><fieldset><label for="original">Original Text</label><textarea cols="80" row="3" name="original" id="'+transposh_params.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="'+transposh_params.prefix+'translation" value="" class="text ui-widget-content ui-corner-all"/></fieldset></form>');jQuery("#"+transposh_params.prefix+"d-tabs-1 label").css("display","block");jQuery("#"+transposh_params.prefix+"d-tabs-1 textarea.text").css({"margin-bottom":"12px",width:"95%",padding:".4em"});jQuery("#"+transposh_params.prefix+"original").val(jQuery("#"+transposh_params.prefix+b).attr("orig"));jQuery("#"+transposh_params.prefix+"translation").val(jQuery("#"+transposh_params.prefix+b).html());if(jQuery("#"+transposh_params.prefix+b).attr("trans")){jQuery("#"+transposh_params.prefix+"translation").val(jQuery("#"+transposh_params.prefix+b).attr("trans"))}jQuery("#"+transposh_params.prefix+"translation").data("edit",{changed:false});jQuery("#"+transposh_params.prefix+"translation").keyup(function(d){if(jQuery("#"+transposh_params.prefix+b).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})}});var a={};if(binglangs.indexOf(transposh_params.lang+",",0)>-1){a["Suggest - Bing"]=function(){getbt()}}if(google.language.isTranslatable(transposh_params.lang)||"he|zh-tw|pt|fa".indexOf(transposh_params.lang)>-1){a["Suggest - Google"]=function(){getgt()}}a.Ok=function(){var d=jQuery("#"+transposh_params.prefix+"translation").val();if(jQuery("#"+transposh_params.prefix+"translation").data("edit").changed){ajax_translate(d,0,b);jQuery("#"+transposh_params.prefix+"translation").data("edit",{changed:false})}jQuery(this).dialog("close")};var c={Close:function(){jQuery(this).dialog("close")}};jQuery("#"+transposh_params.prefix+"d-tabs").dialog({bgiframe:true,modal:true,width:500,buttons:a})}jQuery.noConflict();var transposh_params=new Array();jQuery("script[src*='transposh.js']").each(function(a){var e=unescape(this.src.substring(this.src.indexOf("?")+1));var d=e.split("&");for(var c=0;c<d.length;c++){var g=d[c].indexOf("=");if(g>0){var b=d[c].substring(0,g);var f=d[c].substring(g+1);transposh_params[b]=f}}});google.load("language","1");var binglangs="";if(typeof(Microsoft)!="undefined"){try{binglangs=String(Microsoft.Translator.GetLanguages())+",zh,zh-tw,"}catch(err){alert("There was an error using Microsoft.Translator - probably a bad key or URL used in key. ("+err+")")}}jQuery(document).ready(function(){if(typeof(jQuery().progressbar)!="undefined"){transposh_params.progress=true}if(google.language.isTranslatable(transposh_params.lang)||"he|zh-tw|pt|fa".indexOf(transposh_params.lang)>-1){do_auto_translate()}if(transposh_params.edit){jQuery("."+transposh_params.prefix).each(function(c){var a=jQuery(this).attr("id").substr(jQuery(this).attr("id").lastIndexOf("_")+1);jQuery(this).after('<span id="'+transposh_params.prefix+"img_"+a+'" class="tr-icon" title="'+jQuery(this).attr("orig")+'"></span>');var b=jQuery("#"+transposh_params.prefix+"img_"+a);b.click(function(){translate_dialog(a);return false}).css({border:"0px",margin:"1px",padding:"0px"});if(jQuery(this).attr("source")=="1"){b.addClass("tr-icon-yellow")}else{if(jQuery(this).attr("source")=="0"){b.addClass("tr-icon-green")}}if(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
5
  Requires at least: 2.7
6
  Tested up to: 2.8.2
7
- Stable tag: 0.3.0
8
 
9
  Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
10
 
@@ -110,6 +110,10 @@ change the .css from transparent background to your page background color. And l
110
  5. Widget style selection
111
 
112
  == Changelog ==
 
 
 
 
113
  = 2009/07/23 - 0.3.0 =
114
  * Support Bing (MSN) translator as a hinting facilitator
115
  = 2009/07/21 - 0.2.9 =
4
  Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
5
  Requires at least: 2.7
6
  Tested up to: 2.8.2
7
+ Stable tag: 0.3.1
8
 
9
  Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
10
 
110
  5. Widget style selection
111
 
112
  == Changelog ==
113
+ = 2009/07/27 - 0.3.1 =
114
+ * Much faster caching of auto translation results on server with reduced server load
115
+ * Mark active language in the widget for css usage
116
+ * Fixed url code with paramaters and subdirectories
117
  = 2009/07/23 - 0.3.0 =
118
  * Support Bing (MSN) translator as a hinting facilitator
119
  = 2009/07/21 - 0.2.9 =
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.3.0
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
@@ -351,7 +351,7 @@ function add_transposh_css() {
351
  return;
352
  }
353
  //include the transposh.css
354
- wp_enqueue_style("transposh","$tr_plugin_url/css/transposh.css",array(),'0.3.0');
355
  wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/ui-lightness/jquery-ui.css",array(),'1.0');
356
 
357
  }
@@ -395,7 +395,7 @@ function add_transposh_js() {
395
  if (get_option(ENABLE_MSN_TRANSLATE)) {
396
  wp_enqueue_script("mstranslate","http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId=".get_option(MSN_TRANSLATE_KEY),array(),'1',get_option(ENABLE_FOOTER_SCRIPTS));
397
  }
398
- wp_enqueue_script("transposh","$tr_plugin_url/js/transposh.js?post_url=$post_url{$edit_mode}&lang={$GLOBALS['lang']}&prefix=".SPAN_PREFIX,array("jquery"),'0.3.0',get_option(ENABLE_FOOTER_SCRIPTS));
399
  }
400
  }
401
 
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.3.1
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
351
  return;
352
  }
353
  //include the transposh.css
354
+ wp_enqueue_style("transposh","$tr_plugin_url/css/transposh.css",array(),'0.3.1');
355
  wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/ui-lightness/jquery-ui.css",array(),'1.0');
356
 
357
  }
395
  if (get_option(ENABLE_MSN_TRANSLATE)) {
396
  wp_enqueue_script("mstranslate","http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId=".get_option(MSN_TRANSLATE_KEY),array(),'1',get_option(ENABLE_FOOTER_SCRIPTS));
397
  }
398
+ wp_enqueue_script("transposh","$tr_plugin_url/js/transposh.js?post_url=$post_url{$edit_mode}&lang={$GLOBALS['lang']}&prefix=".SPAN_PREFIX,array("jquery"),'0.3.1',get_option(ENABLE_FOOTER_SCRIPTS));
399
  }
400
  }
401
 
transposh_admin.php CHANGED
@@ -281,7 +281,7 @@ class transposh_plugin {
281
  //constructor of class, PHP4 compatible construction for backward compatibility
282
  function transposh_plugin() {
283
  if (get_option(ENABLE_CSS_FLAGS))
284
- wp_enqueue_style("transposh-flags",plugins_url('', __FILE__)."/css/transposh_flags.css",array(),'0.3.0');
285
  //add filter for WordPress 2.8 changed backend box system !
286
  add_filter('screen_layout_columns', array(&$this, 'on_screen_layout_columns'), 10, 2);
287
  //add some help
281
  //constructor of class, PHP4 compatible construction for backward compatibility
282
  function transposh_plugin() {
283
  if (get_option(ENABLE_CSS_FLAGS))
284
+ wp_enqueue_style("transposh-flags",plugins_url('', __FILE__)."/css/transposh_flags.css",array(),'0.3.1');
285
  //add filter for WordPress 2.8 changed backend box system !
286
  add_filter('screen_layout_columns', array(&$this, 'on_screen_layout_columns'), 10, 2);
287
  //add some help
transposh_db.php CHANGED
@@ -93,19 +93,18 @@ function fetch_translation($original, $lang) {
93
 
94
  /*
95
  * A new translation has been posted, update the translation database.
 
96
  */
97
  function update_translation() {
98
  global $wpdb;
99
 
100
  $ref=getenv('HTTP_REFERER');
101
- $original = base64_url_decode($_POST['token']);
102
- $translation = $_POST['translation'];
103
  $lang = $_POST['lang'];
104
  $source = $_POST['source'];
105
-
106
  // check params
107
 
108
- if(!isset($original) || !isset($translation) || !isset($lang)) {
109
 
110
  return;
111
  }
@@ -119,81 +118,82 @@ function update_translation() {
119
  exit;
120
  }
121
 
122
- $table_name = $wpdb->prefix . TRANSLATIONS_TABLE;
123
-
124
- //Decode & remove already escaped character to avoid double escaping
125
- $translation = $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translation))));
126
-
127
- //The original content is encoded as base64 before it is sent (i.e. token), after we
128
- //decode it should just the same after it was parsed.
129
- $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
130
 
131
- //add our own custom header - so we will know that we got here
132
- header("Transposh: ver-0.3.0 db_version-". DB_VERSION);
 
133
 
134
- list($translated_text, $old_source) = fetch_translation($original, $lang);
135
- if ($translated_text) {
136
- if ($source == 1) {
137
-
138
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
- if ($translation == $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translated_text)))) && $old_source == $source) {
141
-
142
- return;
 
 
 
 
 
143
  }
144
  }
145
 
146
- $update = "REPLACE INTO $table_name (original, translated, lang, source)
147
- VALUES ('" . $original . "','" . $translation . "','" . $lang . "','" . $source . "')";
 
 
148
 
149
  $result = $wpdb->query($update);
150
 
151
  if($result !== FALSE) {
152
- update_transaction_log($original, $translation, $lang, $source);
153
-
154
- //Delete entry from cache
155
- if(ENABLE_APC && function_exists('apc_store')) {
156
- apc_delete($original .'___'. $lang);
157
- }
158
 
159
 
160
  }
161
  else {
162
 
 
163
  header("HTTP/1.0 404 Failed to update language database ".mysql_error());
164
  }
165
-
166
  exit;
167
  }
168
 
169
  /*
170
- * Update the transaction log
171
- */
172
- function update_transaction_log(&$original, &$translation, &$lang, $source) {
173
- global $wpdb, $user_ID;
174
- get_currentuserinfo();
175
-
176
- // log either the user ID or his IP
177
- if ('' == $user_ID) {
178
- $loguser = $_SERVER['REMOTE_ADDR'];
179
- }
180
- else {
181
- $loguser = $user_ID;
182
- }
183
-
184
- $log = "INSERT INTO ".$wpdb->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) ".
185
- "VALUES ('" . $original . "','" . $translation . "','" . $lang . "','".$loguser."','".$source."')";
186
-
187
- $result = $wpdb->query($log);
188
-
189
- if($result === FALSE) {
190
-
191
-
192
- }
193
- }
194
-
195
- /*
196
- * A new translation has been posted, update the translation database.
197
  */
198
  function get_translation_history($token, $lang) {
199
  global $wpdb;
@@ -227,7 +227,7 @@ function get_translation_history($token, $lang) {
227
  $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
228
 
229
  //add our own custom header - so we will know that we got here
230
- header("Transposh: ver-0.3.0 db_version-". DB_VERSION);
231
 
232
  $query = "SELECT translated, translated_by, timestamp, source, user_login ".
233
  "FROM $table_name ".
93
 
94
  /*
95
  * A new translation has been posted, update the translation database.
96
+ * This has changed since we now accept multiple translations at once
97
  */
98
  function update_translation() {
99
  global $wpdb;
100
 
101
  $ref=getenv('HTTP_REFERER');
102
+ $items = $_POST['items'];
 
103
  $lang = $_POST['lang'];
104
  $source = $_POST['source'];
 
105
  // check params
106
 
107
+ if(!isset($items) || !isset($lang)) {
108
 
109
  return;
110
  }
118
  exit;
119
  }
120
 
121
+ //add our own custom header - so we will know that we got here
122
+ header("Transposh: ver-0.3.1 db_version-". DB_VERSION);
 
 
 
 
 
 
123
 
124
+ // transaction log stuff
125
+ global $user_ID;
126
+ get_currentuserinfo();
127
 
128
+ // log either the user ID or his IP
129
+ if ('' == $user_ID) {
130
+ $loguser = $_SERVER['REMOTE_ADDR'];
131
+ }
132
+ else {
133
+ $loguser = $user_ID;
134
+ }
135
+ // end tl
136
+
137
+ // We are now passing all posted items
138
+ for ($i=0;$i<$items;$i++) {
139
+ $original = base64_url_decode($_POST["tk$i"]);
140
+ $translation = $_POST["tr$i"];
141
+ //Decode & remove already escaped character to avoid double escaping
142
+ $translation = $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translation))));
143
+
144
+ //The original content is encoded as base64 before it is sent (i.e. token), after we
145
+ //decode it should just the same after it was parsed.
146
+ $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
147
+
148
+ //Here we check we are not redoing stuff
149
+ list($translated_text, $old_source) = fetch_translation($original, $lang);
150
+ if ($translated_text) {
151
+ if ($source == 1) {
152
+
153
+ return;
154
+ }
155
+ if ($translation == $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translated_text)))) && $old_source == $source) {
156
+
157
+ return;
158
+ }
159
  }
160
+ // Setting the values string for the database (notice how concatanation is handled)
161
+ $values .= "('" . $original . "','" . $translation . "','" . $lang . "','" . $source . "')".(($items != $i+1) ?', ':'');
162
+ // Setting the transaction log records
163
+ $logvalues .= "('" . $original . "','" . $translation . "','" . $lang . "','".$loguser."','".$source."')".(($items != $i+1) ?', ':'');
164
+
165
+ // If we have caching - we remove previous entry from cache
166
+ if(ENABLE_APC && function_exists('apc_store')) {
167
+ apc_delete($original .'___'. $lang);
168
  }
169
  }
170
 
171
+ // perform insertion to the database, with one query :)
172
+ $update = "REPLACE INTO ".$wpdb->prefix . TRANSLATIONS_TABLE." (original, translated, lang, source)
173
+ VALUES $values";
174
+
175
 
176
  $result = $wpdb->query($update);
177
 
178
  if($result !== FALSE) {
179
+ // update the transaction log too
180
+ $log = "INSERT INTO ".$wpdb->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) ".
181
+ "VALUES $logvalues";
182
+ $result = $wpdb->query($log);
 
 
183
 
184
 
185
  }
186
  else {
187
 
188
+
189
  header("HTTP/1.0 404 Failed to update language database ".mysql_error());
190
  }
191
+ // this is a termination for the ajax sequence
192
  exit;
193
  }
194
 
195
  /*
196
+ * Get translation history for some translation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  */
198
  function get_translation_history($token, $lang) {
199
  global $wpdb;
227
  $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
228
 
229
  //add our own custom header - so we will know that we got here
230
+ header("Transposh: ver-0.3.1 db_version-". DB_VERSION);
231
 
232
  $query = "SELECT translated, translated_by, timestamp, source, user_login ".
233
  "FROM $table_name ".
transposh_widget.php CHANGED
@@ -85,11 +85,11 @@ function add_transposh_widget_css() {
85
  // TODO: user generated version
86
  $options = get_option(WIDGET_TRANSPOSH);
87
  if ($options['style'] == 1 || $options['style'] == 2) {
88
- wp_enqueue_style("transposh_widget","{$GLOBALS['tr_plugin_url']}/css/transposh_widget.css",array(),'0.3.0');
89
  if (get_option(ENABLE_CSS_FLAGS)) {
90
- wp_enqueue_style("transposh_flags", "{$GLOBALS['tr_plugin_url']}/css/transposh_flags.css",array(),'0.3.0');
91
  if (file_exists("{$GLOBALS['tr_plugin_url']}/css/transposh_flags_u.css"))
92
- wp_enqueue_style("transposh_flags", "{$GLOBALS['tr_plugin_url']}/css/transposh_flags_u.css",array(),'0.3.0');
93
  }
94
  }
95
 
@@ -139,7 +139,7 @@ function transposh_widget($args) {
139
  }
140
 
141
 
142
- echo "<a href=\"" . $page_url . "\">".
143
  display_flag("$plugpath/img/flags/", $flag, $language,get_option(ENABLE_CSS_FLAGS)).
144
  "</a>";
145
  if ($options['style'] != 1) {
85
  // TODO: user generated version
86
  $options = get_option(WIDGET_TRANSPOSH);
87
  if ($options['style'] == 1 || $options['style'] == 2) {
88
+ wp_enqueue_style("transposh_widget","{$GLOBALS['tr_plugin_url']}/css/transposh_widget.css",array(),'0.3.1');
89
  if (get_option(ENABLE_CSS_FLAGS)) {
90
+ wp_enqueue_style("transposh_flags", "{$GLOBALS['tr_plugin_url']}/css/transposh_flags.css",array(),'0.3.1');
91
  if (file_exists("{$GLOBALS['tr_plugin_url']}/css/transposh_flags_u.css"))
92
+ wp_enqueue_style("transposh_flags", "{$GLOBALS['tr_plugin_url']}/css/transposh_flags_u.css",array(),'0.3.1');
93
  }
94
  }
95
 
139
  }
140
 
141
 
142
+ echo "<a href=\"" . $page_url . '"'.(($GLOBALS['lang'] == $code) ? ' class="tr_active"' :'').'>'.
143
  display_flag("$plugpath/img/flags/", $flag, $language,get_option(ENABLE_CSS_FLAGS)).
144
  "</a>";
145
  if ($options['style'] != 1) {