Skip to content
Docs
Get RestroPress

Filter

plugin_locale

Updated
On this page

Filters the locale used when loading RestroPress translation files.

This is the standard WordPress plugin_locale filter, applied by RestroPress::load_textdomain with the text domain restropress. It is applied twice: once to the site locale from get_locale() and once to the user locale from determine_locale() when that function exists. The returned locales decide which restropress-{locale}.mo or .l10n.php files are searched for.

Parameters#

ParameterTypeDescription
$valuestringThe locale being filtered, for example en_US. The first call passes the site locale and the second call passes the determined user locale.
$arg2stringThe text domain, always restropress here.

Return value#

string. The locale to load translations for.

Example#

function my_force_restropress_locale( $locale, $domain ) {
	if ( 'restropress' === $domain ) {
		return 'fr_FR';
	}
	return $locale;
}
add_filter( 'plugin_locale', 'my_force_restropress_locale', 10, 2 );

Notes#

Core WordPress hook that other plugins also use. Always check the second argument before changing the value. RestroPress fires it from two call sites, one for the site locale and one for the user locale.

Source#

Applied in:

  • includes/class-rpress.php (line 405), in RestroPress::load_textdomain()
  • includes/class-rpress.php (line 406), in RestroPress::load_textdomain()

See also#

Was this page helpful?