Make WordPress Core

Ticket #19852: 19852-makepot.5.diff

File 19852-makepot.5.diff, 4.8 KB (added by ryan, 13 years ago)

User and site admin in same pot. Dupe removal for net admin pot.

  • makepot.php

     
    1212
    1313        var $projects = array(
    1414                'generic',
     15                'wp-frontend',
     16                'wp-admin',
     17                'wp-network-admin',
    1518                'wp-core',
    1619                'wp-ms',
    1720                'wp-tz',
     
    5760                        'comments' => "Copyright (C) {year} {package-name}\nThis file is distributed under the same license as the {package-name} package.",
    5861                ),
    5962                'generic' => array(),
     63                'wp-frontend' => array(
     64                        'description' => 'Translation of frontend strings in WordPress {version}',
     65                        'copyright-holder' => 'WordPress',
     66                        'package-name' => 'WordPress',
     67                        'package-version' => '{version}',
     68                ),
     69                'wp-admin' => array(
     70                        'description' => 'Translation of site admin strings in WordPress {version}',
     71                        'copyright-holder' => 'WordPress',
     72                        'package-name' => 'WordPress',
     73                        'package-version' => '{version}',
     74                ),
     75                'wp-network-admin' => array(
     76                        'description' => 'Translation of network admin strings in WordPress {version}',
     77                        'copyright-holder' => 'WordPress',
     78                        'package-name' => 'WordPress',
     79                        'package-version' => '{version}',
     80                ),
    6081                'wp-core' => array(
    6182                        'description' => 'Translation of WordPress {version}',
    6283                        'copyright-holder' => 'WordPress',
     
    185206        }
    186207
    187208        function wp_core($dir, $output) {
     209                if ( !file_exists( "$dir/wp-admin/user/about.php" ) ) {
     210                        // WP 3.3 or earlier.
     211                        return $this->wp_generic( $dir, array(
     212                                'project' => 'wp-core', 'output' => $output,
     213                        ) );
     214                } else {
     215                        // WP 3.4 and later
     216                        // @todo check returns
     217                        $this->wp_frontend($dir, $output);
     218                        $this->wp_admin($dir, null);
     219                        $this->wp_network_admin($dir, null);
     220                        $this->wp_user_admin($dir, null);
     221                }
     222        }
     223
     224        function wp_frontend($dir, $output) {
    188225                return $this->wp_generic( $dir, array(
    189                         'project' => 'wp-core', 'output' => $output,
     226                        'project' => 'wp-frontend', 'output' => $output,
     227                        'includes' => array(), 'excludes' => array( 'wp-admin/.*', 'wp-content/themes/twentyten/.*', 'wp-content/themes/twentyeleven/.*' ),
     228                        'default_output' => 'wordpress.pot',
     229                        'extract_not_gettexted' => false,
    190230                ) );
    191231        }
    192232
     233        function wp_admin($dir, $output) {
     234                $frontend_pot = tempnam( sys_get_temp_dir(), 'frontend.pot');
     235                if ( false === $frontend_pot ) return false;
     236
     237                $frontend_result = $this->wp_frontend( $dir, $frontend_pot );
     238                if ( ! $frontend_result ) {
     239                        unlink( $frontend_pot );
     240                        return false;
     241                }
     242
     243                $result = $this->wp_generic( $dir, array(
     244                        'project' => 'wp-admin', 'output' => $output,
     245                        'includes' => array( 'wp-admin/.*' ), 'excludes' => array( 'wp-admin/includes/continents-cities\.php', 'wp-admin/network/.*' ),
     246                        'default_output' => 'wordpress-admin.pot',
     247                        'extract_not_gettexted' => false,
     248                ) );
     249
     250                if ( ! $result ) {
     251                        return false;
     252                }
     253
     254                $common_pot = tempnam( sys_get_temp_dir(), 'common.pot' );
     255                if ( ! $common_pot ) {
     256                        unlink( $frontend_pot );
     257                        return false;
     258                }
     259                $admin_pot = realpath( is_null( $output ) ? 'wordpress-admin.pot' : $output );
     260                system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot > $common_pot" );
     261                system( "msgcat -u --use-first $admin_pot $common_pot -o $admin_pot" );
     262                return true;
     263        }
     264
     265        function wp_network_admin($dir, $output) {
     266                $frontend_pot = tempnam( sys_get_temp_dir(), 'frontend.pot');
     267                if ( false === $frontend_pot ) return false;
     268
     269                $frontend_result = $this->wp_frontend( $dir, $frontend_pot );
     270                if ( ! $frontend_result ) {
     271                        unlink( $frontend_pot );
     272                        return false;
     273                }
     274
     275                $admin_pot = tempnam( sys_get_temp_dir(), 'admin.pot');
     276                if ( false === $admin_pot ) return false;
     277
     278                $admin_result = $this->wp_admin( $dir, $admin_pot );
     279                if ( ! $admin_result ) {
     280                        unlink( $admin_pot );
     281                        return false;
     282                }
     283
     284                $result = $this->wp_generic( $dir, array(
     285                        'project' => 'wp-network-admin', 'output' => $output,
     286                        'includes' => array( 'wp-admin/network/.*' ), 'excludes' => array(),
     287                        'default_output' => 'wordpress-network-admin.pot',
     288                        'extract_not_gettexted' => false,
     289                ) );
     290
     291                if ( ! $result ) {
     292                        return false;
     293                }
     294
     295                $common_pot = tempnam( sys_get_temp_dir(), 'common.pot' );
     296                if ( ! $common_pot ) {
     297                        unlink( $admin_pot );
     298                        unlink( $frontend_pot );
     299                        return false;
     300                }
     301
     302                $net_admin_pot = realpath( is_null( $output ) ? 'wordpress-network-admin.pot' : $output );
     303                system( "msgcat --more-than=1 --use-first $frontend_pot $admin_pot $net_admin_pot > $common_pot" );
     304                system( "msgcat -u --use-first $net_admin_pot $common_pot -o $net_admin_pot" );
     305                return true;
     306        }
     307
    193308        function wp_ms($dir, $output) {
     309                if ( file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
    194310                if ( !is_file("$dir/wp-admin/ms-users.php") ) return false;
    195311                $core_pot = tempnam( sys_get_temp_dir(), 'wordpress.pot');
    196312                if ( false === $core_pot ) return false;