Welcome Guest, Not a member yet? Register   Sign In
One URL, multiple languages, SEO-friendly?
#1

[eluser]popovich[/eluser]
Hello and happy new year!

This site — wital. net (I'd like to have this discussion without google indexing it, hence no link) — there are threee languages in use, english, russian and german. A language is being set in a cookie (code follows) and when changing languages, the user will always see the same URL: the browser is pointed at a page .../in-{language}/, sets the language cookie and returns back, showing the contents of the page in the selected language. The thing is that the visitor doesn't see any processes, except for a different language on the screen.

Now, the problem is that Google and other search engines fail to index any other languages except for the default, which is English (naturally).

What am I doing wrong here? Should I implement a different method? The only objective is to leave the URL the same for any language used or still-to-come.

Thanks for the insight.

Here is the code:
Code:
function set_user_lang()
    {
        $this->GLO['user_lang_id'] = get_cookie('wiww_langid');
        $accept_lang = ( $this->agent->accept_lang() ) ? $this->agent->accept_lang() : "en";
        
        $q = "select * from lang_list where published='yes' order by priority asc;";
        $query = $this->db->query($q);
        
        $coo_lang_correct = false;
        
        foreach( $query->result() as $row ){
            $temp = array();
            $temp['id'] = $row->id;
            $temp['trigger'] = $row->do_trigger;
            $temp['label'] = $row->label;
            $temp['accept_code'] = $row->accept_code;
            $temp['default_lang'] = $row->default_lang;
            if($this->GLO['user_lang_id'] == $row->id ){
                 $coo_lang_correct = true;
                 $this->GLO['user_lang_label'] = $row->accept_code;
            }
            
            $this->GLO['langs'][] = $temp;
            
        }
        
        #    
        # if cookie is not correct,
        # search for accepted language
        #
        if( !$coo_lang_correct ){
            foreach ( $this->GLO['langs'] as $row ){
                if( strstr($accept_lang, $row['accept_code']) ){
                    $this->GLO['user_lang_id'] = $row['id'];
                    $this->GLO['user_lang_label'] = $row['accept_code'];
                    break;
                }
            }
        }
        
        # set default language
        foreach ( $this->GLO['langs'] as $row ){
            if( strstr('yes', $row['default_lang']) ){
                $this->GLO['def_lang_id'] = $row['id'];
                $this->GLO['def_lang_label'] = $row['accept_code'];
                break;
            }
        }
        
        
        #last try
        if ( !$this->GLO['user_lang_id'] ) {
            $this->GLO['user_lang_id'] = $this->GLO['def_lang_id'];
            $this->GLO['user_lang_label'] = $this->GLO['def_lang_label'];
        }
        
        # set cookies
        $this->do_cookie('wiww_langid', $this->GLO['user_lang_id']);
        $this->do_cookie('def_langid', $this->GLO['def_lang_id']);
                
    }

    function swap_lang(){
    
        $trigger = $this->uri->segment(1);
        
        if ( $pos = strpos($trigger, "in-") < 1 ){
            
            $pos = substr($trigger, 3);

            foreach ( $this->GLO['langs'] as $row) {
            
                if ( $row['trigger'] == $pos ){
                    $this->GLO['user_lang_id'] = $row['id'];
                    $this->do_cookie('wiww_langid', $this->GLO['user_lang_id']);
                    
                    if( $this->agent->is_referral() ){
                        if ( strstr($this->agent->referrer(), site_url()) ) {
                            return $this->agent->referrer();
                        } else {
                            return site_url();
                        }
                    }else{
                        return site_url();
                    }
                    
                }
            }
            
        }else{
        
            return false;
            
        }
    }
#2

[eluser]bitist[/eluser]
The issue could be that you have different content in same URLs.

Browsing in English the company page:
http://www.wital.net/company
Then changing to Deutsch on the same page:
http://www.wital.net/company
We got different content on same URL.

Somehow Google is able to detect that the page is in different language, but they are not able to provide this link:
http://www.wital.net/in-german
and then redirect to:
http://www.wital.net/company

You should use a language prefix in the url for not English language pages:
http://www.wital.net/de/company
#3

[eluser]popovich[/eluser]
This is the point — I'd be glad to stay with the same URL but to have the language (=content) selected on acccept-lang or cookie. And to make google index the content in all three languages.
It would be a pity if I had to re-write the code and change URLs for that.

My guess is that google detects ".../in-german" link only because I have manually added and submitted the sitemap with it. The XML-machine would not want to notice those links, actually.

Any ideas how to design the redirect, so the bots pay attention to it?
#4

[eluser]xwero[/eluser]
you could snoop the user agent and don't redirect for the bots but you still can do it for the all other user agents.
#5

[eluser]popovich[/eluser]
alright, but in the case of a bot I would have to pull out the contents in all languages, I guess. might get ugly here... or will it?
#6

[eluser]xwero[/eluser]
there must be some link where you switch the languages. So instead of redirecting to the no language segment url keep the url as it is for bots. I don't see how it could get ugly?
#7

[eluser]popovich[/eluser]
For a non-bot browser:
content english: wital.net/company
switch to german: wital.net/in-german
content in german: wital.net/company

For a bot browser:
content in english, german, russian & other still-to-come languages: wital.net/company

The ugly situation happens if the bot-check fails and dumps all languages in front of the eyes of a perplexed visitor.

Correct me if I am wrong.




Theme © iAndrew 2016 - Forum software by © MyBB