Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 10 replies, has 4 voices.

Last updated by Bruno 8 years ago.

Assigned support staff: Bruno.

Author Posts
June 7, 2013 at 7:19 am #133747

Serge

Ok, we are building a site, mainly for Chinese customers, so the default language when a customer (who is NOT logging in) must be in Chinese (simplified). There will be an english version of the site, but only few people will use it. We do NOT want to make Chinese customers (even those on VPN with US IP Addresses) have to switch from English to Chinese, we want Chinese to be default site.

On the back end the site needs to be 100% in English.

I have tried changing settings left and right and can not come up with the right combination.

Please advise

June 7, 2013 at 8:41 am #133780

Andreas Neuber
Supporter

Languages: English (English ) German (Deutsch )

Hi Serge,

I think I will quickly run a test to tell you more.

# Under "WPML > Languages > Edit languages" which "code" does your Chinese has?

# You are using a Chinese .mo file for your WordPress I assume. Could you sent it to me via email - andreas.n@onthegosystems.com

Thanks!

June 7, 2013 at 1:16 pm #133885

Serge

Thanks Andreas. I did not think this would be such a complicated issue.

June 7, 2013 at 5:35 pm #133982

Adriano

Dear Serge,

Is this issue resolved?

June 8, 2013 at 2:38 am #134071

Serge

NO - I see no posted solution!!!

PLEASE Help

June 10, 2013 at 9:52 pm #134494

Bruno

Dear Serge,

I'm Bruno and I'm handling this issue now.

First the default language should be in Chinese (WPML > Languages​​). Be sure that the Chinese language is the default.

When the user is logged in, he will see the content in English? Sorry, I did not understand that part: "so the default language when a customer (who is NOT logging in) must be in Chinese (simplified)".

If yes, we need to reset the language. See the example below. You must add this function in the functions.php file of your theme.

function wpml133747(){
	global $sitepress;

	//is WordPress dashboard, then it is displayed in english.
	if( is_admin() ) {
		$sitepress->switch_lang('en');
		return;
	}

	//User is not logged, then he should use the chinese language
	if( !is_user_logged_in() ) {
		$sitepress->switch_lang('zh-hans');
	} else {
		//User logged in, so let's show the English language.
		$sitepress->switch_lang('en');
	}
}
add_action('init', 'wpml133747', 99);

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Thank you.

June 20, 2013 at 1:53 am #137380

Serge

Sorry to be confusing, Bruno

Here is what is needed

Ok, so to clarify - when a user comes to the web site, the first language I want them to see is Chinese. They need to be able to switch to English too.

HOWEVER, when I or one of the admins logs in to the back end to edit the site, add new pages, etc, everything there (admin menus, etc) need to be in English

I do not seem to have any .mo files, but I did not think I needed them since I thought they were only for the back end (which would be in English)

Thanks for your help. I am happy to provide you with actual login into the site to test things out.

June 20, 2013 at 4:26 pm #137624

Bruno

Dear Serge,

I edited the function I had created above.

function wpml133747(){
	global $sitepress, $current_user;

	$query_string = !empty($_GET['lang']) ? true : false;
	
	//is admin, then it is displayed in english.
	if(is_admin() && $current_user->roles[0] == 'administrator'){
		
		$sitepress->switch_lang('en');
		return;

	} else {
		//if user does not use the lang switcher
		if(!$query_string) {

			if( !is_user_logged_in() ) {
				$sitepress->switch_lang('zh-hans');
			} else {
				$sitepress->switch_lang('en');
			}

		}

	}
}
add_action('init', 'wpml133747', 99);

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Thank you.

June 22, 2013 at 2:48 pm #138124

Serge

can I give you a login for the site and you see if it will work? I am not sure where the function goes and keep getting an error when switching to Chinese too.

Do not want to post login info here since it is open forum.

June 24, 2013 at 5:54 pm #138557

Bruno

Dear Serge,

I’ll send you a private email right now asking you for some private information that will help me debug this issue for you. Please check your email in a couple of minutes, and if you don’t get it, let me know so I can send it again.

Thanks.

June 28, 2013 at 1:15 pm #139844

Bruno

Dear Serge,

I created a simple plugin based on the above function. Please do not forget to delete this function to your functions.php file does not have a conflict. I'll send the file to your email. The file content is:

<?php
/**
 * Plugin Name: Fix Lang
 * Description: Redirects the language to Chinese.
 * Version: 0.1
 */
function wpml133747(){
    global $sitepress, $current_user;
 
    $query_string = !empty($_GET['lang']) ? true : false;
     
    //is admin, then it is displayed in english.
    if(is_admin() && $current_user->roles[0] == 'administrator'){
         
        $sitepress->switch_lang('en');
        return;
 
    } else {
        //if user does not use the lang switcher
        if(!$query_string) {
 
            if( !is_user_logged_in() ) {
                $sitepress->switch_lang('zh-hans');
            } else {
                $sitepress->switch_lang('en');
            }
 
        }
 
    }
}
add_action('init', 'wpml133747', 99);
?>

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Thank you.

The topic ‘[Closed] two languages - one default for backend, one for front end’ is closed to new replies.