Ticket #34749: 34749-develop-svn.diff
File 34749-develop-svn.diff, 5.4 KB (added by , 8 years ago) |
---|
-
tools/i18n/makepot.php
26 26 'glotpress', 27 27 'rosetta', 28 28 'wporg-bb-forums', 29 'wporg-themes', 30 'wporg-plugins', 31 'wporg-forums', 32 'wordcamporg', 29 33 ); 30 34 31 35 var $rules = array( … … 137 141 'copyright-holder' => 'WordPress', 138 142 'package-name' => 'WordPress.org International Forums', 139 143 ), 144 'wporg' => array( 145 'description' => 'WordPress.org', 146 'copyright-holder' => 'WordPress', 147 'package-name' => 'WordPress.org', 148 ), 149 'wordcamporg' => array( 150 'description' => 'WordCamp.org', 151 'copyright-holder' => 'WordPress', 152 'package-name' => 'WordCamp.org', 153 ), 140 154 'rosetta' => array( 141 155 'description' => 'Rosetta (.wordpress.org locale sites)', 142 156 'copyright-holder' => 'WordPress', … … 408 422 return $this->xgettext('wp', $dir, $output, $placeholders); 409 423 } 410 424 411 412 function bb($dir, $output) {413 $placeholders = array();414 $output = is_null($output)? 'bbpress.pot' : $output;415 return $this->xgettext('bb', $dir, $output, $placeholders);416 417 }418 419 425 function get_first_lines($filename, $lines = 30) { 420 426 $extf = fopen($filename, 'r'); 421 427 if (!$extf) return false; … … 428 434 } 429 435 $first_lines .= $line; 430 436 } 437 438 // PHP will close file handle, but we are good citizens. 439 fclose( $extf ); 440 441 // Make sure we catch CR-only line endings. 442 $first_lines = str_replace( "\r", "\n", $first_lines ); 443 431 444 return $first_lines; 432 445 } 433 446 434 435 447 function get_addon_header($header, &$source) { 436 if (preg_match('|'.$header.':(.*)$|mi', $source, $matches)) 437 return trim($matches[1]); 438 else 448 /* 449 * A few things this needs to handle: 450 * - 'Header: Value\n' 451 * - '// Header: Value' 452 * - '/* Header: Value * /' 453 * - '<?php // Header: Value ?>' 454 * - '<?php /* Header: Value * / $foo='bar'; ?>' 455 */ 456 if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $header, '/' ) . ':(.*)$/mi', $source, $matches ) ) { 457 return $this->_cleanup_header_comment( $matches[1] ); 458 } else { 439 459 return false; 460 } 440 461 } 441 462 463 /** 464 * Removes any trailing closing comment / PHP tags from the header value 465 */ 466 function _cleanup_header_comment( $str ) { 467 return trim( preg_replace( '/\s*(?:\*\/|\?>).*/', '', $str ) ); 468 } 469 442 470 function generic($dir, $output) { 443 471 $output = is_null($output)? "generic.pot" : $output; 444 472 return $this->xgettext('generic', $dir, $output, array()); … … 455 483 return $slug; 456 484 } 457 485 458 function wp_plugin($dir, $output, $slug = null) { 486 function wp_plugin( $dir, $output, $slug = null, $args = array() ) { 487 $defaults = array( 488 'excludes' => array(), 489 'includes' => array(), 490 ); 491 $args = array_merge( $defaults, $args ); 459 492 $placeholders = array(); 460 493 // guess plugin slug 461 494 if (is_null($slug)) { … … 506 539 $placeholders['slug'] = $slug; 507 540 508 541 $output = is_null($output)? "$slug.pot" : $output; 509 $res = $this->xgettext( 'wp-plugin', $dir, $output, $placeholders);542 $res = $this->xgettext( 'wp-plugin', $dir, $output, $placeholders, $args['excludes'], $args['includes'] ); 510 543 if (!$res) return false; 511 544 $potextmeta = new PotExtMeta; 512 545 $res = $potextmeta->append($main_file, $output); … … 571 604 return $res; 572 605 } 573 606 574 function bp($dir, $output) { 575 $output = is_null($output)? "buddypress.pot" : $output; 576 return $this->xgettext('bp', $dir, $output, array(), array('bp-forums/bbpress/.*')); 607 function bp( $dir, $output ) { 608 $output = is_null( $output ) ? 'buddypress.pot' : $output; 609 $args = array( 610 'excludes' => array( 'bp-forums/bbpress/.*', 'tests/.*' ), 611 ); 612 613 // BuddyPress 2.1+ 614 if ( is_dir( "$dir/src" ) ) { 615 $args = array( 616 'includes' => array( 'src/.*' ), 617 'excludes' => array( 'src/bp-forums/bbpress/.*' ), 618 ); 619 } 620 621 return $this->wp_plugin( $dir, $output, 'buddypress', $args ); 577 622 } 578 623 624 function bb( $dir, $output ) { 625 $output = is_null( $output ) ? 'bbpress.pot' : $output; 626 return $this->wp_plugin( $dir, $output, 'bbpress' ); 627 } 628 579 629 function glotpress( $dir, $output ) { 580 630 $output = is_null( $output ) ? "glotpress.pot" : $output; 581 631 return $this->xgettext( 'glotpress', $dir, $output ); … … 586 636 return $this->xgettext( 'wporg-bb-forums', $dir, $output, array(), array( 587 637 'bb-plugins/elfakismet/.*', 588 638 'bb-plugins/support-forum/.*', 639 'themes/.*', 589 640 ) ); 590 641 } 591 642 643 function wporg_themes( $dir, $output ) { 644 $output = is_null( $output ) ? 'wporg-themes.pot' : $output; 645 return $this->xgettext( 'wporg', $dir, $output, array(), array(), array( 646 'plugins/theme-directory/.*', 647 'themes/pub/wporg-themes/.*' 648 ) ); 649 } 650 651 function wporg_plugins( $dir, $output ) { 652 $output = is_null( $output ) ? 'wporg-plugins.pot' : $output; 653 return $this->xgettext( 'wporg', $dir, $output, array(), array(), array( 654 '.*\.php', 655 ) ); 656 } 657 658 function wporg_forums( $dir, $output ) { 659 $output = is_null( $output ) ? 'wporg-forums.pot' : $output; 660 return $this->xgettext( 'wporg', $dir, $output, array(), array(), array( 661 '.*\.php', 662 ) ); 663 } 664 665 function wordcamporg( $dir, $output ) { 666 $output = is_null( $output ) ? 'wordcamporg.pot' : $output; 667 return $this->xgettext( 'wordcamporg', $dir, $output, array(), array(), array( 668 '.*\.php', 669 ) ); 670 } 671 592 672 function rosetta( $dir, $output ) { 593 673 $output = is_null( $output )? 'rosetta.pot' : $output; 594 674 return $this->xgettext( 'rosetta', $dir, $output, array(), array(), array(