Transposh WordPress Translation - Version 0.5.0

Version Description

Ability to translate all content, backup service for human translations

Download this release

Release Info

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

Code changes from version 0.4.3 to 0.5.0

core/constants.php CHANGED
@@ -92,12 +92,12 @@ $rtl_languages = array("ar", "he", "fa", "yi");
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_");
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", "hu", "it", "ja", "ko", "lt", "no", "pl", "pt", "ro", "ru", "sk", "sl", "es", "sv", "th", "tr");
96
 
97
  //Define the new capability that will be assigned to roles - translator
98
  define("TRANSLATOR", 'translator');
99
 
100
+ define("TRANSPOSH_PLUGIN_VER",'0.5.0');
101
 
102
  //Define segment id prefix, will be included in span tag. also used as class identifier
103
  define("SPAN_PREFIX", "tr_");
js/transposhadmin.js CHANGED
@@ -1,6 +1,5 @@
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)}})})})}})});
1
  var timer,items=0,translations=[],tokens=[],langs=[];
2
+ function ajax_translate_me(g,c,e){clearTimeout(timer);items++;tokens.push(g);translations.push(c);langs.push(e);timer=setTimeout(function(){for(var b={sr0:1,translation_posted:"2",items:items},a=0;a<items;a++){if(tokens[a]!=tokens[a-1])b["tk"+a]=tokens[a];if(langs[a]!=langs[a-1])b["ln"+a]=langs[a];if(translations[a]!=translations[a-1])b["tr"+a]=translations[a]}jQuery.ajax({type:"POST",url:t_jp.post_url,data:b,success:function(){},error:function(){}});items=0;translations=[];tokens=[];langs=[]},200)}
3
+ function translate_post(g){var c=0,e="",b=0;jQuery("#tr_loading").data("done",false);jQuery.getJSON(t_jp.post_url+"?tr_phrases_post=y&post="+g+"&random="+Math.random(),function(a){jQuery("#tr_translate_title").html("Translating post: "+a.posttitle);if(a.length===undefined){jQuery("#tr_loading").html("Nothing left to translate");jQuery("#tr_loading").data("done",true)}else{jQuery("#tr_loading").html('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>');
4
+ jQuery("#progress_bar").progressbar({value:0});jQuery("#progress_bar2").progressbar({value:0});jQuery.each(a.p,function(f,d){jQuery("#progress_bar2").progressbar("value",b/d.l.length*100);jQuery.each(d.l,function(j,h){google.language.translate(f,"",h,function(i){if(!i.error){if(e!=f){e=f;b=0;c++}jQuery("#progress_bar").progressbar("value",c/a.length*100);b++;jQuery("#progress_bar2").progressbar("value",b/d.l.length*100);jQuery("#p").text(jQuery("<div>"+f+"</div>").text());jQuery("#l").text(h);jQuery("#r").text(jQuery("<div>"+
5
+ i.translation+"</div>").text());c===a.length&&b===d.l.length&&jQuery("#tr_loading").data("done",true);ajax_translate_me(d.t,jQuery("<div>"+i.translation+"</div>").text(),h)}})})})}})}google.load("language","1");jQuery(document).ready(function(){t_jp.post&&translate_post(t_jp.post)});
 
js/transposhcontrol.js CHANGED
@@ -3,4 +3,7 @@ jQuery("#sortable").disableSelection();jQuery("#changename").click(function(){jQ
3
  else if(jQuery(this).hasClass("active")){jQuery(this).removeClass("active");jQuery(this).addClass("translateable")}else jQuery(this).hasClass("translateable")?jQuery(this).removeClass("translateable"):jQuery(this).addClass("active");jQuery("input",this).val(jQuery(this).attr("id")+(jQuery(this).hasClass("active")?",v":",")+(jQuery(this).hasClass("translateable")?",t":","))}};jQuery(".languages").dblclick(clickfunction).click(clickfunction);jQuery("#default_lang").droppable({accept:".languages",activeClass:"highlight_default",
4
  drop:function(b,a){jQuery("#default_list").empty();jQuery(a.draggable.clone().removeAttr("style").removeClass("active").removeClass("translateable")).appendTo("#default_list").show("slow");jQuery("#default_list .logoicon").remove();jQuery("#sortable").find("#"+a.draggable.attr("id")).addClass("active")}});jQuery("#sortiso").click(function(){jQuery("#sortable li").sort(function(b,a){if(jQuery(b).attr("id")==jQuery("#default_list li").attr("id"))return-1;if(jQuery(a).attr("id")==jQuery("#default_list li").attr("id"))return 1;
5
  return jQuery(b).attr("id")>jQuery(a).attr("id")?1:-1}).remove().appendTo("#sortable").dblclick(clickfunction).click(clickfunction);return false});jQuery("#sortname").click(function(){jQuery("#sortable li").sort(function(b,a){langa=jQuery(".langname",b).filter(function(){return!jQuery(this).hasClass("hidden")}).text();langb=jQuery(".langname",a).filter(function(){return!jQuery(this).hasClass("hidden")}).text();langdef=jQuery(".langname","#default_list li").filter(function(){return!jQuery(this).hasClass("hidden")}).text();
6
- if(langa==langdef)return-1;if(langb==langdef)return 1;return langa>langb?1:-1}).remove().appendTo("#sortable").dblclick(clickfunction).click(clickfunction);return false})});
 
 
 
3
  else if(jQuery(this).hasClass("active")){jQuery(this).removeClass("active");jQuery(this).addClass("translateable")}else jQuery(this).hasClass("translateable")?jQuery(this).removeClass("translateable"):jQuery(this).addClass("active");jQuery("input",this).val(jQuery(this).attr("id")+(jQuery(this).hasClass("active")?",v":",")+(jQuery(this).hasClass("translateable")?",t":","))}};jQuery(".languages").dblclick(clickfunction).click(clickfunction);jQuery("#default_lang").droppable({accept:".languages",activeClass:"highlight_default",
4
  drop:function(b,a){jQuery("#default_list").empty();jQuery(a.draggable.clone().removeAttr("style").removeClass("active").removeClass("translateable")).appendTo("#default_list").show("slow");jQuery("#default_list .logoicon").remove();jQuery("#sortable").find("#"+a.draggable.attr("id")).addClass("active")}});jQuery("#sortiso").click(function(){jQuery("#sortable li").sort(function(b,a){if(jQuery(b).attr("id")==jQuery("#default_list li").attr("id"))return-1;if(jQuery(a).attr("id")==jQuery("#default_list li").attr("id"))return 1;
5
  return jQuery(b).attr("id")>jQuery(a).attr("id")?1:-1}).remove().appendTo("#sortable").dblclick(clickfunction).click(clickfunction);return false});jQuery("#sortname").click(function(){jQuery("#sortable li").sort(function(b,a){langa=jQuery(".langname",b).filter(function(){return!jQuery(this).hasClass("hidden")}).text();langb=jQuery(".langname",a).filter(function(){return!jQuery(this).hasClass("hidden")}).text();langdef=jQuery(".langname","#default_list li").filter(function(){return!jQuery(this).hasClass("hidden")}).text();
6
+ if(langa==langdef)return-1;if(langb==langdef)return 1;return langa>langb?1:-1}).remove().appendTo("#sortable").dblclick(clickfunction).click(clickfunction);return false});backupclick=function(){jQuery("#transposh-backup").click(function(){return false}).text("Backup In Progress");jQuery.get(t_jp.post_url+"?backup="+Math.random(),function(b){var a="red";if(b[0]=="2")a="green";jQuery("#backup_result").html(b).css("color",a);jQuery("#transposh-backup").click(backupclick).text("Do Backup Now")});return false};
7
+ jQuery("#transposh-backup").click(backupclick);do_translate_all=function(){jQuery("#progress_bar_all").progressbar({value:0});stop_translate_var=false;jQuery("#tr_loading").data("done",true);jQuery.ajaxSetup({cache:false});jQuery.getJSON(t_jp.post_url,{translate_all:"y"},function(b){dotimer=function(a){clearTimeout(timer2);if(jQuery("#tr_loading").data("done")||jQuery("#tr_loading").data("attempt")>4){jQuery("#progress_bar_all").progressbar("value",(a+1)/b.length*100);jQuery("#tr_loading").data("attempt",
8
+ 0);translate_post(b[a]);if(b[a]&&!stop_translate_var)timer2=setTimeout(function(){dotimer(a+1)},1E3)}else{jQuery("#tr_loading").data("attempt",jQuery("#tr_loading").data("attempt")+1);timer2=setTimeout(function(){dotimer(a)},6E4)}};timer2=setTimeout(function(){dotimer(0)},0)});jQuery("#transposh-translate").text("Stop translate");jQuery("#transposh-translate").click(stop_translate);return false};stop_translate=function(){clearTimeout(timer2);stop_translate_var=true;jQuery("#transposh-translate").text("Translate All Now");
9
+ jQuery("#transposh-translate").click(do_translate_all);return false};jQuery("#transposh-translate").click(do_translate_all)});
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Transposh - translation filter for wordpress ===
2
  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.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,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.3 =
163
  Minor bug fixes, more compatability
164
  = 0.4.2 =
@@ -169,6 +171,10 @@ This version provides integration with google-sitemaps-xml and wp-super-cache
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
1
  === Transposh - translation filter for wordpress ===
2
  Contributors: oferwald, amirperlman
3
  Donate link: http://transposh.org/donate/
4
+ Tags: translation, widget, filter, bilingual, multilingual, transposh, translate, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
5
  Requires at least: 2.7
6
  Tested up to: 2.9.2
7
+ Stable tag: 0.5.0
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.5.0 =
163
+ Ability to translate all content, backup service for human translations
164
  = 0.4.3 =
165
  Minor bug fixes, more compatability
166
  = 0.4.2 =
171
  This version allows sorting of languages within the widget
172
 
173
  == Changelog ==
174
+ = 2010/03/24 - 0.5.0 =
175
+ * Ability to backup human translation to a remote database (hosted on google appengine)
176
+ * Ability to translate all existing content with a single click from the administration page
177
+ * 7 more languages added to MSN translator
178
  = 2010/02/28 - 0.4.3 =
179
  * Shrink even more with pre-calculating supported languages
180
  * Allow cross-domain posting
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.3
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
@@ -43,6 +43,7 @@ require_once("wp/transposh_widget.php");
43
  require_once("wp/transposh_admin.php");
44
  require_once("wp/transposh_options.php");
45
  require_once("wp/transposh_postpublish.php");
 
46
 
47
  /**
48
  * This class represents the complete plugin
@@ -117,6 +118,8 @@ class transposh_plugin {
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'));
122
  }
@@ -700,7 +703,17 @@ class transposh_plugin {
700
  }
701
  }
702
  }
 
 
 
 
 
 
 
 
 
703
  }
 
704
  $my_transposh_plugin = new transposh_plugin();
705
 
706
  ?>
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.5.0
8
  Author URI: http://transposh.org/
9
  License: GPL (http://www.gnu.org/licenses/gpl.txt)
10
  */
43
  require_once("wp/transposh_admin.php");
44
  require_once("wp/transposh_options.php");
45
  require_once("wp/transposh_postpublish.php");
46
+ require_once("wp/transposh_backup.php");
47
 
48
  /**
49
  * This class represents the complete plugin
118
  add_action('wp_print_scripts', array(&$this,'add_transposh_js'));
119
  // add_action('wp_head', array(&$this,'add_transposh_async'));
120
  add_action("sm_addurl",array(&$this,'add_sm_transposh_urls'));
121
+ add_action('transposh_backup_event', array(&$this,'run_backup'));
122
+
123
  register_activation_hook(__FILE__, array(&$this,'plugin_activate'));
124
  register_deactivation_hook(__FILE__,array(&$this,'plugin_deactivate'));
125
  }
703
  }
704
  }
705
  }
706
+
707
+ /**
708
+ * Runs a scheduled backup
709
+ */
710
+ function run_backup() {
711
+
712
+ $my_transposh_backup = new transposh_backup($this);
713
+ $my_transposh_backup->do_backup();
714
+ }
715
  }
716
+
717
  $my_transposh_plugin = new transposh_plugin();
718
 
719
  ?>
wp/transposh_admin.php CHANGED
@@ -85,7 +85,7 @@ class transposh_plugin_admin {
85
  //Update the list of supported/editable/sortable languages
86
 
87
  foreach($_POST['languages'] as $code => $lang) {
88
- list ($langcode, $viewable, $translateable) = explode(",",$lang);
89
  $sorted_langs[$langcode] = $langcode;
90
  if($viewable) {
91
  $viewable_langs[$langcode] = $langcode;
@@ -118,6 +118,16 @@ class transposh_plugin_admin {
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
  }
123
 
@@ -161,12 +171,33 @@ class transposh_plugin_admin {
161
  wp_enqueue_style("transposh_flags",$this->transposh->transposh_plugin_url."/css/transposh_flags.css",array(),TRANSPOSH_PLUGIN_VER);
162
  wp_enqueue_script('jquery-ui-droppable');
163
  wp_enqueue_script("transposh_control",$this->transposh->transposh_plugin_url."/js/transposhcontrol.js",array(),TRANSPOSH_PLUGIN_VER, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  //add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
166
  add_meta_box('transposh-sidebox-about', 'About this plugin', array(&$this, 'on_sidebox_about_content'), $this->pagehook, 'side', 'core');
167
  add_meta_box('transposh-sidebox-widget', 'Widget settings', array(&$this, 'on_sidebox_widget_content'), $this->pagehook, 'side', 'core');
168
  add_meta_box('transposh-sidebox-news', 'Plugin news', array(&$this, 'on_sidebox_news_content'), $this->pagehook, 'side', 'core');
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');
@@ -179,7 +210,7 @@ class transposh_plugin_admin {
179
  //global $screen_layout_columns;
180
  //add a 3rd content box now for demonstration purpose, boxes added at start of page rendering can't be switched on/off,
181
  //may be needed to ensure that a special box is always available
182
- add_meta_box('transposh-contentbox-community', 'Transposh community features (upcoming)', array(&$this, 'on_contentbox_community_content'), $this->pagehook, 'normal', 'core');
183
  //define some data can be given to each metabox during rendering - not used now
184
  //$data = array('My Data 1', 'My Data 2', 'Available Data 1');
185
  ?>
@@ -303,6 +334,13 @@ class transposh_plugin_admin {
303
  $this->transposh->database->db_stats();
304
  }
305
 
 
 
 
 
 
 
 
306
  /**
307
  * Insert supported languages section in admin page
308
  * @param string $data
@@ -358,7 +396,7 @@ class transposh_plugin_admin {
358
  echo '<ul id="default_list"><li id="'.$this->transposh->options->get_default_language().'" class="languages">'
359
  .display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $langorigname,$this->transposh->options->get_widget_css_flags())
360
  .'<input type="hidden" name="languages[]" value="'. $this->transposh->options->get_default_language() .'" />'
361
- .'&nbsp;<span class="langname">'.$langorigname.'</span><span class="langname hidden">'.$langname.'</span></li>';
362
  echo '</ul></div>';
363
  // list of languages
364
  echo '<div style="overflow:auto; clear: both;">Available Languages (Click to toggle language state - Drag to sort in the widget)';
@@ -427,7 +465,7 @@ class transposh_plugin_admin {
427
 
428
  }
429
 
430
- function on_contentbox_auto_translation_content($data) {
431
 
432
  /*
433
  * Insert the option to enable/disable automatic translation.
@@ -497,12 +535,18 @@ class transposh_plugin_admin {
497
  'This enables auto detection of language used by the user as defined in the ACCEPT_LANGUAGES they send. '.
498
  'This will redirect the first page accessed in the session to the same page with the detected language.';
499
 
500
- /* WIP2
501
  echo '<a href="http://transposh.org/services/index.php?flags='.$flags.'">Gen sprites</a>';*/
502
  }
503
 
504
  function on_contentbox_community_content($data) {
505
- echo "<p>This space is reserved for the coming community features of Transposh that will help you find translators to help with your site.</p>";
 
 
 
 
 
 
506
  }
507
  }
508
 
85
  //Update the list of supported/editable/sortable languages
86
 
87
  foreach($_POST['languages'] as $code => $lang) {
88
+ list ($langcode, $viewable, $translateable) = explode(",",$lang);
89
  $sorted_langs[$langcode] = $langcode;
90
  if($viewable) {
91
  $viewable_langs[$langcode] = $langcode;
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->set_transposh_key($_POST[TRANSPOSH_KEY]);
122
+
123
+ // handle change of schedule for backup to daily
124
+ if ($_POST[TRANSPOSH_BACKUP_SCHEDULE] != $this->transposh->options->get_transposh_backup_schedule()) {
125
+ wp_clear_scheduled_hook('transposh_backup_event');
126
+ if ($_POST[TRANSPOSH_BACKUP_SCHEDULE] == 1)
127
+ wp_schedule_event(time(), 'daily', 'transposh_backup_event');
128
+ }
129
+ $this->transposh->options->set_transposh_backup_schedule($_POST[TRANSPOSH_BACKUP_SCHEDULE]);
130
+
131
  $this->transposh->options->update_options();
132
  }
133
 
171
  wp_enqueue_style("transposh_flags",$this->transposh->transposh_plugin_url."/css/transposh_flags.css",array(),TRANSPOSH_PLUGIN_VER);
172
  wp_enqueue_script('jquery-ui-droppable');
173
  wp_enqueue_script("transposh_control",$this->transposh->transposh_plugin_url."/js/transposhcontrol.js",array(),TRANSPOSH_PLUGIN_VER, true);
174
+ wp_localize_script("transposh_control","t_jp",array(
175
+ 'post_url' => $this->transposh->post_url/*,
176
+ 'plugin_url' => $this->transposh_plugin_url,
177
+ 'edit' => ($this->edit_mode? '1' : ''),
178
+ //'rtl' => (in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : ''),
179
+ 'lang' => $this->target_language,
180
+ // those two options show if the script can support said engines
181
+ 'msn' => (in_array($this->target_language,$GLOBALS['bing_languages']) && $this->options->get_msn_key() ? '1' : ''),
182
+ 'google' => (in_array($this->target_language,$GLOBALS['google_languages']) ? '1' : ''),
183
+ 'prefix' => SPAN_PREFIX,
184
+ 'msnkey'=>$this->options->get_msn_key(),
185
+ 'preferred'=> $this->options->get_preferred_translator(),
186
+ 'progress'=>$this->edit_mode || $this->options->get_widget_progressbar() ? '1' : '')*/
187
+ // 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
188
+ ));
189
+ wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1',true);
190
+ wp_enqueue_script("transposh_admin",$this->transposh->transposh_plugin_url."/js/transposhadmin.js",array(),TRANSPOSH_PLUGIN_VER, true);
191
+ wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",array(),'1.0');
192
+ wp_enqueue_script("jqueryui","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",array("jquery"),'1.7.2',true);
193
+
194
 
195
  //add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
196
  add_meta_box('transposh-sidebox-about', 'About this plugin', array(&$this, 'on_sidebox_about_content'), $this->pagehook, 'side', 'core');
197
  add_meta_box('transposh-sidebox-widget', 'Widget settings', array(&$this, 'on_sidebox_widget_content'), $this->pagehook, 'side', 'core');
198
  add_meta_box('transposh-sidebox-news', 'Plugin news', array(&$this, 'on_sidebox_news_content'), $this->pagehook, 'side', 'core');
199
  add_meta_box('transposh-sidebox-stats', 'Plugin stats', array(&$this, 'on_sidebox_stats_content'), $this->pagehook, 'side', 'core');
200
+ add_meta_box('transposh-sidebox-translate', 'Translate all', array(&$this, 'on_sidebox_translate_content'), $this->pagehook, 'side', 'core');
201
  add_meta_box('transposh-contentbox-languages', 'Supported languages', array(&$this, 'on_contentbox_languages_content'), $this->pagehook, 'normal', 'core');
202
  add_meta_box('transposh-contentbox-translation', 'Translation settings', array(&$this, 'on_contentbox_translation_content'), $this->pagehook, 'normal', 'core');
203
  add_meta_box('transposh-contentbox-autotranslation', 'Automatic translation settings', array(&$this, 'on_contentbox_auto_translation_content'), $this->pagehook, 'normal', 'core');
210
  //global $screen_layout_columns;
211
  //add a 3rd content box now for demonstration purpose, boxes added at start of page rendering can't be switched on/off,
212
  //may be needed to ensure that a special box is always available
213
+ add_meta_box('transposh-contentbox-community', 'Transposh community features', array(&$this, 'on_contentbox_community_content'), $this->pagehook, 'normal', 'core');
214
  //define some data can be given to each metabox during rendering - not used now
215
  //$data = array('My Data 1', 'My Data 2', 'Available Data 1');
216
  ?>
334
  $this->transposh->database->db_stats();
335
  }
336
 
337
+ function on_sidebox_translate_content($data) {
338
+ echo '<div id="progress_bar_all"></div><div id="tr_translate_title"></div>';
339
+ echo '<div id="tr_loading" style="margin: 0 0 10px 0">Translate by clicking the button below</div>';
340
+ echo '<a id="transposh-translate" href="'.$this->transposh->post_url.'?translate_all&offset=1" onclick="return false;" class="button">Translate All Now</a><br/>';
341
+ //get_posts
342
+ }
343
+
344
  /**
345
  * Insert supported languages section in admin page
346
  * @param string $data
396
  echo '<ul id="default_list"><li id="'.$this->transposh->options->get_default_language().'" class="languages">'
397
  .display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $langorigname,$this->transposh->options->get_widget_css_flags())
398
  .'<input type="hidden" name="languages[]" value="'. $this->transposh->options->get_default_language() .'" />'
399
+ .'&nbsp;<span class="langname">'.$langorigname.'</span><span class="langname hidden">'.$langname.'</span></li>';
400
  echo '</ul></div>';
401
  // list of languages
402
  echo '<div style="overflow:auto; clear: both;">Available Languages (Click to toggle language state - Drag to sort in the widget)';
465
 
466
  }
467
 
468
+ function on_contentbox_auto_translation_content($data) {
469
 
470
  /*
471
  * Insert the option to enable/disable automatic translation.
535
  'This enables auto detection of language used by the user as defined in the ACCEPT_LANGUAGES they send. '.
536
  'This will redirect the first page accessed in the session to the same page with the detected language.';
537
 
538
+ /* WIP2
539
  echo '<a href="http://transposh.org/services/index.php?flags='.$flags.'">Gen sprites</a>';*/
540
  }
541
 
542
  function on_contentbox_community_content($data) {
543
+ echo '<h4>Backup service for human translation</h4>';
544
+ echo '<input type="radio" value="1" name="'.TRANSPOSH_BACKUP_SCHEDULE.'" '. $this->checked($this->transposh->options->get_transposh_backup_schedule() == 1) . '/>Enable daily backup<br/>';
545
+ echo '<input type="radio" value="2" name="'.TRANSPOSH_BACKUP_SCHEDULE.'" '. $this->checked($this->transposh->options->get_transposh_backup_schedule() == 2) . '/>Enable live backup<br/>';
546
+ echo '<input type="radio" value="0" name="'.TRANSPOSH_BACKUP_SCHEDULE.'" '. $this->checked($this->transposh->options->get_transposh_backup_schedule() == 0) . '/>Disable backup (Can be run manually by clicking the button below)<br/>';
547
+ echo 'Service Key: <input type="text" size="32" class="regular-text" value="'.$this->transposh->options->get_transposh_key().'" id="'.TRANSPOSH_KEY.'" name="'.TRANSPOSH_KEY.'"/> <a target="_blank" href="http://transposh.org/faq/#restore">How to restore?</a><br/>';
548
+ echo '<div id="backup_result"></div>';
549
+ echo '<div style="margin:10px 0"><a id="transposh-backup" href="#" class="button">Do Backup Now</a></div>';
550
  }
551
  }
552
 
wp/transposh_ajax.php CHANGED
@@ -80,4 +80,17 @@ elseif (isset($_GET['tr_cookie_bck'])) {
80
  wp_redirect($my_transposh_plugin->home_url);
81
  }
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  ?>
80
  wp_redirect($my_transposh_plugin->home_url);
81
  }
82
  }
83
+ // Start full translation
84
+ elseif (isset($_GET['translate_all'])) {
85
+ // get all ids in need of translation
86
+ $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type='page' OR post_type='post' ORDER BY ID DESC");
87
+ // only high capabilities users can...
88
+ if (!current_user_can('edit_post',$page_ids[0])) return;
89
+ echo json_encode($page_ids);
90
+ }
91
+ // Start backup on demand
92
+ elseif (isset($_GET['backup'])) {
93
+ $my_transposh_plugin->run_backup();
94
+ }
95
+
96
  ?>
wp/transposh_backup.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Copyright © 2009-2010 Transposh Team (website : http://transposh.org)
3
+ *
4
+ * This program is free software; you can redistribute it and/or modify
5
+ * it under the terms of the GNU General Public License as published by
6
+ * the Free Software Foundation; either version 2 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+ *
18
+ * adapted metabox sample code from http://www.code-styling.de/
19
+ */
20
+
21
+ /*
22
+ * Provide the backup service class
23
+ */
24
+
25
+ define ("TRANSPOSH_BACKUP_SERVICE_URL" , "http://svc.transposh.org/backup");
26
+ //define ("TRANSPOSH_BACKUP_SERVICE_URL" , "http://ofergen:8888/backup");
27
+ //class that reperesent the admin page
28
+ class transposh_backup {
29
+ /** @var transposh_plugin $transposh father class */
30
+ private $transposh;
31
+ //constructor of class, PHP4 compatible construction for backward compatibility
32
+ function transposh_backup(&$transposh) {
33
+ $this->transposh = &$transposh;
34
+ }
35
+
36
+ function do_backup() {
37
+ $body = array();
38
+ $body["home_url"] = $this->transposh->home_url;
39
+ $body["key"] = $this->transposh->options->get_transposh_key();
40
+ $result = wp_remote_post(TRANSPOSH_BACKUP_SERVICE_URL, array('body' => $body));
41
+ if (is_wp_error($result)) {
42
+ echo "500 - ".$result->get_error_message();
43
+ return;
44
+ }
45
+ if ($result['headers']['fail']) {
46
+ echo "500 - ".$result['headers']['fail'];
47
+ return;
48
+ }
49
+ if ($this->transposh->options->get_transposh_key() == "") {
50
+ $this->transposh->options->set_transposh_key($result['headers']['transposh-key']);
51
+ // TODO: deliever new gottenkey to client side?
52
+ //echo $this->transposh->options->get_transposh_key();
53
+ $this->transposh->options->update_options();
54
+ }
55
+ if ($result['headers']['lastitem']) {
56
+ $rowstosend = $this->transposh->database->get_all_human_translation_history($result['headers']['lastitem'], 500);
57
+ while ($rowstosend) {
58
+ $item = 0;
59
+ foreach ($rowstosend as $row) {
60
+ if ($body["or".($item-1)] != $row->original)
61
+ $body["or".$item] = $row->original;
62
+ if ($body["ln".($item-1)] != $row->lang)
63
+ $body["ln".$item] = $row->lang;
64
+ if ($body["tr".($item-1)] != $row->translated)
65
+ $body["tr".$item] = $row->translated;
66
+ if ($body["tb".($item-1)] != $row->translated_by)
67
+ $body["tb".$item] = $row->translated_by;
68
+ if ($body["ts".($item-1)] != $row->timestamp)
69
+ $body["ts".$item] = $row->timestamp;
70
+ $item++;
71
+ }
72
+ $body["items"] = $item;
73
+ if ($item == 0) return; // no need to post 0 items
74
+ $result = wp_remote_post(TRANSPOSH_BACKUP_SERVICE_URL, array('body' => $body));
75
+ if (is_wp_error($result)) {
76
+ echo "500 - ".$result->get_error_message();
77
+ return;
78
+ }
79
+ if ($result['headers']['fail']) {
80
+ echo "500 - ".$result['headers']['fail'];
81
+ return;
82
+ }
83
+ $rowstosend = $this->transposh->database->get_all_human_translation_history($row->timestamp, 500);
84
+ }
85
+ }
86
+ Echo "200 - backup in sync";
87
+ }
88
+ }
wp/transposh_db.php CHANGED
@@ -171,12 +171,13 @@ class transposh_database {
171
  if (isset($_POST["sr$i"])) {
172
  $source = $_POST["sr$i"];
173
  }
174
-
 
175
 
176
  //Here we check we are not redoing stuff
177
  list($translated_text, $old_source) = $this->fetch_translation($original, $lang);
178
  if ($translated_text) {
179
- if ($source == 1) {
180
 
181
  continue;
182
  //return; // too harsh, we just need to get to the next in for
@@ -220,6 +221,11 @@ class transposh_database {
220
 
221
  header("HTTP/1.0 404 Failed to update language database ".mysql_error());
222
  }
 
 
 
 
 
223
  // this is a termination for the ajax sequence
224
  exit;
225
  }
171
  if (isset($_POST["sr$i"])) {
172
  $source = $_POST["sr$i"];
173
  }
174
+ // should we backup?
175
+ if ($source ==0) $backup_immidiate_possible = true;
176
 
177
  //Here we check we are not redoing stuff
178
  list($translated_text, $old_source) = $this->fetch_translation($original, $lang);
179
  if ($translated_text) {
180
+ if ($source > 0) {
181
 
182
  continue;
183
  //return; // too harsh, we just need to get to the next in for
221
 
222
  header("HTTP/1.0 404 Failed to update language database ".mysql_error());
223
  }
224
+
225
+ // Should we backup now?
226
+ if ($backup_immidiate_possible && $this->transposh->options->get_transposh_backup_schedule() == 2) {
227
+ $this->transposh->run_backup();
228
+ }
229
  // this is a termination for the ajax sequence
230
  exit;
231
  }
wp/transposh_options.php CHANGED
@@ -84,6 +84,10 @@ define("WIDGET_CSS_FLAGS", "widget_css_flags");
84
  define("WIDGET_IN_LIST", "widget_in_list");
85
  //Allows user to set his default language per #63 @since 0.3.8
86
  define("WIDGET_ALLOW_SET_DEFLANG", "widget_allow_set_deflang");
 
 
 
 
87
 
88
 
89
  class transposh_plugin_options {
@@ -247,6 +251,14 @@ class transposh_plugin_options {
247
  return $default;
248
  }
249
 
 
 
 
 
 
 
 
 
250
  /**
251
  * Sets a value at the options array
252
  * @param mixed $val
@@ -360,6 +372,14 @@ class transposh_plugin_options {
360
  $this->set_value($val, $this->options[DEFAULT_LANG]);
361
  }
362
 
 
 
 
 
 
 
 
 
363
  /**
364
  * Updates options at the wordpress options table if there was a change
365
  */
84
  define("WIDGET_IN_LIST", "widget_in_list");
85
  //Allows user to set his default language per #63 @since 0.3.8
86
  define("WIDGET_ALLOW_SET_DEFLANG", "widget_allow_set_deflang");
87
+ //Stores the site key to transposh services (backup @since 0.5.0)
88
+ define("TRANSPOSH_KEY","transposh_key");
89
+ //Stores the site key to transposh services (backup @since 0.5.0)
90
+ define("TRANSPOSH_BACKUP_SCHEDULE","transposh_backup_schedule");
91
 
92
 
93
  class transposh_plugin_options {
251
  return $default;
252
  }
253
 
254
+ function get_transposh_key() {
255
+ return $this->options[TRANSPOSH_KEY];
256
+ }
257
+
258
+ function get_transposh_backup_schedule() {
259
+ return $this->options[TRANSPOSH_BACKUP_SCHEDULE];
260
+ }
261
+
262
  /**
263
  * Sets a value at the options array
264
  * @param mixed $val
372
  $this->set_value($val, $this->options[DEFAULT_LANG]);
373
  }
374
 
375
+ function set_transposh_key($val) {
376
+ $this->set_value($val, $this->options[TRANSPOSH_KEY]);
377
+ }
378
+
379
+ function set_transposh_backup_schedule($val) {
380
+ $this->set_value($val, $this->options[TRANSPOSH_BACKUP_SCHEDULE]);
381
+ }
382
+
383
  /**
384
  * Updates options at the wordpress options table if there was a change
385
  */
wp/transposh_postpublish.php CHANGED
@@ -15,11 +15,11 @@
15
  * along with this program; if not, write to the Free Software
16
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
  *
18
- */
19
 
20
  /*
21
  * Provides the side widget in the page/edit pages which will do translations
22
- */
23
 
24
  /**
25
  * class that makes changed to the edit page and post page, adding our change to the side ba
@@ -39,7 +39,7 @@ class transposh_postpublish {
39
  // we'll only do something if so configured to do
40
  if ($this->transposh->options->get_enable_auto_post_translate()) {
41
  add_action('edit_post',array(&$this, 'on_edit'));
42
- // add_action('publish_post',array(&$this, 'on_publish'));
43
  add_action('admin_menu', array(&$this, 'on_admin_menu'));
44
  }
45
  }
@@ -54,9 +54,29 @@ class transposh_postpublish {
54
  add_meta_box( 'transposh_postpublish','Transposh', array(&$this, "transposh_postpublish_box"), 'page', 'side', 'core');
55
  if ($_GET['justedited']) {
56
  wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1',true);
57
- wp_enqueue_script("transposh","{$this->transposh->transposh_plugin_url}/js/transposhadmin.js?post_url={$this->transposh->post_url}&post={$_GET['post']}",array("jquery"),TRANSPOSH_PLUGIN_VER,true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",array(),'1.0');
59
  wp_enqueue_script("jqueryui","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",array("jquery"),'1.7.2',true);
 
 
 
60
  }
61
  }
62
 
@@ -74,8 +94,9 @@ class transposh_postpublish {
74
  $content = apply_filters('the_content', $post->post_content);
75
  // TODO - grab phrases from rss excerpt
76
  //$output = get_the_excerpt();
77
- // echo apply_filters('the_excerpt_rss', $output);
78
-
 
79
  $parser = new parser();
80
  $phrases = $parser->get_phrases_list($content);
81
  $phrases2 = $parser->get_phrases_list($title);
@@ -105,6 +126,10 @@ class transposh_postpublish {
105
  }
106
  }
107
 
 
 
 
 
108
  // the header helps with debugging
109
  header("Content-type: text/javascript");
110
  echo json_encode($json);
15
  * along with this program; if not, write to the Free Software
16
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
  *
18
+ */
19
 
20
  /*
21
  * Provides the side widget in the page/edit pages which will do translations
22
+ */
23
 
24
  /**
25
  * class that makes changed to the edit page and post page, adding our change to the side ba
39
  // we'll only do something if so configured to do
40
  if ($this->transposh->options->get_enable_auto_post_translate()) {
41
  add_action('edit_post',array(&$this, 'on_edit'));
42
+ // add_action('publish_post',array(&$this, 'on_publish'));
43
  add_action('admin_menu', array(&$this, 'on_admin_menu'));
44
  }
45
  }
54
  add_meta_box( 'transposh_postpublish','Transposh', array(&$this, "transposh_postpublish_box"), 'page', 'side', 'core');
55
  if ($_GET['justedited']) {
56
  wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1',true);
57
+ wp_enqueue_script("transposh","{$this->transposh->transposh_plugin_url}/js/transposhadmin.js",array("jquery"),TRANSPOSH_PLUGIN_VER,true);
58
+ wp_localize_script("transposh","t_jp",array(
59
+ 'post_url' => $this->transposh->post_url,
60
+ 'post' => $_GET['post'],
61
+ 'msnkey'=>$this->transposh->options->get_msn_key(),
62
+ 'msn_langs' => json_encode($GLOBALS['bing_languages']),
63
+ 'google_lang' => json_encode($GLOBALS['google_languages']),
64
+ 'preferred'=> $this->transposh->options->get_preferred_translator()/*,
65
+ 'plugin_url' => $this->transposh_plugin_url,
66
+ 'edit' => ($this->edit_mode? '1' : ''),
67
+ //'rtl' => (in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : ''),
68
+ 'lang' => $this->target_language,
69
+ // those two options show if the script can support said engines
70
+ 'prefix' => SPAN_PREFIX,
71
+
72
+ 'progress'=>$this->edit_mode || $this->options->get_widget_progressbar() ? '1' : '')*/
73
+ // 'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
74
+ ));
75
  wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css",array(),'1.0');
76
  wp_enqueue_script("jqueryui","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js",array("jquery"),'1.7.2',true);
77
+ /* if ($this->transposh->options->get_enable_msn_translate() && $this->transposh->options->get_msn_key()) {
78
+ wp_enqueue_script("mstranslate","http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId=".$this->transposh->options->get_msn_key(),array(),'1',true);
79
+ }*/
80
  }
81
  }
82
 
94
  $content = apply_filters('the_content', $post->post_content);
95
  // TODO - grab phrases from rss excerpt
96
  //$output = get_the_excerpt();
97
+ // echo apply_filters('the_excerpt_rss', $output);
98
+ //TODO - get comments text
99
+
100
  $parser = new parser();
101
  $phrases = $parser->get_phrases_list($content);
102
  $phrases2 = $parser->get_phrases_list($title);
126
  }
127
  }
128
 
129
+ // add the title
130
+ // if ($json['length'])
131
+ $json['posttitle'] = $title;
132
+
133
  // the header helps with debugging
134
  header("Content-type: text/javascript");
135
  echo json_encode($json);