You can leverage this hook to force the language of your admin dashboard, however, you need to call it from a plugin and not from your theme, by the time WordPress gets to loading your theme it’s too late.
<?php
/*
Plugin Name: English Only Admin
Plugin URI: https://your-domain.com
Description: Force English (en_US) in the WordPress Admin
Version: 1.0
Author: You
Author URI: https://your-domain.com
Text Domain: englishonlyadmin
*/
// prevent direct access
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! function_exists( 'uniquePrefix_force_english_only_admin' ) ) {
/**
* Override locale for admin to force English (en_US).
*
* @param string $locale Current locale.
*
* @return string English (en_US) locale if in Admin, configured locale otherwise.
*/
function uniquePrefix_force_english_only_admin( $locale ) {
// detect when we are in the admin dashboard and force english
if ( is_admin() ) {
$locale = 'en_US';
}
return $locale;
}
add_filter( 'locale', 'uniquePrefix_force_english_only_admin', 1, 1 );
}
You can leverage this hook to force the language of your admin dashboard, however, you need to call it from a plugin and not from your theme, by the time WordPress gets to loading your theme it’s too late.
Example migrated from Codex:
An example of changing the locale language based on the $_GET parameter of the URL.