5

I have installed a wordpress theme, i can see the .mo and .po /public_html/wp-content/themes/themename/lang, the language I want to use is available.

Could you please advise on how to use a specific language? I don't want to change the admin language just the theme language.

3

I think that your simplest option would be to update your installation using the localized version of WordPress for your native language (and making sure that WPLANG remains set accordingly), and then to use a plugin such as:

... in order to switch just the admin interface to English.

3

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.

3

You can filter the string for locale, it holds the current language. And you can exclude the admin from that filter:

is_admin() or add_filter( 'locale', function() {
    return 'ar';
});
  • Actually, I mean how can i activate a specific language for the theme? – Hicham Feb 8 '14 at 11:56
  • This happens automatically when locale matches an existing translation file. – fuxia Feb 8 '14 at 11:57
  • sorry for bothering as i'm new to WP, but how can i make locale match the translation file? – Hicham Feb 8 '14 at 11:57
  • By adding the code above to a plugin or your theme’s functions.php. – fuxia Feb 8 '14 at 11:58
  • i have to enter then ar-AR for my theme to be in arabic? – Hicham Feb 8 '14 at 12:01
1

Well, you actually do not need anything special to have two different languages in the back end and in the front end. I just tested it again on WP 5.1

  1. go to the settings and set the Site Language to the front end laguage, for example - German, then save.

  2. go to Users and then click edit on your administrator account. There you can set Language to English and save. That's it. Your front end will use German as base and the back end will be in English.

0

You can also try this:

1.Download jquery translate script from this link

2.How it works ( doc, live test )

<?php
function ravs_frontend_translate_script() {
    wp_enqueue_script( 'translate', get_template_directory_uri() . '/js/jquery.translate.js', array( 'jquery' ), '0.0.1', true );
}
add_action( 'wp_enqueue_scripts', 'ravs_frontend_translate_script' );


function ravs_translate_webpage_fx(){
?>
<script>
    // run script after both script load for translate webpage
        jQuery(document).ready(function(){
          //from english to german:
          jQuery('body').translate( 'ar' );
        });
</script>
<?php
add_action('wp_footer','ravs_translate_webpage_fx', 999 ); // make sure this hook run after jquery-translate include in webpage
  • 2
    But that's using Google to translate the page isn't it, not using the .po files he already has? – Rup Feb 12 '14 at 18:26
  • @Rup Yes it is using google traslator not .po file. May be this is possible that .po file not contain translation for a random word then _e() simple echo it while google translator convert whole webpage. – Ravinder Kumar Feb 12 '14 at 18:52

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.