You are here

public function PhpMailerSmtp::setLanguage in PHPMailer SMTP 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Mail/PhpMailerSmtp.php \Drupal\phpmailer_smtp\Plugin\Mail\PhpMailerSmtp::setLanguage()
  2. 2.0.x src/Plugin/Mail/PhpMailerSmtp.php \Drupal\phpmailer_smtp\Plugin\Mail\PhpMailerSmtp::setLanguage()
  3. 2.1.x src/Plugin/Mail/PhpMailerSmtp.php \Drupal\phpmailer_smtp\Plugin\Mail\PhpMailerSmtp::setLanguage()

Provide more user-friendly error messages.

Note: messages should not end with a dot.

File

src/Plugin/Mail/PhpMailerSmtp.php, line 268

Class

PhpMailerSmtp
Implements the base PHPMailer SMTP class for the Drupal MailInterface.

Namespace

Drupal\phpmailer_smtp\Plugin\Mail

Code

public function setLanguage($langcode = 'en', $lang_path = 'language/') {

  // Retrieve English defaults to ensure all message keys are set.
  parent::SetLanguage('en');

  // Overload with Drupal translations.
  $this->language = [
    'authenticate' => $this
      ->t('SMTP error: Could not authenticate.'),
    'connect_host' => $this
      ->t('SMTP error: Could not connect to host.'),
    'data_not_accepted' => $this
      ->t('SMTP error: Data not accepted.'),
    'smtp_connect_failed' => $this
      ->t('SMTP error: Could not connect to SMTP host.'),
    'smtp_error' => $this
      ->t('SMTP server error:'),
    // Messages used during email generation.
    'empty_message' => $this
      ->t('Message body empty'),
    'encoding' => $this
      ->t('Unknown encoding:'),
    'variable_set' => $this
      ->t('Cannot set or reset variable:'),
    'file_access' => $this
      ->t('File error: Could not access file:'),
    'file_open' => $this
      ->t('File error: Could not open file:'),
    // Non-administrative messages.
    'from_failed' => $this
      ->t('The following From address failed:'),
    'invalid_address' => $this
      ->t('Invalid address'),
    'provide_address' => $this
      ->t('You must provide at least one recipient e-mail address.'),
    'recipients_failed' => $this
      ->t('The following recipients failed:'),
  ] + $this->language;
  return TRUE;
}