WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

PHPMailer\PHPMailer

PHPMailer::setLanguage() public WP 1.0

Set the language for error messages. Returns false if it cannot load the language file. The default language is English.

{} Это метод класса: PHPMailer{}

Хуков нет.

Возвращает

true/false.

Использование

$PHPMailer = new PHPMailer();
$PHPMailer->setLanguage( $langcode, $lang_path );
$langcode(строка)
ISO 639-1 2-character language code (e.g. French is "fr")
По умолчанию: 'en'
$lang_path(строка)
Path to the language file directory, with trailing separator (slash)
По умолчанию: ''

Код PHPMailer::setLanguage() WP 5.5.1

<?php
public function setLanguage($langcode = 'en', $lang_path = '')
{
    // Backwards compatibility for renamed language codes
    $renamed_langcodes = [
        'br' => 'pt_br',
        'cz' => 'cs',
        'dk' => 'da',
        'no' => 'nb',
        'se' => 'sv',
        'rs' => 'sr',
        'tg' => 'tl',
        'am' => 'hy',
    ];

    if (isset($renamed_langcodes[$langcode])) {
        $langcode = $renamed_langcodes[$langcode];
    }

    // Define full set of translatable strings in English
    $PHPMAILER_LANG = [
        'authenticate' => 'SMTP Error: Could not authenticate.',
        'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
        'data_not_accepted' => 'SMTP Error: data not accepted.',
        'empty_message' => 'Message body empty',
        'encoding' => 'Unknown encoding: ',
        'execute' => 'Could not execute: ',
        'file_access' => 'Could not access file: ',
        'file_open' => 'File Error: Could not open file: ',
        'from_failed' => 'The following From address failed: ',
        'instantiate' => 'Could not instantiate mail function.',
        'invalid_address' => 'Invalid address: ',
        'invalid_hostentry' => 'Invalid hostentry: ',
        'invalid_host' => 'Invalid host: ',
        'mailer_not_supported' => ' mailer is not supported.',
        'provide_address' => 'You must provide at least one recipient email address.',
        'recipients_failed' => 'SMTP Error: The following recipients failed: ',
        'signing' => 'Signing Error: ',
        'smtp_connect_failed' => 'SMTP connect() failed.',
        'smtp_error' => 'SMTP server error: ',
        'variable_set' => 'Cannot set or reset variable: ',
        'extension_missing' => 'Extension missing: ',
    ];
    if (empty($lang_path)) {
        // Calculate an absolute path so it can work if CWD is not here
        $lang_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR;
    }
    //Validate $langcode
    if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) {
        $langcode = 'en';
    }
    $foundlang = true;
    $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
    // There is no English translation file
    if ('en' !== $langcode) {
        // Make sure language file path is readable
        if (!static::isPermittedPath($lang_file) || !file_exists($lang_file)) {
            $foundlang = false;
        } else {
            // Overwrite language-specific strings.
            // This way we'll never have missing translation keys.
            $foundlang = include $lang_file;
        }
    }
    $this->language = $PHPMAILER_LANG;

    return (bool) $foundlang; // Returns false if language not found
}