wppaste
WordPress

WP_PHPMailer::setLanguage( string $langcode = 'en', string $lang_path = '' ): true

Since
6.8.0
Source
wp-includes/class-wp-phpmailer.php:39
Defines the error messages using WordPress' internationalization method.

Compatibility

WordPress
since 6.8.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 4 of the 5 tracked releases, added in 6.8.0, and compiles on PHP 7.4 through 8.6-dev.

Parameters

$langcodestringoptional
Unused. ISO 639-1 2-character language code. Default 'en'.Default: 'en'
$lang_pathstringoptional
Unused. Path to the language file directory. Default empty string.Default: ''

Return value

true
Always returns true.

Performance profile

How much work a call to WP_PHPMailer::setLanguage() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
130

Executed per call on PHP 8.5. The body compiles to 130.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What one call costs · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_PHPMailer::setLanguage() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always130__(), __(), sprintf(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), sprintf()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 130 instructions, 130 executed per call, 0 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 1

  • __()Retrieves the translation of $text.

Source code

	public static function setLanguage( $langcode = 'en', $lang_path = '' ) {		static::$language = array(			'authenticate'         => __( 'SMTP Error: Could not authenticate.' ),			'buggy_php'            => sprintf(				/* translators: 1: mail.add_x_header. 2: php.ini */				__( 'Your version of PHP is affected by a bug that may result in corrupted messages. To fix it, switch to sending using SMTP, disable the %1$s option in your %2$s, or switch to MacOS or Linux, or upgrade your PHP version.' ),				'mail.add_x_header',				'php.ini'			),			'connect_host'         => __( 'SMTP Error: Could not connect to SMTP host.' ),			'data_not_accepted'    => __( 'SMTP Error: Data not accepted.' ),			'empty_message'        => __( 'Message body empty' ),			/* translators: There is a space after the colon. */			'encoding'             => __( 'Unknown encoding: ' ),			/* translators: There is a space after the colon. */			'execute'              => __( 'Could not execute: ' ),			/* translators: There is a space after the colon. */			'extension_missing'    => __( 'Extension missing: ' ),			/* translators: There is a space after the colon. */			'file_access'          => __( 'Could not access file: ' ),			/* translators: There is a space after the colon. */			'file_open'            => __( 'File Error: Could not open file: ' ),			/* translators: There is a space after the colon. */			'from_failed'          => __( 'The following From address failed: ' ),			'instantiate'          => __( 'Could not instantiate mail function.' ),			/* translators: There is a space after the colon. */			'invalid_address'      => __( 'Invalid address: ' ),			'invalid_header'       => __( 'Invalid header name or value' ),			/* translators: There is a space after the colon. */			'invalid_hostentry'    => __( 'Invalid host entry: ' ),			/* translators: There is a space after the colon. */			'invalid_host'         => __( 'Invalid host: ' ),			/* translators: There is a space at the beginning. */			'mailer_not_supported' => __( ' mailer is not supported.' ),			'provide_address'      => __( 'You must provide at least one recipient email address.' ),			/* translators: There is a space after the colon. */			'recipients_failed'    => __( 'SMTP Error: The following recipients failed: ' ),			/* translators: There is a space after the colon. */			'signing'              => __( 'Signing Error: ' ),			/* translators: There is a space after the colon. */			'smtp_code'            => __( 'SMTP code: ' ),			/* translators: There is a space after the colon. */			'smtp_code_ex'         => __( 'Additional SMTP info: ' ),			'smtp_connect_failed'  => __( 'SMTP connect() failed.' ),			/* translators: There is a space after the colon. */			'smtp_detail'          => __( 'Detail: ' ),			/* translators: There is a space after the colon. */			'smtp_error'           => __( 'SMTP server error: ' ),			/* translators: There is a space after the colon. */			'variable_set'         => __( 'Cannot set or reset variable: ' ),			'no_smtputf8'          => __( 'Server does not support SMTPUTF8 needed to send to Unicode addresses' ),			'imap_recommended'     => __( 'Using simplified address parser is not recommended. Install the PHP IMAP extension for full RFC822 parsing.' ),			/* translators: %s: $useimap */			'deprecated_argument'  => sprintf( __( 'Argument %s is deprecated' ), '$useimap' ),		); 		return true;	}

Changelog

Introduced in 6.8.0. 2 changes between 6.8.8 and 7.1.0.

  1. 6.8.8
  2. 6.9.7
  3. 7.0.4
  4. 7.1.0

Signature, return type and hooks compared across 4 parsed releases.

6.9.7
Parameter $langcode retyped from untyped to string.verified against source
6.9.7
Parameter $lang_path retyped from untyped to string.verified against source
6.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/class-wp-phpmailer.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.