Changeset 76 for trunk/WordPress/plugin/transposh/parser.php
- Timestamp:
- 03/19/2009 12:22:25 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/WordPress/plugin/transposh/parser.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)
Note: See TracChangeset
for help on using the changeset viewer.
