apply_filters( 'locale', string $locale )

Filters the locale ID of the WordPress installation.


Parameters Parameters

$locale

(string) The locale ID.


Top ↑

Source Source

File: wp-includes/l10n.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by surrealwebs

    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: http://your-domain.com
    Description: Force English (en_US) in the WordPress Admin
    Version: 1.0
    Author: You
    Author URI: http://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 must log in before being able to contribute a note or feedback.