WP_Locale_Switcher::load_translations( string $locale )

In this article

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

$localestringrequired
The locale to load translations for.

Source

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

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

	load_default_textdomain( $locale );

	foreach ( $domains as $domain ) {
		// The default text domain is handled by `load_default_textdomain()`.
		if ( 'default' === $domain ) {
			continue;
		}

		/*
		 * Unload current text domain but allow them to be reloaded
		 * after switching back or to another locale.
		 */
		unload_textdomain( $domain, true );
		get_translations_for_domain( $domain );
	}
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.