Alert: 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.

WP_Locale_Switcher::load_translations() WordPress Method

The WP_Locale_Switcher::load_translations() method is used to load translation files for the current user's locale. This is useful for plugins and themes that need to be translated into the user's language.

WP_Locale_Switcher::load_translations( string $locale ) #

Load translations for a given locale.


Description

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


Top ↑

Parameters

$locale

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


Top ↑

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 );
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.