Changeset 76
- Timestamp:
- 03/19/2009 12:22:25 PM (3 years ago)
- Location:
- trunk/WordPress/plugin/transposh
- Files:
-
- 2 edited
-
parser.php (modified) (7 diffs)
-
transposh.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/parser.php
r74 r76 56 56 //Is current position within the channel tag, i.e. RSS feed 57 57 $is_in_channel = FALSE; 58 59 //Indicates whether automatic translation (i.e. google) is enabled for this page 60 $enable_auto_translate; 58 61 59 62 /* … … 416 419 $start = $pos; 417 420 } 421 else if($end_of_number = is_number($pos)) 422 { 423 //numbers will break translations segements and will not be included in the translation 424 translate_text($start); 425 $pos = $start = $end_of_number; 426 } 418 427 else 419 428 { … … 456 465 $pos++; 457 466 $start = $pos; 467 } 468 else if($end_of_number = is_number($pos)) 469 { 470 //numbers will break translations segements and will not be included in the translation 471 translate_text($start); 472 $pos = $start = $end_of_number; 458 473 } 459 474 else … … 519 534 $page[$position] == '"' || $page[$position] == '!' || 520 535 $page[$position] == ':' || $page[$position] == '|' || 521 $page[$position] == ';' || 522 //break on numbers but not like: 3rd, 4th 523 (is_digit($position) && !is_a_to_z_character($position+1))) 536 $page[$position] == ';') 524 537 { 525 538 //break the sentence into segments regardless of the next character. … … 570 583 } 571 584 585 /* 586 * Determines if the current position marks the begining of a number, e.g. 123 050-391212232 587 * 588 * Return 0 if not a number otherwise return the position past this number. 589 */ 590 function is_number($position) 591 { 592 global $page; 593 $start = $position; 594 595 while(is_digit($position) || $page[$position] == '-' || $page[$position] == '+') 596 { 597 $position++; 598 } 599 600 if($position != $start && (is_white_space($position) || $page[$position] == '<')) 601 { 602 return $position; 603 } 604 605 return 0; 606 } 572 607 573 608 /* … … 622 657 return TRUE; 623 658 } 624 }625 626 /*627 * Skip within buffer past unreadable characters , i.e. white space628 * and characters considred to be a sentence breaker. Staring from the specified629 * position going either forward or backward.630 * param forward - indicate direction going either backward of forward.631 */632 function skip_unreadable_chars(&$index, $forward=TRUE)633 {634 global $page, $pos;635 636 if(!isset($index))637 {638 //use $pos as the default position if not specified otherwise639 $index = &$pos;640 }641 $start = $index;642 643 while($index < strlen($page) && $index > 0 &&644 (is_white_space($index) || is_sentence_breaker($index)))645 {646 ($forward ? $index++ : $index--);647 }648 649 return $index;650 659 } 651 660 … … 769 778 $is_translated = FALSE; 770 779 771 if(!($is_edit_mode || get_option(ENABLE_AUTO_TRANSLATE,1)) || !in_array('body', $tags_list))780 if(!($is_edit_mode || $enable_auto_translate) || !in_array('body', $tags_list)) 772 781 { 773 782 if($translated_text != NULL) -
trunk/WordPress/plugin/transposh/transposh.php
r74 r76 281 281 function insert_javascript_includes() 282 282 { 283 global $plugin_url, $wp_query; 284 285 if (!($wp_query->query_vars[EDIT_PARAM] == "1" || 286 $wp_query->query_vars[EDIT_PARAM] == "true") && !get_option(ENABLE_AUTO_TRANSLATE,1)) 283 global $plugin_url, $wp_query, $lang, $home_url, $enable_auto_translate; 284 285 $is_edit_param_enabled = ($wp_query->query_vars[EDIT_PARAM] == "1" || 286 $wp_query->query_vars[EDIT_PARAM] == "true"); 287 288 if (!$is_edit_param_enabled && ! $enable_auto_translate) 287 289 { 288 290 //TODO: check permission later - for now just make sure we don't load the … … 294 296 $overlib_dir = "$plugin_url/js/overlibmws"; 295 297 296 if ($wp_query->query_vars[EDIT_PARAM] == "1" || $wp_query->query_vars[EDIT_PARAM] == "true") { 298 if($is_edit_param_enabled) 299 { 297 300 $js = "\n<script type=\"text/javascript\" src=\"$overlib_dir/overlibmws.js\"></script>"; 298 301 $js .= "\n<script type=\"text/javascript\" src=\"$overlib_dir/overlibmws_filter.js\"></script>"; … … 302 305 $js .= "\n<script type=\"text/javascript\" src=\"$overlib_dir/overlibmws_shadow.js\"></script>"; 303 306 } 304 $js .= "\n<script type=\"text/javascript\" src=\"$plugin_url/js/transposh.js\"></script>"; 305 $js .= "\n<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></script>"; 306 $js .= "\n<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>"; 307 $js .= "\n<script type=\"text/javascript\">google.load(\"language\", \"1\");</script>"; 308 global $lang, $home_url; 309 $post_url = $home_url . '/index.php'; 310 $js .= "\n<script type=\"text/javascript\">var transposh_post_url='$post_url';var transposh_target_lang='$lang';</script>"; 311 if (get_option(ENABLE_AUTO_TRANSLATE,1)) { 307 308 if($is_edit_param_enabled || $enable_auto_translate) 309 { 310 $js .= "\n<script type=\"text/javascript\" src=\"$plugin_url/js/transposh.js\"></script>"; 311 $js .= "\n<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></script>"; 312 $js .= "\n<script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script>"; 313 $js .= "\n<script type=\"text/javascript\">google.load(\"language\", \"1\");</script>"; 314 315 316 $post_url = $home_url . '/index.php'; 317 $js .= "\n<script type=\"text/javascript\">var transposh_post_url='$post_url';var transposh_target_lang='$lang';</script>"; 318 312 319 $js .= "\n<script type=\"text/javascript\">$(document).ready(function() {do_auto_translate();});</script>"; 313 320 } 314 echo $js; 321 322 echo $js . "\n"; 315 323 } 316 324 … … 383 391 function init_global_vars() 384 392 { 385 global $home_url, $home_url_quoted, $plugin_url, $table_name, $wpdb ;393 global $home_url, $home_url_quoted, $plugin_url, $table_name, $wpdb, $enable_auto_translate; 386 394 387 395 $home_url = get_option('home'); … … 393 401 394 402 $table_name = $wpdb->prefix . TRANSLATIONS_TABLE; 403 $enable_auto_translate = get_option(ENABLE_AUTO_TRANSLATE,1); 395 404 } 396 405 … … 530 539 logger(__METHOD__ . $_SERVER['REQUEST_URI']); 531 540 init_global_vars(); 532 533 541 534 542 if ($_POST['translation_posted']) 535 543 { … … 766 774 { 767 775 global $admin_msg; 768 logger("Enter " . __METHOD__, 3);776 logger("Enter " . __METHOD__, 4); 769 777 770 778 $db_version = get_option(TRANSPOSH_DB_VERSION);
Note: See TracChangeset
for help on using the changeset viewer.
