DeutschEnglish

Submenu

 - - - By CrazyStat - - -

15. February 2012

WordPress: Frontend and Backend in different Language

Filed under: Wordpress — Tags: , , , , , — Christopher Kramer @ 23:45

In case you want to use a different language for the wordpress frontend (your blog) and the backend (admin panel), here is a tip how it can be done.

Step 1: Set frontend language

Configure the language of WordPress for the language you want your frontend in. You do this in wp_config.php using the constant WPLANG:

define ('WPLANG', '');

This unsets the language, meaning the frontend will be English. This also works if you use a localized version of wordpress. If you want to set another language, do so:

define ('WPLANG', 'de_DE');

This would set the language to German. You need to have a corresponding .mo-file in wp-content/languages (in this example, wp-content/languages/de_DE.mo).

Step 2: Set the backend language

Step one will also affect the backend. If you want to have the backend in another language, there is a neat little plugin which changes the backend language for you, which I found on this forum.

<?php
/*
Plugin Name: Change backend language
Version: 0.5
Plugin URI: http://forum.wordpress-deutschland.org/konfiguration/32642-frontend-soll-englisch-sein-adminbereich-deutsch-engl-od-deut-download-nehmen.html
Description: Changes the backend language
Author: Oliver Schlöbe
Author URI: http://www.schloebe.de/
*/

function os_setAdminLang($locale) {
    if( WP_ADMIN === true ) {
        $locale = 'de_DE';
        return $locale;
    }
}

add_filter('locale', 'os_setAdminLang', 1, 1);
?>

This changes the backend language to German. In case you want another language, change ‘de_DE’ to the desired language in line 13. You need a corresponding .mo-file just like for the frontend.

Save this as something like wp-content/plugins/change_be_language.php

Then active the plugin in your backend and your backend will turn into the language you set.

Attention: Make sure there are no extra spaces in the plugin-file. Especially at the end, some editors tend to add spaces or line breaks. This will result in problems (headers cannot be sent etc.).

Hope someone finds this useful.

Update: Just found out, that the author wrote a blog post himself about this (English text at the bottom of the page)…

Recommendation

Try my Open Source PHP visitor analytics script CrazyStat.

6 Comments »

  1. Hi,

    I have integrated this plugin in my site, and I see the whole code in my site’s header. Can you help me out?

    Comment by mmmhussein — 28. February 2013 @ 14:50

  2. @mmmhussein:
    1. Make sure you don’t have any extra spaces or other things before “” in change_be_language.php
    2. make sure the file extension is “.php”
    3. Make sure and ?> are written exactly like this
    UPDATE: WordPress inserts spaces in this comment. There should be no space between < and ?php! Maybe I should upload the file for convenience. I hope this solves your problem. Please let me know whether it does. Greetings, Christopher

    Comment by Christopher Kramer — 28. February 2013 @ 18:22

  3. Thank you so much, it still works like a charm!

    Comment by Elf — 23. April 2013 @ 13:04

  4. I have seen it in several places,
    But it doesnt work for me
    I want my backend to en_US and front end to fa_IR
    but it changes both front and backend languages to English

    Comment by ahmad — 9. April 2014 @ 13:38

  5. I solved my problem by following code

    function os_setAdminLang($locale) {
    if( WP_ADMIN === true ) {
    $locale = ‘en_US’;
    }
    else {
    $locale = ‘fa_IR’;
    }
    return $locale;
    }

    add_filter(‘locale’, ‘os_setAdminLang’, 1, 1);

    Comment by ahmad — 9. April 2014 @ 13:50

  6. Thank you! Saved my day!

    Comment by Kirill — 17. February 2018 @ 10:34

RSS feed for comments on this post. TrackBack URL

Leave a comment