Make WordPress Core

Ticket #27610: 27610.patch

File 27610.patch, 2.6 KB (added by azaozz, 12 years ago)
  • src/wp-includes/class-wp-editor.php

     
    262262
    263263                        if ( empty( self::$first_init ) ) {
    264264                                self::$baseurl = includes_url( 'js/tinymce' );
     265
    265266                                $mce_locale = get_locale();
     267                                self::$mce_locale = $mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1
    266268
    267                                 if ( empty( $mce_locale ) || 'en' == substr( $mce_locale, 0, 2 ) ) {
    268                                         $mce_locale = 'en';
    269                                 }
    270 
    271                                 self::$mce_locale = $mce_locale;
    272 
    273269                                /** This filter is documented in wp-admin/includes/media.php */
    274270                                $no_captions = (bool) apply_filters( 'disable_captions', '' );
    275271                                $first_run = true;
     
    384380                                                        $url = set_url_scheme( $url );
    385381                                                        $mce_external_plugins[ $name ] = $url;
    386382                                                        $plugurl = dirname( $url );
     383                                                        $strings = $str1 = $str2 = '';
    387384
    388                                                         if ( in_array( $name, $loaded_langs ) ) {
    389                                                                 $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
     385                                                        // Try to load langs/[locale].js and langs/[locale]_dlg.js
     386                                                        if ( ! in_array( $name, $loaded_langs, true ) ) {
     387                                                                $path = str_replace( content_url(), '', $plugurl );
     388                                                                $path = WP_CONTENT_DIR . $path . '/langs/';
     389
     390                                                                if ( function_exists('realpath') )
     391                                                                        $path = trailingslashit( realpath($path) );
     392
     393                                                                if ( @is_file( $path . $mce_locale . '.js' ) )
     394                                                                        $strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n";
     395
     396                                                                if ( @is_file( $path . $mce_locale . '_dlg.js' ) )
     397                                                                        $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n";
     398
     399                                                                if ( 'en' != $mce_locale && empty( $strings ) ) {
     400                                                                        if ( @is_file( $path . 'en.js' ) ) {
     401                                                                                $str1 = @file_get_contents( $path . 'en.js' );
     402                                                                                $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n";
     403                                                                        }
     404
     405                                                                        if ( @is_file( $path . 'en_dlg.js' ) ) {
     406                                                                                $str2 = @file_get_contents( $path . 'en_dlg.js' );
     407                                                                                $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n";
     408                                                                        }
     409                                                                }
     410
     411                                                                if ( ! empty( $strings ) )
     412                                                                        $ext_plugins .= "\n" . $strings . "\n";
    390413                                                        }
     414
     415                                                        $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
     416                                                        $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
    391417                                                }
    392418                                        }
    393419                                }