Ticket #23311: 23311.diff

File 23311.diff, 2.0 KB (added by iandunn, 4 months ago)
  • wp-includes/l10n.php

     
    550550        } 
    551551 
    552552        return $languages; 
     553} 
     554 
     555/** 
     556 * Get the PHPMailer localization name that corresponds to a WordPress localization name 
     557 * 
     558 * PHPMailer's localizations naming scheme doesn't match WordPress', so this function helps to match them up. Typically, that just means 
     559 * converting to lowercase and using the first two characters of the WP name, but there are also exceptions that are handled. PHPMailer 
     560 * will check if the resulting filename actually exists, and default to English if it doesn't, so checking that is not necessary here. 
     561 *  
     562 * @since  
     563 * 
     564 * @param string $wp_lang A WordPress localization name. Defaults to the localization currently being used. 
     565 * @return string The corresponding PHPMailer localization name. 
     566 */ 
     567function get_phpmailer_localization( $wp_lang = WPLANG ) { 
     568        $wp_lang = strtolower( $wp_lang ); 
     569                 
     570        switch ( $wp_lang ) { 
     571                case 'cs_cz': 
     572                        $phpmailer_lang = 'cz'; 
     573                break; 
     574                 
     575                case 'da_dk': 
     576                        $phpmailer_lang = 'dk'; 
     577                break; 
     578                 
     579                case 'pt_br': 
     580                        $phpmailer_lang = 'br'; 
     581                break; 
     582                 
     583                case 'sv_se': 
     584                        $phpmailer_lang = 'se'; 
     585                break; 
     586                 
     587                case 'zh_ch': 
     588                        $phpmailer_lang = 'zh_ch'; 
     589                break; 
     590                         
     591                default: 
     592                        $phpmailer_lang = substr( $wp_lang, 0, 2 ); 
     593                break; 
     594        } 
     595         
     596        return $phpmailer_lang; 
    553597} 
     598 No newline at end of file 
  • wp-includes/pluggable.php

     
    225225                require_once ABSPATH . WPINC . '/class-phpmailer.php'; 
    226226                require_once ABSPATH . WPINC . '/class-smtp.php'; 
    227227                $phpmailer = new PHPMailer( true ); 
     228                $phpmailer->SetLanguage( get_phpmailer_localization(), apply_filters( 'mailer_language_directory', WP_CONTENT_DIR . '/languages/phpmailer/' ) ); 
    228229        } 
    229230 
    230231        // Headers