The plugins_update_check_locales WordPress PHP filter allows you to modify the locales requested for plugin translations.
Usage
add_filter('plugins_update_check_locales', 'your_custom_function');
function your_custom_function($locales) {
// your custom code here
return $locales;
}
Parameters
$locales: string[] – An array of plugin locales. Default is all available locales of the site.
More information
See WordPress Developer Resources: plugins_update_check_locales
Examples
Limiting Locales to English and Spanish
Only request translations for English (en_US) and Spanish (es_ES) locales.
add_filter('plugins_update_check_locales', 'limit_locales_to_english_spanish');
function limit_locales_to_english_spanish($locales) {
$locales = array('en_US', 'es_ES');
return $locales;
}
Adding French Locale
Add French (fr_FR) locale to the existing locales for plugin translations.
add_filter('plugins_update_check_locales', 'add_french_locale');
function add_french_locale($locales) {
$locales[] = 'fr_FR';
return $locales;
}
Removing a Specific Locale
Remove German (de_DE) locale from the plugin translations.
add_filter('plugins_update_check_locales', 'remove_german_locale');
function remove_german_locale($locales) {
$index = array_search('de_DE', $locales);
if ($index !== false) {
unset($locales[$index]);
}
return $locales;
}
Using a Custom List of Locales
Use a custom list of locales for plugin translations.
add_filter('plugins_update_check_locales', 'use_custom_locales_list');
function use_custom_locales_list($locales) {
$locales = array('en_US', 'es_ES', 'fr_FR', 'it_IT', 'pt_BR');
return $locales;
}
Clearing All Locales
Remove all locales from plugin translations.
add_filter('plugins_update_check_locales', 'clear_all_locales');
function clear_all_locales($locales) {
$locales = array();
return $locales;
}