Ticket #7296: 7296.2.diff
File 7296.2.diff, 4.5 KB (added by , 13 months ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/cli/class-export.php
102 102 103 103 $files = array_merge( $files, $jed_files ); 104 104 105 if ( version_compare( $version, '6.5-beta', '>=' ) ) { 106 // Create PHP file. 107 $php_file = "{$wp_locale}.mo.php"; 108 if ($context) { 109 $php_file = "$context-{$php_file}"; 110 } 111 $php_file = "{$dest}/{$php_file}"; 112 $result = $this->build_php_file( $gp_project, $gp_locale, $translation_set, $po_entries, $php_file ); 113 if ($result) { 114 $files[] = $php_file; 115 } 116 } 117 105 118 // Create PO file. 106 119 $po_file = "{$wp_locale}.po"; 107 120 if ( $context ) { … … 256 269 257 270 return true; 258 271 } 272 273 /** 274 * Builds a PHP file for translations. 275 * 276 * @param GP_Project $gp_project The GlotPress project. 277 * @param GP_Locale $gp_locale The GlotPress locale. 278 * @param GP_Translation_Set $set The translation set. 279 * @param Translation_Entry[] $entries The translation entries. 280 * @param string $dest Destination file name. 281 * @return boolean True on success, false on failure. 282 */ 283 private function build_php_file( $gp_project, $gp_locale, $set, $entries, $dest ) { 284 $format = gp_array_get( GP::$formats, 'php' ); 285 $content = $format->print_exported_file( $gp_project, $gp_locale, $set, $entries ); 286 287 return false !== file_put_contents( $dest, $content ); 288 } 259 289 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/cli/class-language-pack.php
510 510 return $match[1]; 511 511 } 512 512 513 /** 513 /** 514 * Builds a PHP file for translations. 515 * 516 * @param GP_Project $gp_project The GlotPress project. 517 * @param GP_Locale $gp_locale The GlotPress locale. 518 * @param GP_Translation_Set $set The translation set. 519 * @param Translation_Entry[] $entries The translation entries. 520 * @param string $dest Destination file name. 521 * @return bool True on success, false on error. 522 */ 523 private function build_php_file( $gp_project, $gp_locale, $set, $entries, $dest ) { 524 $format = gp_array_get( GP::$formats, 'php' ); 525 $content = $format->print_exported_file( $gp_project, $gp_locale, $set, $entries ); 526 527 return false !== file_put_contents( $dest, $content ); 528 } 529 530 /** 514 531 * Executes a command via exec(). 515 532 * 516 533 * @param string $command The escaped command to execute. … … 652 669 $json_file_base = "{$export_directory}/{$filename}"; 653 670 $po_file = "{$export_directory}/{$filename}.po"; 654 671 $mo_file = "{$export_directory}/{$filename}.mo"; 672 $php_file = "{$export_directory}/{$filename}.mo.php"; 655 673 $zip_file = "{$export_directory}/{$filename}.zip"; 656 674 $build_zip_file = "{$build_directory}/{$wp_locale}.zip"; 657 675 $build_sig_file = "{$build_zip_file}.sig"; … … 666 684 unset( $mapping['po'] ); 667 685 668 686 // Create JED json files for each JS file. 669 $ json_files = $this->build_json_files( $data->gp_project, $gp_locale, $set, $mapping, $json_file_base );687 $additional_files = $this->build_json_files( $data->gp_project, $gp_locale, $set, $mapping, $json_file_base ); 670 688 689 // Create PHP file. 690 $php_file_written = $this->build_php_file( $data->gp_project, $gp_locale, $set, $po_entries, $php_file ); 691 692 if ( $php_file_written ) { 693 $additional_files[] = $php_file; 694 } 695 671 696 // Create PO file. 672 697 $last_modified = $this->build_po_file( $data->gp_project, $gp_locale, $set, $po_entries, $po_file ); 673 698 … … 703 728 escapeshellarg( $zip_file ), 704 729 escapeshellarg( $po_file ), 705 730 escapeshellarg( $mo_file ), 706 implode( ' ', array_map( 'escapeshellarg', $ json_files ) )731 implode( ' ', array_map( 'escapeshellarg', $additional_files ) ) 707 732 ) ); 708 733 709 734 if ( is_wp_error( $result ) ) {