Version Description
Minor bug fixes, more compatability
Download this release
Release Info
Developer | oferwald |
Plugin | Transposh WordPress Translation |
Version | 0.4.3 |
Comparing to | |
See all releases |
Code changes from version 0.4.2 to 0.4.3
- core/constants.php +2 -2
- core/parser.php +18 -6
- css/transposh_flags.css +1 -1
- img/{flags.png → flags53.png} +0 -0
- js/transposh.js +6 -8
- js/transposhedit.js +13 -13
- readme.txt +11 -2
- transposh.php +30 -20
- wp/transposh_ajax.php +11 -0
- wp/transposh_db.php +25 -0
core/constants.php
CHANGED
@@ -90,14 +90,14 @@ $languages = array(
|
|
90 |
$rtl_languages = array("ar", "he", "fa", "yi");
|
91 |
|
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.
|
101 |
|
102 |
//Define segment id prefix, will be included in span tag. also used as class identifier
|
103 |
define("SPAN_PREFIX", "tr_");
|
90 |
$rtl_languages = array("ar", "he", "fa", "yi");
|
91 |
|
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", "ht", "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.3');
|
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
@@ -258,7 +258,7 @@ class parser {
|
|
258 |
* @return int length of number.
|
259 |
*/
|
260 |
function is_number($page, $position) {
|
261 |
-
return strspn($page,'0123456789
|
262 |
}
|
263 |
|
264 |
/**
|
@@ -326,8 +326,20 @@ class parser {
|
|
326 |
$start = $pos;
|
327 |
}
|
328 |
// Numbers also break, if they are followed by whitespace (or a sentence breaker) (don't break 42nd) // TODO: probably by breaking entities too...
|
|
|
329 |
elseif($num_len = $this->is_number($string,$pos)) {
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
$this->tag_phrase($string,$start,$pos);
|
332 |
$start = $pos + $num_len + 1;
|
333 |
}
|
@@ -418,15 +430,15 @@ class parser {
|
|
418 |
function create_edit_span ($original_text , $translated_text, $source, $for_hidden_element = false) {
|
419 |
// Use base64 encoding to make that when the page is translated (i.e. update_translation) we
|
420 |
// get back exactlly the same string without having the client decode/encode it in anyway.
|
421 |
-
$span = '<span class ="'.SPAN_PREFIX.'" id="'.SPAN_PREFIX.$this->segment_id.'" token="' . base64_url_encode($original_text)."\" source=\"$source\"";
|
422 |
// those are needed for on the fly image creation / hidden elements translations
|
423 |
if ($this->is_edit_mode || $for_hidden_element) {
|
424 |
-
$span .= " orig=\"$original_text\"";
|
425 |
if ($for_hidden_element) {
|
426 |
-
$span.= ' hidden="y"';
|
427 |
// hidden elements currently have issues figuring what they translated in the JS
|
428 |
if ($translated_text != null) {
|
429 |
-
$span.= " trans=\"$translated_text\"";
|
430 |
}
|
431 |
}
|
432 |
}
|
258 |
* @return int length of number.
|
259 |
*/
|
260 |
function is_number($page, $position) {
|
261 |
+
return strspn($page,'0123456789-+$%,.\\/',$position);
|
262 |
}
|
263 |
|
264 |
/**
|
326 |
$start = $pos;
|
327 |
}
|
328 |
// Numbers also break, if they are followed by whitespace (or a sentence breaker) (don't break 42nd) // TODO: probably by breaking entities too...
|
329 |
+
// also prefixed by whitespace?
|
330 |
elseif($num_len = $this->is_number($string,$pos)) {
|
331 |
+
// this is the case of B2 or B2,
|
332 |
+
if (($this->is_white_space($string[$pos-1]) || ($start == $pos)
|
333 |
+
|| ($this->is_sentence_breaker($string[$pos+$num_len-1],$string[$pos+$num_len],$string[$pos+$num_len+1]))) &&
|
334 |
+
($this->is_white_space($string[$pos+$num_len]) || $this->is_sentence_breaker($string[$pos+$num_len],$string[$pos+$num_len+1],$string[$pos+$num_len+2]))) {
|
335 |
+
// we will now compensate on the number followed by breaker case, if we need to
|
336 |
+
if (!($this->is_white_space($string[$pos-1]) || ($start == $pos))) {
|
337 |
+
if ($this->is_sentence_breaker($string[$pos+$num_len-1],$string[$pos+$num_len],$string[$pos+$num_len+1])) {
|
338 |
+
$num_len--; //this makes the added number shorter by one, and the pos will be at a sentence breaker next so we don't have to compensate
|
339 |
+
}
|
340 |
+
$pos += $num_len;
|
341 |
+
$num_len = 0; // we have already added this
|
342 |
+
}
|
343 |
$this->tag_phrase($string,$start,$pos);
|
344 |
$start = $pos + $num_len + 1;
|
345 |
}
|
430 |
function create_edit_span ($original_text , $translated_text, $source, $for_hidden_element = false) {
|
431 |
// Use base64 encoding to make that when the page is translated (i.e. update_translation) we
|
432 |
// get back exactlly the same string without having the client decode/encode it in anyway.
|
433 |
+
$span = '<span class ="'.SPAN_PREFIX.'" id="'.SPAN_PREFIX.$this->segment_id.'" data-token="' . base64_url_encode($original_text)."\" data-source=\"$source\"";
|
434 |
// those are needed for on the fly image creation / hidden elements translations
|
435 |
if ($this->is_edit_mode || $for_hidden_element) {
|
436 |
+
$span .= " data-orig=\"$original_text\"";
|
437 |
if ($for_hidden_element) {
|
438 |
+
$span.= ' data-hidden="y"';
|
439 |
// hidden elements currently have issues figuring what they translated in the JS
|
440 |
if ($translated_text != null) {
|
441 |
+
$span.= " data-trans=\"$translated_text\"";
|
442 |
}
|
443 |
}
|
444 |
}
|
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/
|
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/flags53.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 → flags53.png}
RENAMED
File without changes
|
js/transposh.js
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
-
(function(){function
|
2 |
-
{ln0:t_jp.lang,sr0:
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
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")})})();
|
1 |
+
(function(a){function w(d,c){if(a.trim(c).length!==0){var f=function(){var b=a(this).attr("id").substr(a(this).attr("id").lastIndexOf("_")+1),p=a("#"+e+"img_"+b);a("#"+e+b).attr("data-source",1);p.removeClass("tr-icon-yellow").removeClass("tr-icon-green").addClass("tr-icon-yellow")};a("*[data-token='"+d+"'][data-hidden!='y']").html(c).each(f);a("*[data-token='"+d+"'][data-hidden='y']").attr("data-trans",c).each(f)}}function l(d,c){t_jp.progress&&a("#"+d).progressbar("value",c)}function q(d,c){clearTimeout(r);
|
2 |
+
h.push(d);m.push(c);w(d,c);r=setTimeout(function(){var f={ln0:t_jp.lang,sr0:s,translation_posted:"2",items:h.length},b;for(b=0;b<h.length;b+=1){f["tk"+b]=h[b];f["tr"+b]=m[b];t+=a("*[data-token='"+h[b]+"']").size()}a.ajax({type:"POST",url:t_jp.post_url,data:f,success:function(){l(j,t/g*100)}});m=[];h=[]},200)}function x(){a("#"+e+"credit").css({overflow:"auto"}).append('<div style="float: left;width: 90%;height: 10px" id="'+i+'"/><div style="margin-bottom:10px;float:left;width: 90%;height: 10px" id="'+
|
3 |
+
j+'"/>');a("#"+i).progressbar({value:0});a("#"+j).progressbar({value:0});a("#"+j+" > div").css({background:"#28F828",border:"#08A908 1px solid"})}function u(){var d=[],c=t_jp.lang;a("."+e+'[data-source=""]').each(function(){var f=a(this).attr("data-token"),b=a(this).attr("data-orig");if(b===undefined)b=a(this).html();if(d[b]!==1){d[b]=1;if(typeof Microsoft!=="undefined"){if(c==="zh")c="zh-chs";else if(c==="zh-tw")c="zh-cht";try{Microsoft.Translator.translate(b,"",c,function(k){q(f,a("<div>"+k+"</div>").text());
|
4 |
+
l(i,(g-a("."+e+'[data-source=""]').size())/g*100)})}catch(p){}}else google.language.translate(b,"",t_jp.lang,function(k){if(!k.error){q(f,a("<div>"+k.translation+"</div>").text());l(i,(g-a("."+e+'[data-source=""]').size())/g*100)}})}})}var n,v,o,g,e=t_jp.prefix,i=e+"pbar",j=i+"_s",s=1,t=0,r,h=[],m=[];v=function(){google.load("language","1",{callback:n})};a(document).ready(function(){a("#"+e+"setdeflang").click(function(){a.get(t_jp.post_url+"?tr_cookie="+Math.random());a(this).hide("slow");return false});
|
5 |
+
var d;g=a("."+e+'[data-source=""]').size();d=new Date;a.ajaxSetup({cache:true});if((g>5||d.getHours()===4&&g>0)&&(t_jp.google||t_jp.msn)){n=function(){if(t_jp.progress){var c=function(){a.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(){x();u()}})};typeof a.xLazyLoader==="function"?c():a.getScript(t_jp.plugin_url+"/js/lazy.js",c)}else u()};if(t_jp.msn&&
|
6 |
+
t_jp.preferred===2||!t_jp.google){s=2;o=function(){a.getScript("http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId="+t_jp.msnkey,n)};t_jp.edit&&t_jp.progress?a.getScript(t_jp.plugin_url+"/js/lazy.js",o):o()}else a.getScript("http://www.google.com/jsapi",v)}t_jp.edit&&a.getScript(t_jp.plugin_url+"/js/transposhedit.js")})})(jQuery);
|
|
|
|
js/transposhedit.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
(function(){function
|
2 |
-
|
3 |
-
google.language.translate(
|
4 |
-
"zh
|
5 |
-
resizable:false,height:140,modal:true,overlay:{backgroundColor:"#000",opacity:0.5},buttons:{Discard:function(){
|
6 |
-
|
7 |
-
"
|
8 |
-
|
9 |
-
"
|
10 |
-
|
11 |
-
t_jp.prefix+
|
12 |
-
|
13 |
-
|
1 |
+
(function(a){function l(b,c){if(a.trim(c).length===0)c=a("[data-token='"+b+"']").attr("data-orig");var e=function(){var f=a(this).attr("id").substr(a(this).attr("id").lastIndexOf("_")+1),d=a("#"+t_jp.prefix+"img_"+f);a("#"+t_jp.prefix+f).attr("data-source",0);d.removeClass("tr-icon-yellow").removeClass("tr-icon-green").addClass("tr-icon-green")};a("*[data-token='"+b+"'][data-hidden!='y']").html(c).each(e);a("*[data-token='"+b+"'][data-hidden='y']").attr("data-trans",c).each(e)}function m(b,c){l(b,
|
2 |
+
c);a.ajax({type:"POST",url:t_jp.post_url,data:{ln0:t_jp.lang,sr0:0,translation_posted:"2",items:1,tk0:b,tr0:c},success:function(){},error:function(e){alert("Error !!! failed to translate.\n\nServer's message: "+e.statusText)}})}function g(){if(typeof google==="undefined"){h=function(){google.load("language","1",{callback:i})};i=function(){g()};a.xLazyLoader({js:"http://www.google.com/jsapi",success:h})}else{a(":button:contains('Suggest - Google')").attr("disabled","disabled").addClass("ui-state-disabled");
|
3 |
+
google.language.translate(a("#"+t_jp.prefix+"original").val(),"",t_jp.lang,function(b){b.error||a("#"+t_jp.prefix+"translation").val(a("<div>"+b.translation+"</div>").text()).keyup()})}}function j(){if(typeof Microsoft==="undefined")a.xLazyLoader({js:"http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId="+t_jp.msnkey,success:function(){j()}});else{a(":button:contains('Suggest - Bing')").attr("disabled","disabled").addClass("ui-state-disabled");var b=t_jp.lang;if(b==="zh")b="zh-chs";if(b==="zh-tw")b=
|
4 |
+
"zh-cht";try{Microsoft.Translator.translate(a("#"+t_jp.prefix+"original").val(),"",b,function(e){a("#"+t_jp.prefix+"translation").val(a("<div>"+e+"</div>").text()).keyup()})}catch(c){alert("There was an error using Microsoft.Translator - probably a bad key or URL used in key. ("+c+")")}}}function n(){a('<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(){a("#"+t_jp.prefix+"translation").data("edit",{changed:false});a(this).dialog("close");a("#"+t_jp.prefix+"d-tabs").dialog("close")},Cancel:function(){a(this).dialog("close")}}})}function k(b){var c={},e={};if(t_jp.msn)c["Suggest - Bing"]=function(){j()};if(t_jp.google)c["Suggest - Google"]=function(){g()};c.Ok=function(){var f=a("#"+t_jp.prefix+"translation").val(),d=a("#"+t_jp.prefix+b).attr("data-token");
|
6 |
+
if(a("#"+t_jp.prefix+"translation").data("edit").changed){m(d,f);a("#"+t_jp.prefix+"translation").data("edit",{changed:false})}a(this).dialog("close")};e={Close:function(){a(this).dialog("close")}};a("#"+t_jp.prefix+"d-tabs").remove();a('<div id="'+t_jp.prefix+'d-tabs" title="Edit Translation"/>').appendTo("body");a("#"+t_jp.prefix+"d-tabs").append("<ul/>").tabs({cache:true}).tabs("add","#"+t_jp.prefix+"d-tabs-1","Translate").tabs("add",t_jp.post_url+"?tr_token_hist="+a("#"+t_jp.prefix+b).attr("data-token")+
|
7 |
+
"&lang="+t_jp.lang,"History").css("text-align","left").css("padding",0).bind("tabsload",function(f,d){a("table",d.panel).addClass("ui-widget ui-widget-content").css({width:"95%",padding:"0"});a("table thead tr",d.panel).addClass("ui-widget-header");a("table tbody td[source='2']",d.panel).append('<span title="computer" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-gear"></span>');a("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>');
|
8 |
+
a("table tbody td[source='0']",d.panel).append('<span title="human" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-person"></span>')}).bind("tabsselect",function(f,d){a(d.tab).text()==="Translate"?a("#"+t_jp.prefix+"d-tabs").dialog("option","buttons",c):a("#"+t_jp.prefix+"d-tabs").dialog("option","buttons",e)}).bind("dialogbeforeclose",function(){if(a("#"+t_jp.prefix+"translation").data("edit").changed){n();return false}return true});a("#"+t_jp.prefix+"d-tabs li").css("list-style-type",
|
9 |
+
"none").css("list-style-position","outside");a("#"+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>');
|
10 |
+
a("#"+t_jp.prefix+"d-tabs-1 label").css("display","block");a("#"+t_jp.prefix+"d-tabs-1 textarea.text").css({"margin-bottom":"12px",width:"95%",padding:".4em"});a("#"+t_jp.prefix+"original").val(a("#"+t_jp.prefix+b).attr("data-orig"));a("#"+t_jp.prefix+"translation").val(a("#"+t_jp.prefix+b).html());a("#"+t_jp.prefix+b).attr("data-trans")&&a("#"+t_jp.prefix+"translation").val(a("#"+t_jp.prefix+b).attr("data-trans"));a("#"+t_jp.prefix+"translation").data("edit",{changed:false});a("#"+t_jp.prefix+"translation").keyup(function(){if(a("#"+
|
11 |
+
t_jp.prefix+b).text()!==a(this).val()){a(this).css("background","yellow");a(this).data("edit",{changed:true})}else{a(this).css("background","");a(this).data("edit",{changed:false})}});a("#"+t_jp.prefix+"d-tabs").dialog({bgiframe:true,modal:true,width:500,buttons:c})}var h,i;a("."+t_jp.prefix).each(function(){var b=a(this).attr("id").substr(a(this).attr("id").lastIndexOf("_")+1),c;a(this).after('<span id="'+t_jp.prefix+"img_"+b+'" class="tr-icon" title="'+a(this).attr("data-orig")+'"></span>');c=a("#"+
|
12 |
+
t_jp.prefix+"img_"+b);c.click(function(){if(typeof a.fn.tabs!=="function"){a.ajaxSetup({cache:true});a.getScript(t_jp.plugin_url+"/js/lazy.js",function(){a.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(){k(b)}})})}else k(b);return false}).css({border:"0px",margin:"1px",padding:"0px"});if(a(this).attr("data-source")==="0")c.addClass("tr-icon-green");
|
13 |
+
else a(this).attr("data-source")&&c.addClass("tr-icon-yellow");a(this).attr("data-hidden")==="y"&&c.css({opacity:"0.6"})})})(jQuery);
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: oferwald, amirperlman
|
|
3 |
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.
|
7 |
-
Stable tag: 0.4.
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
@@ -159,6 +159,8 @@ 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.2 =
|
163 |
This version provides Haitian support, auto translate with bing support
|
164 |
= 0.4.0 =
|
@@ -167,6 +169,13 @@ This version provides integration with google-sitemaps-xml and wp-super-cache
|
|
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
|
3 |
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.2
|
7 |
+
Stable tag: 0.4.3
|
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.3 =
|
163 |
+
Minor bug fixes, more compatability
|
164 |
= 0.4.2 =
|
165 |
This version provides Haitian support, auto translate with bing support
|
166 |
= 0.4.0 =
|
169 |
This version allows sorting of languages within the widget
|
170 |
|
171 |
== Changelog ==
|
172 |
+
= 2010/02/28 - 0.4.3 =
|
173 |
+
* Shrink even more with pre-calculating supported languages
|
174 |
+
* Allow cross-domain posting
|
175 |
+
* Fixed name of flags file
|
176 |
+
* Canned remote jQuery, Async loading and footer scripts in sake of compatability, simplicity
|
177 |
+
* Change internal variables to fit html5
|
178 |
+
* Better mixed number support in parser, esp when $ and % is involved
|
179 |
= 2010/01/26 - 0.4.2 =
|
180 |
* Script split, reduced to 1.5k gzipped in common scenarios
|
181 |
* Haitian translation thanks to Bing translator
|
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.
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
@@ -115,7 +115,7 @@ class transposh_plugin {
|
|
115 |
add_action('shutdown', array(&$this,'on_shutdown'));
|
116 |
add_action('wp_print_styles', array(&$this,'add_transposh_css'));
|
117 |
add_action('wp_print_scripts', array(&$this,'add_transposh_js'));
|
118 |
-
add_action('wp_head', array(&$this,'add_transposh_async'));
|
119 |
add_action("sm_addurl",array(&$this,'add_sm_transposh_urls'));
|
120 |
register_activation_hook(__FILE__, array(&$this,'plugin_activate'));
|
121 |
register_deactivation_hook(__FILE__,array(&$this,'plugin_deactivate'));
|
@@ -460,7 +460,7 @@ class transposh_plugin {
|
|
460 |
*/
|
461 |
function add_transposh_css() {
|
462 |
//translation not allowed - no need for the transposh.css
|
463 |
-
if(!$this->is_editing_permitted() && !$this->is_auto_translate_permitted()) return;
|
464 |
// actually - this is only needed when editing
|
465 |
if (!$this->edit_mode) return;
|
466 |
// TODO - remove on lazy load...
|
@@ -483,8 +483,27 @@ class transposh_plugin {
|
|
483 |
|
484 |
if($this->edit_mode || $this->is_auto_translate_permitted()) {
|
485 |
//TODO - fix (onetime var)
|
486 |
-
wp_deregister_script('jquery');
|
487 |
-
wp_enqueue_script("jquery"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
}
|
@@ -494,7 +513,8 @@ class transposh_plugin {
|
|
494 |
* Inserts the transposh async loading in the head.
|
495 |
* @return nothing
|
496 |
*/
|
497 |
-
|
|
|
498 |
if (!$this->edit_mode && !$this->is_auto_translate_permitted()) {
|
499 |
return;
|
500 |
}
|
@@ -506,29 +526,19 @@ class transposh_plugin {
|
|
506 |
echo "t_jp.edit=".($this->edit_mode? 'true' : 'false').";";
|
507 |
//echo "t_jp.rtl=".(in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : 'false').";";
|
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 |
-
/*
|
515 |
-
* // let's lazy load! (worked, didn't make sense)
|
516 |
-
// jQuery(document).ready(
|
517 |
-
jQuery(window).load(
|
518 |
-
function() {
|
519 |
-
jQuery.ajax({
|
520 |
-
type: 'GET',
|
521 |
-
url: '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."',
|
522 |
-
dataType: 'script',
|
523 |
-
cache: true
|
524 |
-
});
|
525 |
-
});
|
526 |
-
*/
|
527 |
echo "var tp = document.createElement('script'); tp.type = 'text/javascript'; tp.async = true;";
|
528 |
echo "tp.src = '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."';";
|
529 |
echo "(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(tp);";
|
530 |
echo"</script>";
|
531 |
-
}
|
532 |
|
533 |
/**
|
534 |
* Determine if the currently selected language (taken from the query parameters) is in the admin's list
|
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.3
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
115 |
add_action('shutdown', array(&$this,'on_shutdown'));
|
116 |
add_action('wp_print_styles', array(&$this,'add_transposh_css'));
|
117 |
add_action('wp_print_scripts', array(&$this,'add_transposh_js'));
|
118 |
+
// add_action('wp_head', array(&$this,'add_transposh_async'));
|
119 |
add_action("sm_addurl",array(&$this,'add_sm_transposh_urls'));
|
120 |
register_activation_hook(__FILE__, array(&$this,'plugin_activate'));
|
121 |
register_deactivation_hook(__FILE__,array(&$this,'plugin_deactivate'));
|
460 |
*/
|
461 |
function add_transposh_css() {
|
462 |
//translation not allowed - no need for the transposh.css
|
463 |
+
if(!$this->is_editing_permitted() && !$this->is_auto_translate_permitted()) return;
|
464 |
// actually - this is only needed when editing
|
465 |
if (!$this->edit_mode) return;
|
466 |
// TODO - remove on lazy load...
|
483 |
|
484 |
if($this->edit_mode || $this->is_auto_translate_permitted()) {
|
485 |
//TODO - fix (onetime var)
|
486 |
+
// wp_deregister_script('jquery');
|
487 |
+
//wp_enqueue_script("jquery");
|
488 |
+
//wp_enqueue_script("transposh","{$this->transposh_plugin_url}/js/transposh.js",array("jquery"),TRANSPOSH_PLUGIN_VER,true)
|
489 |
+
wp_enqueue_script("transposh","{$this->transposh_plugin_url}/js/transposh.js",array("jquery"),TRANSPOSH_PLUGIN_VER);
|
490 |
+
// true -> 1, false -> nothing
|
491 |
+
wp_localize_script("transposh","t_jp",array(
|
492 |
+
'post_url' => $this->post_url,
|
493 |
+
'plugin_url' => $this->transposh_plugin_url,
|
494 |
+
'edit' => ($this->edit_mode? '1' : ''),
|
495 |
+
//'rtl' => (in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : ''),
|
496 |
+
'lang' => $this->target_language,
|
497 |
+
// those two options show if the script can support said engines
|
498 |
+
'msn' => (in_array($this->target_language,$GLOBALS['bing_languages']) && $this->options->get_msn_key() ? '1' : ''),
|
499 |
+
'google' => (in_array($this->target_language,$GLOBALS['google_languages']) ? '1' : ''),
|
500 |
+
'prefix' => SPAN_PREFIX,
|
501 |
+
'msnkey'=>$this->options->get_msn_key(),
|
502 |
+
'preferred'=> $this->options->get_preferred_translator(),
|
503 |
+
'progress'=>$this->edit_mode || $this->options->get_widget_progressbar() ? '1' : '')
|
504 |
+
// 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
|
505 |
+
);
|
506 |
+
/*wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');*/
|
507 |
// toying around - for later...
|
508 |
// wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js",array(),'1.4.1');
|
509 |
}
|
513 |
* Inserts the transposh async loading in the head.
|
514 |
* @return nothing
|
515 |
*/
|
516 |
+
// lost in compatability
|
517 |
+
/* function add_transposh_async() {
|
518 |
if (!$this->edit_mode && !$this->is_auto_translate_permitted()) {
|
519 |
return;
|
520 |
}
|
526 |
echo "t_jp.edit=".($this->edit_mode? 'true' : 'false').";";
|
527 |
//echo "t_jp.rtl=".(in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : 'false').";";
|
528 |
echo "t_jp.lang='{$this->target_language}';";
|
529 |
+
// those two options show if the script can support said engines
|
530 |
+
echo "t_jp.msn=".(in_array($this->target_language,$GLOBALS['bing_languages']) && $this->options->get_msn_key() ? 'true' : 'false').";";
|
531 |
+
echo "t_jp.google=".(in_array($this->target_language,$GLOBALS['google_languages']) ? 'true' : 'false').";";
|
532 |
echo "t_jp.prefix='".SPAN_PREFIX."';";
|
533 |
echo "t_jp.msnkey='{$this->options->get_msn_key()}';";
|
534 |
echo "t_jp.preferred='{$this->options->get_preferred_translator()}';";
|
535 |
echo "t_jp.progress=".($this->edit_mode || $this->options->get_widget_progressbar() ? 'true' : 'false').";";
|
536 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
echo "var tp = document.createElement('script'); tp.type = 'text/javascript'; tp.async = true;";
|
538 |
echo "tp.src = '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."';";
|
539 |
echo "(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(tp);";
|
540 |
echo"</script>";
|
541 |
+
}*/
|
542 |
|
543 |
/**
|
544 |
* Determine if the currently selected language (taken from the query parameters) is in the admin's list
|
wp/transposh_ajax.php
CHANGED
@@ -19,6 +19,17 @@
|
|
19 |
/*
|
20 |
* This file handles various AJAX needs of our plugin
|
21 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
// we need wordpress and us...
|
23 |
require_once('../../../../wp-load.php');
|
24 |
|
19 |
/*
|
20 |
* This file handles various AJAX needs of our plugin
|
21 |
*/
|
22 |
+
// The following headers allow for cross-domain posting here, which is useful for some weird sites
|
23 |
+
header('Access-Control-Allow-Origin: *');
|
24 |
+
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
25 |
+
header('Access-Control-Allow-Headers: X-Requested-With');
|
26 |
+
header('Access-Control-Max-Age: 86400');
|
27 |
+
|
28 |
+
// Exit early so the page isn't fully loaded for options requests
|
29 |
+
if (strtolower($_SERVER['REQUEST_METHOD']) == 'options') {
|
30 |
+
exit();
|
31 |
+
}
|
32 |
+
|
33 |
// we need wordpress and us...
|
34 |
require_once('../../../../wp-load.php');
|
35 |
|
wp/transposh_db.php
CHANGED
@@ -287,6 +287,31 @@ class transposh_database {
|
|
287 |
|
288 |
exit;
|
289 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
/*
|
292 |
* Setup the translation database.
|
287 |
|
288 |
exit;
|
289 |
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Function to return human translations history
|
293 |
+
* @param string $date - either null for all or a date to get terms after
|
294 |
+
* @return array List of rows
|
295 |
+
*/
|
296 |
+
function get_all_human_translation_history($date ="null", $limit = "") {
|
297 |
+
|
298 |
+
$table_name = $GLOBALS['wpdb']->prefix . TRANSLATIONS_LOG;
|
299 |
+
|
300 |
+
|
301 |
+
//add our own custom header - so we will know that we got here
|
302 |
+
// header("Transposh: v-".TRANSPOSH_PLUGIN_VER." db_version-". DB_VERSION);
|
303 |
+
|
304 |
+
if ($date != "null") $dateterm = "and UNIX_TIMESTAMP(timestamp) > $date";
|
305 |
+
if ($limit) $limitterm = "LIMIT $limit";
|
306 |
+
$query = "SELECT original, lang, translated, translated_by, UNIX_TIMESTAMP(timestamp) as timestamp ".
|
307 |
+
"FROM $table_name ".
|
308 |
+
"WHERE source= 0 $dateterm ".
|
309 |
+
"ORDER BY timestamp ASC $limitterm";
|
310 |
+
|
311 |
+
|
312 |
+
$rows = $GLOBALS['wpdb']->get_results($query);
|
313 |
+
return $rows;
|
314 |
+
}
|
315 |
|
316 |
/*
|
317 |
* Setup the translation database.
|