8

I use an English WordPress package and this is very well.

Now, I would like to translate some elements of the blog (like "posted on", "comments") etc., but do leave the dashboard interface intact in English.

Is there any mechanism to translate just the site elements?

migrated from serverfault.com Aug 27 '11 at 17:07

This question came from our site for system and network administrators.

18

You can do the following:

  1. Get the the language pack (e.g. de_DE.mo) from wordpress.org. If the language pack isn't available as a standalone download, you could also use the .mo file which is bundled in the WordPress ZIP-file for your language. Located under wp-content/languages.
  2. Move the .mo file to wp-content/languages/ of your default (english) WordPress installation.
  3. Change the WPLANG constant in wp-config.php to the new locale (e.g. de_DE)
  4. In your functions.php add the following filter:

functions.php

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

    return $locale;
}
  • now, what do you mean by "install your language pack"? should I uninstall the wordpress, and install the new wordpress, but say French? I don't want to uninstall my English wordpress. – serhio Sep 2 '11 at 15:01
  • 1
    No, you don't have to reinstall anything. Just download WP in your desired language an copy the language file from wp-content/languages/ to your original english WP install and modify wp-config.php as described above. Or just download the fr_FR.mo file from this site. – rofflox Sep 2 '11 at 15:05
  • I had not the wp-content/languages/ folder, so I should create it. After performing that manipulation, I has the vice-versa of what I would. I have now the admin panel in Romanian, but the page (even logged or not) - in English. Perhaps I should translate the theme... – serhio Sep 7 '11 at 9:00
  • Of course, you need the theme translated. But the backend should be in English not Romanian if you set is_admin() in the filter above. – rofflox Sep 7 '11 at 9:16
  • I added this code at the end of the functions.php file of the current (twenty ten) theme... Is that correct? – serhio Sep 7 '11 at 16:58
6

You can use plugins for that: http://wordpress.org/extend/plugins/kau-boys-backend-localization/ or http://wordpress.org/extend/plugins/wp-native-dashboard/

  • 1
    Welcome to our site. Please add an explanation: What do these plugins, what are the differences? – fuxia Oct 6 '12 at 14:39
  • 1
    I think there are doing exactly the same. (I just use the first one...) You can install different language files and with the plugins you can change the language for the backend independently. Both plugins provide Dashboard switches for the language, a login language select box and an add-on to the profile page for user-specific language. – zodiac1978 Oct 8 '12 at 6:34
2

An updated answer for Wordpress 4+

@rofflox's answer is still correct, but there have been some changes to Wordpress that can have an effect when using his function 'as-is' since WP 4.0.

The wp-config constant WPLANG has been deprecated in favour of setting the site language via a dropdown in Settings->General. This means that, after changing your site's language to Svenka (for example), your site's admin will appear in English... but that Site Language dropdown in Settings->General will be pre-selected as English (United States). That means that, if you make changes to your General settings later on and forget to pick Svenka as your site's language again, the whole site will revert back to English.

I would recommend creating functions in your functions.php file like so:

//    Set the locale; original function from @rofflox

function vnmFunctionality_setLocale($locale) {
    if (is_admin()) {
        return 'en_US';
    }

    return $locale;
}

add_filter('locale', 'vnmFunctionality_setLocale');

// Enqueue a script to force-set the Language dropdown on the General Options page, just in case we forget about it later.

function vnmFunctionality_countryReminderScript($hook) {
    if ($hook != 'options-general.php') {
        return;
    }

    wp_enqueue_script('lang-reminder-script', get_template_directory() . '/js/site-language.js', array('jquery'), '1.0.0', true);

    wp_localize_script('lang-reminder-script', 'langObject', array(
        'lang'  => get_option('WPLANG'),
    ));
}

add_action('admin_enqueue_scripts', 'vnmFunctionality_countryReminderScript');

And then a Javascript file called site-language.js (saved in a /js/ folder in your theme) like so:

jQuery(document).ready(function($) {
    $('select#WPLANG').val(langObject.lang).change();
});

This should automatically pre-select the site's current display language in the dropdown on the Options page, so that you don't have to remember to do it manually every time.

2

Since WordPress version 4.7, different Backend users can set their own preferred admin language using the native WordPress language selector. This way, they see the WordPress interface in their language and can more easily manage content. Different language for Backend users in Wordpress independent of the Frontend language

1

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.

0

In the WordPress 5.x it real simple to get a different frond and back end language

To change the site language go to Setting -> General -> Site Language and select the site language.

enter image description here

For the Admin Panel goto Users -> Your Profile and select the language you want to have on the Admin Panel

enter image description here

So all the above solutions have become absolute, each user can set their own language for the WordPress interface

-1

What you need is to translate your theme. If your theme has a .pot file then it is easy to translate. Just follow the steps at

http://www.appthemes.com/blog/how-to-translate-a-wordpress-theme/

Else, you will need to edit the theme files and change the words at each instance.

  • my theme (twenty ten) has the folder "wp-content/themes/twentyten/languages" and there are only a .pot file inside... – serhio Sep 7 '11 at 13:12

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.