W3cubDocs

/WordPress

WP_Locale_Switcher::load_translations( string $locale )

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Load translations for a given locale.

Description

When switching to a locale, translations for this locale must be loaded from scratch.

Parameters

$locale

(string) (Required) The locale to load translations for.

Source

File: wp-includes/class-wp-locale-switcher.php

private function load_translations( $locale ) {
		global $l10n;

		$domains = $l10n ? array_keys( $l10n ) : array();

		load_default_textdomain( $locale );

		foreach ( $domains as $domain ) {
			if ( 'default' === $domain ) {
				continue;
			}

			unload_textdomain( $domain );
			get_translations_for_domain( $domain );
		}
	}

Changelog

Version Description
4.7.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_locale_switcher/load_translations