[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;
}
}