WordPress.org

Make WordPress Core

Changeset 9353


Ignore:
Timestamp:
10/26/2008 07:32:58 AM (10 years ago)
Author:
azaozz
Message:

TinyMCE: attempt to load a translation file for external plugins, if not found, try en.js, fixes #7950

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r9119 r9353  
    10381038            include path to the file. The language file should follow the same format as
    10391039            /tinymce/langs/wp-langs.php and should define a variable $strings that
    1040             holds all translated strings. Example:
    1041             $strings = 'tinyMCE.addI18n("' . $mce_locale . '.mypluginname_dlg",{tab_general:"General", ... })';
     1040            holds all translated strings.
     1041            When this filter is not used, the function will try to load {mce_locale}.js.
     1042            If that is not found, en.js will be tried next.
    10421043            */
    10431044            $mce_external_languages = apply_filters('mce_external_languages', array());
     
    10621063                $plugins[] = '-' . $name;
    10631064       
    1064                 if ( in_array($name, $loaded_langs) ) {
    1065                     $plugurl = dirname($url);
    1066                     $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
     1065                $plugurl = dirname($url);
     1066                $strings = '';
     1067                if ( ! in_array($name, $loaded_langs) ) {
     1068                    $plugpath = str_replace( WP_PLUGIN_URL, '', $plugurl );
     1069                    $plugpath = WP_PLUGIN_DIR . $plugpath;
     1070
     1071                    if ( function_exists('realpath') )
     1072                        $plugpath = realpath($plugpath);
     1073
     1074                    $path = $plugpath . '/langs/' . $mce_locale . '.js';
     1075                    $path2 = $plugpath . '/langs/en.js';
     1076
     1077                    if ( is_file($path) && is_readable($path) ) {
     1078                        $strings = @file_get_contents($path);
     1079                    } elseif ( 'en' != $mce_locale && is_file($path2) && is_readable($path2) ) {
     1080                        $strings = @file_get_contents($path2);
     1081                        $strings = preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $strings, 1 );
     1082                    }
     1083
     1084                    if ( $strings )
     1085                        $ext_plugins .= "\n" . $strings . "\n";
    10671086                }
     1087
     1088                $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
    10681089                $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
    10691090            }
    10701091        }
    10711092    }
    1072    
     1093
    10731094    $plugins = implode($plugins, ',');
    10741095   
     
    11261147        'save_callback' => 'switchEditors.saveCallback',
    11271148        'wpeditimage_disable_captions' => $no_captions,
    1128         'plugins' => "$plugins",
    1129         'strict_loading_mode' => true
     1149        'plugins' => "$plugins"
    11301150    );
    11311151   
     
    11421162    $language = $initArray['language'];
    11431163
    1144     $ver = apply_filters('tiny_mce_version', '200');
    1145 /*
    1146     foreach ( $initArray as $v )
    1147         $ver .= $v;
    1148    
    1149     if ( ! empty($mce_external_plugins) ) {
    1150         foreach ( $mce_external_plugins as $n => $v )
    1151             $ver .= $n;
    1152     }
    1153    
    1154     $ver = md5( $ver );
    1155 
    1156    
    1157     // Use cached translations file if exists
    1158     $langs_file = ABSPATH . WPINC . '/js/tinymce/langs/wp-langs-' . $language . '.js';
    1159 
    1160     if ( is_file($langs_file) && is_readable($langs_file) ) {
    1161         if ( $ver != get_option('mce_refresh_check') ) {
    1162             @unlink($langs_file);
    1163             update_option('mce_refresh_check', $ver);
    1164         } else {
    1165             $lang = false;
    1166         }
    1167     }
    1168 */
     1164    $ver = apply_filters('tiny_mce_version', '3101');
     1165
    11691166    if ( 'en' != $language )
    11701167        include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php');
     
    12101207<script type="text/javascript" src="<?php echo $baseurl; ?>/tiny_mce.js?ver=<?php echo $ver; ?>"></script>
    12111208<?php if ( 'en' == $language ) { ?>
    1212     <script type="text/javascript" src="<?php echo $baseurl; ?>/langs/wp-langs-<?php echo $language; ?>.js?ver=<?php echo $ver; ?>"></script>
     1209    <script type="text/javascript" src="<?php echo $baseurl; ?>/langs/wp-langs-en.js?ver=<?php echo $ver; ?>"></script>
    12131210<?php } ?>
    12141211<script type="text/javascript">
    1215 
    12161212<?php if ( 'en' != $language && isset($lang) ) echo $lang; ?>
     1213
    12171214<?php if ( $ext_plugins ) echo $ext_plugins; ?>
    12181215   
Note: See TracChangeset for help on using the changeset viewer.