Version Description
Download this release
Release Info
Developer | oferwald |
Plugin | Transposh WordPress Translation |
Version | 0.2.1 |
Comparing to | |
See all releases |
Code changes from version 0.2.0 to 0.2.1
- core/parser.php +8 -2
- core/shd/simple_html_dom.php +4 -4
- readme.txt +7 -1
- transposh.php +3 -3
- transposh_db.php +2 -2
- transposh_widget.php +44 -4
core/parser.php
CHANGED
@@ -33,6 +33,7 @@ class parser {
|
|
33 |
private $inbody = false;
|
34 |
public $is_edit_mode;
|
35 |
public $is_auto_translate;
|
|
|
36 |
|
37 |
/**
|
38 |
* Determine if the current position in buffer is a white space.
|
@@ -102,7 +103,7 @@ class parser {
|
|
102 |
function is_sentence_breaker($char, $nextchar)
|
103 |
{
|
104 |
if (($char == '.' || $char == '-') && ($this->is_white_space($nextchar))) return true;
|
105 |
-
return (strpos(',?()[]"
|
106 |
}
|
107 |
|
108 |
/**
|
@@ -128,6 +129,7 @@ class parser {
|
|
128 |
$this->currentnode->nodes[] = $node;
|
129 |
$node->_[HDOM_INFO_OUTER] = '';
|
130 |
$node->phrase = $phrase;
|
|
|
131 |
$node->inbody = $this->inbody;
|
132 |
}
|
133 |
}
|
@@ -192,8 +194,12 @@ class parser {
|
|
192 |
$this->currentnode = $node;
|
193 |
// we don't want to translate non-translatable classes
|
194 |
if (stripos($node->class,NO_TRANSLATE_CLASS) !== false) return;
|
195 |
-
if ($
|
196 |
elseif ($node->tag == 'text') {
|
|
|
|
|
|
|
|
|
197 |
if (trim($node->outertext)) {
|
198 |
$this->parsetext($node->outertext);
|
199 |
};
|
33 |
private $inbody = false;
|
34 |
public $is_edit_mode;
|
35 |
public $is_auto_translate;
|
36 |
+
protected $ignore_tags = array('script'=>1, 'style'=>1, 'code'=>1);
|
37 |
|
38 |
/**
|
39 |
* Determine if the current position in buffer is a white space.
|
103 |
function is_sentence_breaker($char, $nextchar)
|
104 |
{
|
105 |
if (($char == '.' || $char == '-') && ($this->is_white_space($nextchar))) return true;
|
106 |
+
return (strpos(',?()[]"!:|;∙',$char) !== false) ? true : false;
|
107 |
}
|
108 |
|
109 |
/**
|
129 |
$this->currentnode->nodes[] = $node;
|
130 |
$node->_[HDOM_INFO_OUTER] = '';
|
131 |
$node->phrase = $phrase;
|
132 |
+
if ($this->inbody)
|
133 |
$node->inbody = $this->inbody;
|
134 |
}
|
135 |
}
|
194 |
$this->currentnode = $node;
|
195 |
// we don't want to translate non-translatable classes
|
196 |
if (stripos($node->class,NO_TRANSLATE_CLASS) !== false) return;
|
197 |
+
if (isset($this->ignore_tags[$node->tag])) return;
|
198 |
elseif ($node->tag == 'text') {
|
199 |
+
// this prevents translation of a link that just surrounds its address
|
200 |
+
if ($node->parent->tag == 'a' && $node->parent->href == $node->outertext) {
|
201 |
+
return;
|
202 |
+
}
|
203 |
if (trim($node->outertext)) {
|
204 |
$this->parsetext($node->outertext);
|
205 |
};
|
core/shd/simple_html_dom.php
CHANGED
@@ -530,12 +530,12 @@ class simple_html_dom {
|
|
530 |
$this->remove_noise("'<!--(.*?)-->'is");
|
531 |
// strip out cdata
|
532 |
$this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
|
533 |
-
// strip out <style> tags
|
534 |
-
$this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
|
535 |
-
$this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
|
536 |
// strip out <script> tags
|
537 |
$this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
|
538 |
$this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
|
|
|
|
|
|
|
539 |
// strip out preformatted tags
|
540 |
$this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
|
541 |
// strip out server side scripts
|
@@ -634,7 +634,7 @@ class simple_html_dom {
|
|
634 |
// end tag
|
635 |
if ($this->char==='/') {
|
636 |
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
637 |
-
$this->skip($this->
|
638 |
$tag = $this->copy_until_char('>');
|
639 |
|
640 |
// skip attributes in end tag
|
530 |
$this->remove_noise("'<!--(.*?)-->'is");
|
531 |
// strip out cdata
|
532 |
$this->remove_noise("'<!\[CDATA\[(.*?)\]\]>'is", true);
|
|
|
|
|
|
|
533 |
// strip out <script> tags
|
534 |
$this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
|
535 |
$this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
|
536 |
+
// strip out <style> tags
|
537 |
+
$this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
|
538 |
+
$this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
|
539 |
// strip out preformatted tags
|
540 |
$this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
|
541 |
// strip out server side scripts
|
634 |
// end tag
|
635 |
if ($this->char==='/') {
|
636 |
$this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
|
637 |
+
$this->skip($this->token_blank);
|
638 |
$tag = $this->copy_until_char('>');
|
639 |
|
640 |
// skip attributes in end tag
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://transposh.org/
|
|
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.7.1
|
7 |
-
Stable tag: 0.2.
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
@@ -97,6 +97,12 @@ Just add the following line to your template:
|
|
97 |
5. Widget style selection
|
98 |
|
99 |
== Release notes ==
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
* 2009/05/18 - 0.2.0
|
101 |
* Faster parser - 50% faster parsing than previous engine (thanks [Simple Html DOM](http://simplehtmldom.sourceforge.net/))
|
102 |
* Hidden elements translation (mainly tooltips specified by title attribute)
|
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.7.1
|
7 |
+
Stable tag: 0.2.1
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
97 |
5. Widget style selection
|
98 |
|
99 |
== Release notes ==
|
100 |
+
* 2009/05/21 - 0.2.1
|
101 |
+
* Fixed unique breaking case in parser (style used within script and not properly terminated) (thanks again Fernanda)
|
102 |
+
* Added language list mode to widget
|
103 |
+
* Prevent translation of url that is self wrapped
|
104 |
+
* Added <code> tag to list of ignored tags (thanks again [Mike](http://www.nostate.com/))
|
105 |
+
* Middle dot is now a seperator
|
106 |
* 2009/05/18 - 0.2.0
|
107 |
* Faster parser - 50% faster parsing than previous engine (thanks [Simple Html DOM](http://simplehtmldom.sourceforge.net/))
|
108 |
* Hidden elements translation (mainly tooltips specified by title attribute)
|
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.2.
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
@@ -357,7 +357,7 @@ function add_transposh_css() {
|
|
357 |
return;
|
358 |
}
|
359 |
//include the transposh.css
|
360 |
-
wp_enqueue_style("transposh","$tr_plugin_url/css/transposh.css",array(),'0.2.
|
361 |
wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/ui-lightness/jquery-ui.css",array(),'1.0');
|
362 |
|
363 |
}
|
@@ -401,7 +401,7 @@ function add_transposh_js() {
|
|
401 |
wp_deregister_script('jquery');
|
402 |
wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');
|
403 |
wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1');
|
404 |
-
wp_enqueue_script("transposh","$tr_plugin_url/js/transposh.js?post_url=$post_url{$edit_mode}&lang={$lang}&prefix=".SPAN_PREFIX,array("jquery"),'0.2.
|
405 |
}
|
406 |
}
|
407 |
|
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.2.1
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
357 |
return;
|
358 |
}
|
359 |
//include the transposh.css
|
360 |
+
wp_enqueue_style("transposh","$tr_plugin_url/css/transposh.css",array(),'0.2.1');
|
361 |
wp_enqueue_style("jquery","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/ui-lightness/jquery-ui.css",array(),'1.0');
|
362 |
|
363 |
}
|
401 |
wp_deregister_script('jquery');
|
402 |
wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');
|
403 |
wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1');
|
404 |
+
wp_enqueue_script("transposh","$tr_plugin_url/js/transposh.js?post_url=$post_url{$edit_mode}&lang={$lang}&prefix=".SPAN_PREFIX,array("jquery"),'0.2.1');
|
405 |
}
|
406 |
}
|
407 |
|
transposh_db.php
CHANGED
@@ -139,7 +139,7 @@ function update_translation()
|
|
139 |
$original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
|
140 |
|
141 |
//add our own custom header - so we will know that we got here
|
142 |
-
header("Transposh: ver-0.2.
|
143 |
|
144 |
list($translated_text, $old_source) = fetch_translation($original, $lang);
|
145 |
if ($translated_text) {
|
@@ -243,7 +243,7 @@ function get_translation_history($token, $lang)
|
|
243 |
$original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
|
244 |
|
245 |
//add our own custom header - so we will know that we got here
|
246 |
-
header("Transposh: ver-0.2.
|
247 |
|
248 |
$query = "SELECT translated, translated_by, timestamp, source, user_login ".
|
249 |
"FROM $table_name ".
|
139 |
$original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
|
140 |
|
141 |
//add our own custom header - so we will know that we got here
|
142 |
+
header("Transposh: ver-0.2.1 db_version-". DB_VERSION);
|
143 |
|
144 |
list($translated_text, $old_source) = fetch_translation($original, $lang);
|
145 |
if ($translated_text) {
|
243 |
$original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));
|
244 |
|
245 |
//add our own custom header - so we will know that we got here
|
246 |
+
header("Transposh: ver-0.2.1 db_version-". DB_VERSION);
|
247 |
|
248 |
$query = "SELECT translated, translated_by, timestamp, source, user_login ".
|
249 |
"FROM $table_name ".
|
transposh_widget.php
CHANGED
@@ -85,7 +85,7 @@ function add_transposh_widget_css() {
|
|
85 |
global $tr_plugin_url;
|
86 |
|
87 |
//include the transposh_widget.css
|
88 |
-
wp_enqueue_style("transposh_widget","$tr_plugin_url/css/transposh_widget.css",array(),'0.2.
|
89 |
|
90 |
}
|
91 |
|
@@ -157,7 +157,46 @@ function transposh_widget($args)
|
|
157 |
echo "<form action=\"$page_url\" method=\"post\">";
|
158 |
echo "<input type=\"hidden\" name=\"lang\" id=\"lang\" value=\"$lang\"/>";
|
159 |
break;
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
echo "<form action=\"$page_url\" method=\"post\">";
|
163 |
echo "<span class=\"" .NO_TRANSLATE_CLASS . "\" >";
|
@@ -204,7 +243,7 @@ function transposh_widget($args)
|
|
204 |
|
205 |
echo "</form>";
|
206 |
//echo "<button onClick=\"do_auto_translate();\">translate all</button>";
|
207 |
-
echo "<div id=\"".SPAN_PREFIX."credit\">by <a href=\"http://transposh.org\"><img class
|
208 |
echo $after_widget;
|
209 |
}
|
210 |
|
@@ -269,8 +308,9 @@ function transposh_widget_control()
|
|
269 |
|
270 |
echo '<p><label for="transposh-style">Style:<br />'.
|
271 |
'<select id="transposh-style" name="transposh-style">'.
|
272 |
-
'<option value="0"' . ($options['style'] == 0 ? ' selected="selected"' : '').'>Language
|
273 |
'<option value="1"' . ($options['style'] == 1 ? ' selected="selected"' : '').'>Flags</option>'.
|
|
|
274 |
'</select>'.
|
275 |
'</label></p>'.
|
276 |
'<p><label for="transposh-progress">Effects:<br/>'.
|
85 |
global $tr_plugin_url;
|
86 |
|
87 |
//include the transposh_widget.css
|
88 |
+
wp_enqueue_style("transposh_widget","$tr_plugin_url/css/transposh_widget.css",array(),'0.2.1');
|
89 |
|
90 |
}
|
91 |
|
157 |
echo "<form action=\"$page_url\" method=\"post\">";
|
158 |
echo "<input type=\"hidden\" name=\"lang\" id=\"lang\" value=\"$lang\"/>";
|
159 |
break;
|
160 |
+
case 2: // language list
|
161 |
+
//keep the flags in the same direction regardless of the overall page direction
|
162 |
+
echo "<div class=\"" . NO_TRANSLATE_CLASS . " transposh_flags\" >";
|
163 |
+
|
164 |
+
foreach($languages as $code => $lang2)
|
165 |
+
{
|
166 |
+
list($language,$flag) = explode (",",$lang2);
|
167 |
+
|
168 |
+
//remove any language identifier
|
169 |
+
$page_url = cleanup_url($page_url);
|
170 |
+
|
171 |
+
//Only show languages which are viewable or (editable and the user is a translator)
|
172 |
+
if(strpos($viewable_langs, $code) !== FALSE ||
|
173 |
+
($is_translator && strpos($editable_langs, $code) !== FALSE) ||
|
174 |
+
(get_option(DEFAULT_LANG) == $code && $lang))
|
175 |
+
{
|
176 |
+
$page_url2 = rewrite_url_lang_param($page_url, $code, $is_edit);
|
177 |
+
if (get_option(DEFAULT_LANG) == $code) {
|
178 |
+
$page_url2 = $page_url;
|
179 |
+
}
|
180 |
+
//TODO: improve this hacky! shortening
|
181 |
+
$urlpath = parse_url($page_url2, PHP_URL_PATH);
|
182 |
+
if (trim(parse_url($page_url2, PHP_URL_QUERY)) != '')
|
183 |
+
$urlpath .= '?'.parse_url($page_url2, PHP_URL_QUERY);
|
184 |
+
if (trim(parse_url($page_url2, PHP_URL_FRAGMENT)) != '')
|
185 |
+
$urlpath .= '#'.parse_url($page_url2, PHP_URL_FRAGMENT);
|
186 |
+
|
187 |
+
echo "<a href=\"" . $urlpath . "\">".
|
188 |
+
"<img src=\"$plugpath/img/flags/$flag.png\" title=\"$language\" alt=\"$language\"".
|
189 |
+
" style=\"padding: 1px 3px;border: 0px\"/></a>$language<br/>";
|
190 |
+
$is_showing_languages = TRUE;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
echo "</div>";
|
194 |
+
|
195 |
+
// this is the form for the edit...
|
196 |
+
echo "<form action=\"$page_url\" method=\"post\">";
|
197 |
+
echo "<input type=\"hidden\" name=\"lang\" id=\"lang\" value=\"$lang\"/>";
|
198 |
+
break;
|
199 |
+
default: // language selection
|
200 |
|
201 |
echo "<form action=\"$page_url\" method=\"post\">";
|
202 |
echo "<span class=\"" .NO_TRANSLATE_CLASS . "\" >";
|
243 |
|
244 |
echo "</form>";
|
245 |
//echo "<button onClick=\"do_auto_translate();\">translate all</button>";
|
246 |
+
echo "<div id=\"".SPAN_PREFIX."credit\">by <a href=\"http://transposh.org\"><img class=\"".NO_TRANSLATE_CLASS."\" src=\"$plugpath/img/tplogo.png\" style=\"padding:1px;border:0px\" title=\"Transposh\" alt=\"Transposh\"/></a></div>";
|
247 |
echo $after_widget;
|
248 |
}
|
249 |
|
308 |
|
309 |
echo '<p><label for="transposh-style">Style:<br />'.
|
310 |
'<select id="transposh-style" name="transposh-style">'.
|
311 |
+
'<option value="0"' . ($options['style'] == 0 ? ' selected="selected"' : '').'>Language selection</option>'.
|
312 |
'<option value="1"' . ($options['style'] == 1 ? ' selected="selected"' : '').'>Flags</option>'.
|
313 |
+
'<option value="2"' . ($options['style'] == 2 ? ' selected="selected"' : '').'>Language list</option>'.
|
314 |
'</select>'.
|
315 |
'</label></p>'.
|
316 |
'<p><label for="transposh-progress">Effects:<br/>'.
|