Make WordPress Core


Ignore:
Timestamp:
01/08/2025 12:52:04 PM (22 months ago)
Author:
swissspidy
Message:

I18N: Mail: Make PHPMailer messages translatable.

Adds a new WP_PHPMailer class to leverage the WordPress i18n system with PHPMailer, so that any user-visible error messages can be properly translated.

Props sukhendu2002, swissspidy, audrasjb, iandunn, nacin, mark-k.
Fixes #23311.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-locale-switcher.php

    r57350 r59592  
    274274         *
    275275         * @global WP_Locale $wp_locale WordPress date and time locale object.
     276         * @global PHPMailer\PHPMailer\PHPMailer $phpmailer
    276277         *
    277278         * @param string $locale The locale to change to.
    278279         */
    279280        private function change_locale( $locale ) {
    280                 global $wp_locale;
     281                global $wp_locale, $phpmailer;
    281282
    282283                $this->load_translations( $locale );
    … …  
    285286
    286287                WP_Translation_Controller::get_instance()->set_locale( $locale );
     288
     289                if ( $phpmailer instanceof WP_PHPMailer ) {
     290                        $phpmailer->SetLanguage();
     291                }
    287292
    288293                /**
Note: See TracChangeset for help on using the changeset viewer.