EllisLab text mark
Advanced Search
     
i18n library and google bot
Posted: 29 August 2011 08:21 PM
Joined: 2011-01-10
3 posts

I am currently using internationalization i18n library but…
Their is a error when google bot fetches your page it will give a php error

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<
h4>A PHP Error was encountered</h4>

<
p>SeverityWarning</p>
<
p>Message:  array_key_exists(): The first argument should be either a string or an integer</p>
<
p>Filenamecore/MY_Lang.php</p>
<
p>Line Number153</p>

</
div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<
h4>A PHP Error was encountered</h4>

<
p>SeverityWarning</p>
<
p>Message:  array_key_exists(): The first argument should be either a string or an integer</p>
<
p>Filenamecore/MY_Lang.php</p>
<
p>Line Number153</p>

</
div

maybe because google bot is not a browser : )
How to config lang for bots? Please help me :S

 
Posted: 30 August 2011 09:39 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2008-10-14
57 posts

I have modified the

function default_lang()
    
{
       
return array_shift(array_keys($this->languages));
    

function to use only the first language in languages array, not to ask for the browser language settings…

or

function default_lang()
    
{
        $browser_lang 
= !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ',') : '';
        
$browser_lang substr($browser_lang0,2);
        
        if ( !
$browser_lang {
        
return array_shift(array_keys($this->languages));
        
}
        
else {
        
return (array_key_exists($browser_lang$this->languages)) ? $browser_langarray_shift(array_keys($this->languages));
        
}
    } 


if you would like to keep this feature.

 
Posted: 30 August 2011 04:55 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-01-10
3 posts
Stoney - 30 August 2011 01:39 PM

I have modified the

function default_lang()
    
{
       
return array_shift(array_keys($this->languages));
    

function to use only the first language in languages array, not to ask for the browser language settings…

or

function default_lang()
    
{
        $browser_lang 
= !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ',') : '';
        
$browser_lang substr($browser_lang0,2);
        
        if ( !
$browser_lang {
        
return array_shift(array_keys($this->languages));
        
}
        
else {
        
return (array_key_exists($browser_lang$this->languages)) ? $browser_langarray_shift(array_keys($this->languages));
        
}
    } 


if you would like to keep this feature.

10x smile

 
Posted: 10 October 2011 05:24 AM   [ # 3 ]   [ Rating: 0 ]
Joined: 2011-08-06
120 posts

Thanks this works great with Tor and sites like anonymous.org too. wink

Before this change I was getting php errors when using Tor browser or accessing my site from anonymous.org.

I suggest to include this modification into the original code of i18n library.

 
Posted: 22 February 2012 01:55 PM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2010-07-20
2 posts

How does these changes affect the search engine friendliness? If I curl my site without the changes I get an PHP error (really ugly) if I add the changes I get nothing back. It doesn’t seem very google friendly to me :-(

Do you guys know if any modification to load the home page with it’s links with all the links, metatags, html tags wink

 
Posted: 22 March 2012 09:48 AM   [ # 5 ]   [ Rating: 0 ]
Joined: 2012-01-08
25 posts

I had the same php error issue

now with the modification (on webmaster tools google)
I do a fetch as google bot I have

HTTP/1.1 302 Moved Temporarily
Set-Cookie: 90plan=R3938748381; path=/; expires=Sun, 25-Mar-2012 02:05:58 GMT
Date: Thu, 22 Mar 2012 13:45:53 GMT
Server: Apache/2.2.X (OVH)
X-Powered-By: PHP/5.2.17
Location: http://www.mysite.com/en/home
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html


I don’t think a 302 is correct for the home page right?