Version Description
Improved lang attribute support, changed default language translation option
Download this release
Release Info
Developer | oferwald |
Plugin | Transposh WordPress Translation |
Version | 0.5.2 |
Comparing to | |
See all releases |
Code changes from version 0.5.1 to 0.5.2
- core/constants.php +3 -1
- core/parser.php +42 -11
- index.php +18 -0
- readme.txt +11 -4
- transposh.php +2 -1
core/constants.php
CHANGED
@@ -27,6 +27,8 @@ define("ENABLE_APC", TRUE);
|
|
27 |
|
28 |
//Class marking a section not be translated.
|
29 |
define("NO_TRANSLATE_CLASS", "no_translate");
|
|
|
|
|
30 |
|
31 |
//Supported languages, new languages can be added here
|
32 |
//the array directs from language code to - English Name, Native name, flag
|
@@ -97,7 +99,7 @@ $bing_languages = array("en", "ar", "bg", "zh", "zh-tw", "cs", "da", "nl", "ht",
|
|
97 |
//Define the new capability that will be assigned to roles - translator
|
98 |
define("TRANSLATOR", 'translator');
|
99 |
|
100 |
-
define("TRANSPOSH_PLUGIN_VER",'0.5.
|
101 |
|
102 |
//Define segment id prefix, will be included in span tag. also used as class identifier
|
103 |
define("SPAN_PREFIX", "tr_");
|
27 |
|
28 |
//Class marking a section not be translated.
|
29 |
define("NO_TRANSLATE_CLASS", "no_translate");
|
30 |
+
define("NO_TRANSLATE_CLASS_GOOGLE", "notranslate");
|
31 |
+
define("ONLY_THISLANGUAGE_CLASS", "only_thislanguage");
|
32 |
|
33 |
//Supported languages, new languages can be added here
|
34 |
//the array directs from language code to - English Name, Native name, flag
|
99 |
//Define the new capability that will be assigned to roles - translator
|
100 |
define("TRANSLATOR", 'translator');
|
101 |
|
102 |
+
define("TRANSPOSH_PLUGIN_VER",'0.5.2');
|
103 |
|
104 |
//Define segment id prefix, will be included in span tag. also used as class identifier
|
105 |
define("SPAN_PREFIX", "tr_");
|
core/parser.php
CHANGED
@@ -96,9 +96,14 @@ class parser {
|
|
96 |
/** @var simple_html_dom Contains the document dom model */
|
97 |
private $html; // the document
|
98 |
public $dir_rtl;
|
|
|
99 |
public $lang;
|
|
|
|
|
100 |
private $inbody = false;
|
101 |
-
private $inselect;
|
|
|
|
|
102 |
public $is_edit_mode;
|
103 |
public $is_auto_translate;
|
104 |
public $feed_fix;
|
@@ -366,12 +371,45 @@ class parser {
|
|
366 |
function translate_tagging($node, $level = 0) {
|
367 |
$this->currentnode = $node;
|
368 |
// we don't want to translate non-translatable classes
|
369 |
-
if (stripos($node->class,NO_TRANSLATE_CLASS) !== false
|
370 |
-
|
371 |
-
|
|
|
|
|
372 |
$this->inselect = false;
|
373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
if (isset($this->ignore_tags[$node->tag])) return;
|
|
|
375 |
if ($node->tag == 'text') {
|
376 |
// this prevents translation of a link that just surrounds its address
|
377 |
if ($node->parent->tag == 'a' && $node->parent->href == $node->outertext) {
|
@@ -397,13 +435,6 @@ class parser {
|
|
397 |
$node->value = call_user_func_array($this->url_rewrite_func,array($node->value));
|
398 |
}
|
399 |
}
|
400 |
-
// we can only do translation for elements which are in the body, not in other places
|
401 |
-
elseif ($node->tag == 'body') {
|
402 |
-
$this->inbody = true;
|
403 |
-
}
|
404 |
-
elseif ($node->tag == 'select' || $node->tag == 'textarea') {
|
405 |
-
$this->inselect = $level;
|
406 |
-
}
|
407 |
// in submit type inputs, we want to translate the value
|
408 |
elseif ($node->tag == 'input' && $node->type =='submit') {
|
409 |
$this->parsetext($node->value);
|
96 |
/** @var simple_html_dom Contains the document dom model */
|
97 |
private $html; // the document
|
98 |
public $dir_rtl;
|
99 |
+
/** @var string Contains the iso of the target language */
|
100 |
public $lang;
|
101 |
+
/** @var boolean Contains the fact that this language is the default one (only parse other lanaguage spans) */
|
102 |
+
public $default_lang = false;
|
103 |
private $inbody = false;
|
104 |
+
private $inselect = false;
|
105 |
+
/** @var int holds level of non default language */
|
106 |
+
private $inlangnondef = false;
|
107 |
public $is_edit_mode;
|
108 |
public $is_auto_translate;
|
109 |
public $feed_fix;
|
371 |
function translate_tagging($node, $level = 0) {
|
372 |
$this->currentnode = $node;
|
373 |
// we don't want to translate non-translatable classes
|
374 |
+
if (stripos($node->class,NO_TRANSLATE_CLASS) !== false ||
|
375 |
+
stripos($node->class,NO_TRANSLATE_CLASS_GOOGLE) !== false ||
|
376 |
+
strtolower($node->lang) === $this->lang) return;
|
377 |
+
|
378 |
+
if ($this->inselect && $level <= $this->inselect)
|
379 |
$this->inselect = false;
|
380 |
|
381 |
+
if ($this->inlangnondef && $level <= $this->inlangnondef)
|
382 |
+
$this->inlangnondef = false;
|
383 |
+
|
384 |
+
if ($this->default_lang && $node->lang != '' && stripos($node->lang,$this->lang) === false)
|
385 |
+
$this->inlangnondef = $level;
|
386 |
+
|
387 |
+
// we can only do translation for elements which are in the body, not in other places, and this must
|
388 |
+
// move here due to the possibility of early recurse in default language
|
389 |
+
if ($node->tag == 'body') {
|
390 |
+
$this->inbody = true;
|
391 |
+
}
|
392 |
+
// this again should be here, the different behaviour on select and textarea
|
393 |
+
elseif ($node->tag == 'select' || $node->tag == 'textarea') {
|
394 |
+
$this->inselect = $level;
|
395 |
+
}
|
396 |
+
|
397 |
+
//support only_thislanguage class, (nulling the node if it should not display)
|
398 |
+
if (strtolower($node->lang) != $this->lang && stripos($node->class,ONLY_THISLANGUAGE_CLASS) !== false) {
|
399 |
+
$node->outertext = '';
|
400 |
+
return;
|
401 |
+
}
|
402 |
+
|
403 |
+
// if we are in the default lang, and we have no foreign langs classes, we'll recurse from here
|
404 |
+
if ($this->default_lang && !$this->inlangnondef) {
|
405 |
+
foreach($node->nodes as $c) {
|
406 |
+
$this->translate_tagging($c, $level +1);
|
407 |
+
}
|
408 |
+
return;
|
409 |
+
}
|
410 |
+
|
411 |
if (isset($this->ignore_tags[$node->tag])) return;
|
412 |
+
|
413 |
if ($node->tag == 'text') {
|
414 |
// this prevents translation of a link that just surrounds its address
|
415 |
if ($node->parent->tag == 'a' && $node->parent->href == $node->outertext) {
|
435 |
$node->value = call_user_func_array($this->url_rewrite_func,array($node->value));
|
436 |
}
|
437 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
// in submit type inputs, we want to translate the value
|
439 |
elseif ($node->tag == 'input' && $node->type =='submit') {
|
440 |
$this->parsetext($node->value);
|
index.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head>
|
3 |
+
<title>Transposh plugin starter page</title>
|
4 |
+
</head>
|
5 |
+
<body>
|
6 |
+
<div style="text-align: center;"><span style="font-weight: bold;">Welcome to <a href="http://transposh.org">transposh</a> wordpress plugin</span><br />
|
7 |
+
</div><br />
|
8 |
+
Transposh helps you multi-lingualize your blog with ease<br />
|
9 |
+
<br />
|
10 |
+
Here are a few starting points:<br />
|
11 |
+
<a href="http://transposh.org">Transposh homepage</a><br />
|
12 |
+
<a href="http://transposh.org/faq/">Transposh FAQ</a><br />
|
13 |
+
<a href="http://wordpress.org/extend/plugins/transposh-translation-filter-for-wordpress/">Transposh plugin page on wordpress.org</a><br />
|
14 |
+
<a href="http://trac.transposh.org">Transposh development site and wiki</a><br />
|
15 |
+
<a href="http://wordpress.org/extend/plugins/transposh-translation-filter-for-wordpress/">Download the latest version of Transposh plugin</a>
|
16 |
+
|
17 |
+
</body>
|
18 |
+
</html>
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Transposh - translation filter for wordpress ===
|
2 |
-
Contributors: oferwald
|
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:
|
7 |
-
Stable tag: 0.5.
|
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.5.1 =
|
163 |
Improved speed and database structure
|
164 |
= 0.5.0 =
|
@@ -173,10 +175,15 @@ This version provides integration with google-sitemaps-xml and wp-super-cache
|
|
173 |
This version allows sorting of languages within the widget
|
174 |
|
175 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
176 |
= 2010/04/11 - 0.5.1 =
|
177 |
* Improved database structure to support long translations
|
178 |
* Improved speed by pre-fetching contents with a single mysql query (over 70% faster in some cases)
|
179 |
-
* Fix for textarea tag bug - (thanks [timo]
|
180 |
= 2010/03/24 - 0.5.0 =
|
181 |
* Ability to backup human translation to a remote database (hosted on google appengine)
|
182 |
* Ability to translate all existing content with a single click from the administration page
|
1 |
=== Transposh - translation filter for wordpress ===
|
2 |
+
Contributors: oferwald
|
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: 3.0 beta-1
|
7 |
+
Stable tag: 0.5.2
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
159 |
5. Widget style selection box, with three basic appearances, flags below (in Hebrew), language selection on the top right and language list on the bottom right.
|
160 |
|
161 |
== Upgrade Notice ==
|
162 |
+
= 0.5.2 =
|
163 |
+
Improved lang attribute support, changed default language translation option
|
164 |
= 0.5.1 =
|
165 |
Improved speed and database structure
|
166 |
= 0.5.0 =
|
175 |
This version allows sorting of languages within the widget
|
176 |
|
177 |
== Changelog ==
|
178 |
+
= 2010/04/11 - 0.5.2 =
|
179 |
+
* support the google notranslate class notation (as an addition to no_translate)
|
180 |
+
* support for lang tagging on paragraphs
|
181 |
+
* changed translation of default language to just translate paragraphs explicitly marked with a different language
|
182 |
+
* support the only_thislanguage class to make sure a paragraph is only displayed in a given language
|
183 |
= 2010/04/11 - 0.5.1 =
|
184 |
* Improved database structure to support long translations
|
185 |
* Improved speed by pre-fetching contents with a single mysql query (over 70% faster in some cases)
|
186 |
+
* Fix for textarea tag bug - (thanks [timo](http://www.herbaldepecona.com/))
|
187 |
= 2010/03/24 - 0.5.0 =
|
188 |
* Ability to backup human translation to a remote database (hosted on google appengine)
|
189 |
* Ability to translate all existing content with a single click from the administration page
|
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.5.
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
@@ -168,6 +168,7 @@ class transposh_plugin {
|
|
168 |
$parse->url_rewrite_func = array(&$this, 'rewrite_url');
|
169 |
$parse->dir_rtl = (in_array ($this->target_language, $GLOBALS['rtl_languages']));
|
170 |
$parse->lang = $this->target_language;
|
|
|
171 |
$parse->is_edit_mode = $this->edit_mode;
|
172 |
$parse->is_auto_translate = $this->is_auto_translate_permitted();
|
173 |
// TODO - check this!
|
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.2
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
*/
|
168 |
$parse->url_rewrite_func = array(&$this, 'rewrite_url');
|
169 |
$parse->dir_rtl = (in_array ($this->target_language, $GLOBALS['rtl_languages']));
|
170 |
$parse->lang = $this->target_language;
|
171 |
+
$parse->default_lang = $this->options->is_default_language($this->target_language);
|
172 |
$parse->is_edit_mode = $this->edit_mode;
|
173 |
$parse->is_auto_translate = $this->is_auto_translate_permitted();
|
174 |
// TODO - check this!
|