Part of the EllisLab Network
   
 
referencement, best practices for multilanguage sites
Posted: 22 March 2008 07:35 AM   [ Ignore ]  
Research Assistant
RankRankRank
Total Posts:  663
Joined  08-26-2006

Hi,

For a multilanguage site I want to implement an automatic language attribution in the default controller. But I wonder whether my solution using the URL helper function redirect() will not perturb Google referencing the pages. I’ve already had bad
experiences using redirects (that was a HTML refresh, though).

My solution

class Front extends Controller{

    
function index()
    
{
        $langs 
$this->agent->languages();
        
        
// the critical part of it
        
redirect($langs[0]);
    
}
}
class En extends Controller {

    
function _remap()
    
{
        $lang 
'en';
        
        
$data['menu'$this->_menu($lang);
        
        
$this->load->view($this->html_template$data);
    
}
}
class Fr extends Controller {

    
function _remap()
    
{
        $lang 
'fr';
        
        
$data['menu'$this->_menu($lang);
        
        
$this->load->view($this->html_template$data);
    
}

The above gives me :
1. no routing required
2. I obtain short URLs www.site.com/fr/content, www.site.com/en/content
3. I need the language detection only in the front controller
4. Google has a 1:1 relation for address and content

Do You think that my solution will work out for the referencement?
Is there a risk that Google or any other motor will reject my site due to the redirect?
Do You have a better solution wink

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

Profile
 
 
Posted: 01 April 2008 10:24 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Avatar
Total Posts:  11
Joined  03-07-2008

Are you talking about Google’s translate engine?  Or Google’s search engine indexing each of the languages?  There shouldn’t be a problem with the search engine indexing.  However, if you are talking about using the translate engine, then read on.  (Your post wasn’t clear on which you were speaking of.)

Accessing Google’s translate engine without using the script snippet they provide is actually a violation of Google’s Terms of Service, and they can blacklist your site if you are caught.  This is pretty much the case with every free translation engine out there, as I have done extensive research on this.

Also, if your site requires the use of sessions, the sessions will be rendered useless when you call Google translate, or any other translate engine.

I had actually come up with a workaround for that and coded it into a nice class, however, further research into the issue revealed the legal issues that were involved.  Trust me, it isn’t worth it.

Here’s what I did, and what I recommend.  Hard code the language translations.  I set up a language file for each language I wanted the site to use.  All the views were templated with variables so that they could be replaced by the appropriate language.  If the site is using static data and is not depending on constantly changing user input that needs constant translation (like a wiki) then this is definitely the best route.  The translation sites will add between 3 and 10 seconds, sometimes more, to each page load.  Hard coding it makes it lightening fast.  Nobody likes to wait, and the wait could make people not want to visit the site.  It’s also best to use a professional translation.

 Signature 

Rhapdog
Freelance PHP Programmer

Profile
 
 
Posted: 03 April 2008 02:06 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
RankRankRank
Total Posts:  663
Joined  08-26-2006

I have all the strings of my site already translated. I am talking about Google’s search engine indexing. One of my clients had a HTML refresh installed and Google did not index it’s site, my guess because this kind of technique is also used by spam sites.

Since my new site will completely be based onto the redirect function (every visit of the home page is redirected to one of the languages) and I want the site and it’s content to be indexed by Google & Co., I want to be sure that it’ll work.

 Signature 

Die Wirklichkeit ist das, was übrig bleibt, wenn man aufgehört hat, daran zu glauben.

Profile
 
 
Posted: 03 April 2008 07:00 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Avatar
Total Posts:  11
Joined  03-07-2008

Redirects themselves are not considered by Google to be bad.  However, redirects within javascript generally are not detected by the search engine and it is best to duplicate them in a <noscript> tag. 

If you would like more information on exactly why Google removes sites from it’s indexing, read Google’s Webmaster Guidelines at http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=35769

You might also want to take a look at their section on redirects at http://www.google.com/support/webmasters/bin/answer.py?answer=66355

 Signature 

Rhapdog
Freelance PHP Programmer

Profile
 
 
Posted: 07 June 2010 09:34 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  32
Joined  08-05-2009

my solution for multi language app are:
- extend language helper for setting default language from config such as create function setLanguage() which is lang file as parameter.
- create language controller to select/change language which are lang code and current URI as parameter.

thats all.. smile

here are my code

for function setLanguage in language_helper. This function always load in every controller.

function setLanguage($lang_file='general'){
    $ci
=get_instance();
    
$lang_app $ci->session->userdata('lapak_lang');
    
$lang_system $ci->config->item('language');
            
    if(!empty(
$lang_app) || !empty($lang_system)){
        $ci
->config->set_item('language'$lang_system); 
        
$ci->session->set_userdata('lapak_lang',$lang_app);
    
}else{
        $ci
->config->set_item('language''english'); 
        
$ci->session->set_userdata('lapak_lang','en-US');
    
}
    $ci
->lang->load($lang_file$ci->session->userdata('lapak_lang'));

example controller to select lang and redirect to current page

<?php
class language extends Controller {
    
function __construct(){
        parent
::__construct();
    
}
    
    
function index(){
        redirect
('home');
    
}
    
    
function select(){
        $r 
$this->uri->segment(4);
        
$redirect=explode('_',$r);
        
        if(empty(
$r) ){
            $redirect 
'home';
        
}else{
            $redirect
=implode('/',$redirect);
        
}
        $lang 
$this->uri->segment(3);
        
        
//echo $redirect;
        //exit;
        
        
if($lang=='us')
            $this
->config->set_item('language''english'); 
            
$this->config->set_item('lapak_lang''en-US'); 
            
            
$this->session->set_userdata('lapak_lang''en-US');
        
}
        
if($lang=='id')
            $this
->config->set_item('language''indonesian'); 
            
$this->config->set_item('lapak_lang''id'); 
            
            
$this->session->set_userdata('lapak_lang''id');
        
}
        
        redirect
($redirect);
        
    
}

In my view file i put anchor like this

<?php 
$str 
str_replace('/','_',$this->uri->uri_string());
$lnk_id base_url()."language/select/id/".$str;
$lnk_us base_url()."language/select/us/".$str;
?>
<?php 
echo $this->lang->line('l_Lang')?> 
<a href="<?=$lnk_us?>id="btnUS">&nbsp;</a> <a href="<?=$lnk_id?>id="btnID">&nbsp;</a

what do you think about my solution?

 Signature 

Computer Science Student
Freelance Application Developer
NuAzul
blogNuAzul

Profile
 
 
Posted: 01 July 2010 02:22 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  8
Joined  06-21-2010

Maybe we could also try that one….So far i couldn’t think of a better idea…

Profile
 
 
   
 
 
‹‹ Mosso Hosting      In Texas ››