9

I'd like to have the backend of Wordpress in English and use a different locale for the frontend

so far I figure out perhaps I could do it by setting in the wpconfig the locale I want to use in the frontend, then add in functions.php something like this:

add_filter('locale', 'mytheme_backendlocale');
function mytheme_backendlocale($locale) {
    if ( is_admin() ) {
        return 'en_US';
    }
    return $locale;
}

is this the best practice to achieve what I want or should I do it differently?

2

Install the plugin WP Native Dashboard. Then you can set one language for the front-end in your wp-config.php and each user can choose another one for the back-end.
See Change language of comments template for details and a screenshot.

1

There is a plugin that may be what you need.

http://wordpress.org/extend/plugins/fe-be-localization/

  • well thanks, I'll give a look to the code, but maybe won't use it since it's not updated since 2008 and supports up to WP 2.6 only - if I like it and have the ability maybe will try to talk to the developer and update it – unfulvio Nov 1 '11 at 11:03
  • oh just checked, it does pretty much the same as the function I wrote above, in another style – unfulvio Nov 1 '11 at 11:04
  • Yeah, its old, but seems the only one around. If the code is how you have done it, then I guess the answer is you are on the correct track and its how I would have done it.. cant think of a better way. – Andy James Nov 1 '11 at 11:06
1

Till now, I think that Fulvio's answer's the best one. I'm using that filter even on a multisite setup, with just one line:

add_filter('locale', 'set_admin_locale');
function set_admin_locale($locale) {
  return 'en_US';
}

Basically sometimes, and in this case, I use multisite for multi-language sites instead of plugins. Also, I have 1 single theme for each language (usually child themes of the main language). So every site of the network has its own language, but on the admin side, I need all teh interfaces in italian.

So what I do is:

  1. I don't use the general WPLANG constant in wp-config.php
  2. I set italian in every site of teh network
  3. In each theme's functions.php I use the above filter to control the frontend language/locale.

NOTE: that filter won't change the admin language, so there's no need to check if is_admin()

0

If anyone is still looking for that, here is what you should do since version 4.7

function wp_noshor_redefine_locale($locale) {
    if( is_admin() ):
        switch_to_locale('en_US');
    endif;
}
add_filter('init','wp_noshor_redefine_locale');

This forces the dashboard to load in English, then you can go to settings, set the language you desire.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.