Changeset 151
- Timestamp:
- 04/07/2009 12:08:58 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/WordPress/plugin/transposh/core/parser.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/core/parser.php
r142 r151 35 35 $pos = 0; 36 36 37 //Used for statistics 38 $phrase_count = 0; 39 $pharses_by_human = 0; 40 $pharses_by_cat = 0; 41 37 42 //Contains the stack of tag in the current position within the page 38 43 $tags_list = array(); … … 61 66 logger("Enter " . __METHOD__, 4); 62 67 63 global $page, $tr_page, $pos, $tags_list, $lang ;68 global $page, $tr_page, $pos, $tags_list, $lang, $phrase_count, $pharses_by_human, $pharses_by_cat; 64 69 $no_translate = 0; 65 70 $page_length = strlen($page); … … 150 155 } 151 156 157 logger("Stats: all-$phrase_count, cat-$pharses_by_cat, human-$pharses_by_human", 0); 152 158 logger("Exit " . __METHOD__, 4); 153 159 } … … 453 459 //will break translation unit when one of the following characters is reached: ., 454 460 if(is_sentence_breaker($pos) || 455 $page[$pos] == '<' || $page[$pos] == '>') //only in cdata the < > are valid breakers as well461 $page[$pos] == '<' || $page[$pos] == '>') //only in cdata the < > are valid breakers as well 456 462 { 457 463 translate_text($start); … … 498 504 } 499 505 else if($is_in_channel && 500 ($current_tag == 'title' || $current_tag == 'description' || $current_tag == 'category'))506 ($current_tag == 'title' || $current_tag == 'description' || $current_tag == 'category')) 501 507 { 502 508 $rc = TRUE; … … 527 533 } 528 534 else if($page[$position] == ',' || $page[$position] == '?' || 529 $page[$position] == '(' || $page[$position] == ')' ||530 $page[$position] == '[' || $page[$position] == ']' ||531 $page[$position] == '"' || $page[$position] == '!' ||532 $page[$position] == ':' || $page[$position] == '|' ||533 $page[$position] == ';')535 $page[$position] == '(' || $page[$position] == ')' || 536 $page[$position] == '[' || $page[$position] == ']' || 537 $page[$position] == '"' || $page[$position] == '!' || 538 $page[$position] == ':' || $page[$position] == '|' || 539 $page[$position] == ';') 534 540 { 535 541 //break the sentence into segments regardless of the next character. … … 569 575 //Exception: don't break when we there is a white space after the apostrophe. e.g. `uncategorized` 570 576 if(($entity == "’" || $entity == "'" || $entity == "'") 571 && $page[$end_pos + 1] != " ")577 && $page[$end_pos + 1] != " ") 572 578 { 573 579 $is_breaker = FALSE; … … 598 604 599 605 while(is_digit($position) || $page[$position] == '-' || $page[$position] == '+' || 600 (($page[$position] == ',' || $page[$position] == '.' || $page[$position] == '\\' || $page[$position] == '/') && is_digit($position+1)))606 (($page[$position] == ',' || $page[$position] == '.' || $page[$position] == '\\' || $page[$position] == '/') && is_digit($position+1))) 601 607 { 602 608 $position++; … … 738 744 { 739 745 logger("Enter " . __METHOD__ . " : $start", 4); 740 global $page, $pos, $lang ;746 global $page, $pos, $lang, $phrase_count, $pharses_by_human, $pharses_by_cat; 741 747 742 748 //trim white space from the start position going forward … … 767 773 list($translated_text, $source) = fetch_translation($original_text, $lang); 768 774 775 $phrase_count++; 776 if ($translated_text != NULL) { 777 if ($source) { 778 $pharses_by_cat++; 779 } else { 780 $pharses_by_human++; 781 } 782 } 783 769 784 insert_translation($original_text, $translated_text, $source, $start, $end); 770 785 } … … 790 805 791 806 //Use base64 encoding to make that when the page is translated (i.e. update_translation) we 792 //get back exactlly the same string without having the client decode/encode it in anyway.793 $token = "token=\"" . base64_url_encode($original_text) . "\"";794 795 if($translated_text == NULL)796 { 797 $span .= "u\" id=\"{$span_prefix}{$segment_id}\" $token>";807 //get back exactlly the same string without having the client decode/encode it in anyway. 808 $token = "token=\"" . base64_url_encode($original_text) . "\""; 809 810 if($translated_text == NULL) 811 { 812 $span .= "u\" id=\"{$span_prefix}{$segment_id}\" $token>"; 798 813 $span .= $original_text . '</span>'; 799 814 } … … 907 922 //Allow specific override for url rewriting . 908 923 if($enable_permalinks_rewrite && function_exists('is_url_excluded_from_permalink_rewrite') && 909 is_url_excluded_from_permalink_rewrite($href))924 is_url_excluded_from_permalink_rewrite($href)) 910 925 { 911 926 $use_params = TRUE;
Note: See TracChangeset
for help on using the changeset viewer.
