WordPress in other languages

I would like to set WordPress theme to be in a language other than English, but I would like to keep the control panel of WordPress in English. How do I accomplish that?

Changing define('WPLANG', ''); in wp-config.php would not help, as it will change the language for the control panel as well.

Read More

I am not interested in a plugin, all I need is set the language for the theme, but not the control panel.

Thanks.

Related posts

Leave a Reply

2 comments

  1. Here’s an example, front end will be Dutch, back end default English:

    if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) === false ) :
        define( 'WPLANG', 'nl_NL' );
    else :
        define( 'WPLANG', '' );
    endif;
    

    UPDATE

    WordPress 4.0 deprecated the WPLANG constant (link). The site language is set from the admin panel: Settings -> General -> Site Language.

    Developers can now modify the locale by defining the $locale global in wp-config.php, …

    if( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) === false ) :
        $locale = 'nl_NL';
    else :
        $locale = 'en_US';
    endif;
    

    … or with the locale filter:

    add_filter( 'locale', 'so16425245_filter_locale', 0, 1 );
    function so16425245_filter_locale( $locale )
    {
        if( strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) !== false )
            return 'en_US';
    
        return 'nl_NL';
    }
    

    See also Greeso’s answer with regard to admin AJAX.

  2. The answer by ‘diggy’ is great, and works most of the time. However it will not work in one situation:

    If you are using AJAX within WordPress, then $_SERVER['REQUEST_URI'] will contain wp-admin/admin-ajax.php even if you are at the site root (for example if you go to http://www.your-site.com, then $_SERVER['REQUEST_URI'] will return wp-admin/admin-ajax.php if you are using AJAX in that root page).

    Therefore, to work around this issue, you should modify the condition inspection to be as follows:

    if ( ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) === false ) || (strpos( $_SERVER['REQUEST_URI'], 'wp-admin/admin-ajax.php' ) !== false) ) :
        define( 'WPLANG', 'nl_NL' );
    else :
        define( 'WPLANG', '' );
    endif;
    

    Update

    For 4.0 and up, use the following

    if ( ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) === false ) || (strpos( $_SERVER['REQUEST_URI'], 'wp-admin/admin-ajax.php' ) !== false) ) :
        $locale = 'nl_NL';
    else :
        $locale = 'en_US';
    endif;