...

View Full Version : still havent resolved language problem



likon
08-08-2008, 07:49 AM
<?php

$default_lang= 'fr';

if (isset($_GET['lang'])) { $language = $_GET['lang']; } else { $language = $default_lang; }


$text[1]['en'] = "Last version";
$text[1]['fr'] = "Derni&egrave;re";


echo $text[1][$language];



function set_link ( $base_url, $language, $text ) {
return '<a href=\"".$baseurl."?lang=".$language."\"">".$text."</a>';
}

$current_url= $_SERVER['PHP_SELF'];
set_link( $current_url, "fr", "French");
set_link( $current_url, "en", "English");
?>

Instead of using session or cookies, I am trying to embed ?lang=$language into links . which these links set as trigger for 2 different language

but it i think my function set_link does not work properly.

either the return part was not right . or.. i am confused.

help me ?
thanks

oesxyl
08-08-2008, 08:21 AM
function set_link ( $base_url, $language, $text ) {
return '<a href=\"".$baseurl."?lang=".$language."\"">".$text."</a>';
}
?>

typo in function set_link, href must be $base_url not $baseurl

regards

likon
08-08-2008, 08:22 AM
i think i should use echo instead of return .
but apparently i still have problem with escaping the " to what i want . as normal <a href >


any help is appreciated.

thanks

oesxyl
08-08-2008, 08:28 AM
i think i should use echo instead of return .
but apparently i still have problem with escaping the " to what i want . as normal <a href >
any help is appreciated.

thanks
sorry, is my fault, I didn't look closer to quotes, :)



function set_link($base_url, $language, $text){
return '<a href="'.$baseurl.'"?lang='.$language.'">'.$text.'</a>';
}

return is ok, in my opinion but this way:


$current_url= $_SERVER['PHP_SELF'];
echo set_link( $current_url, "fr", "French");
echo set_link( $current_url, "en", "English");


regards

likon
08-08-2008, 08:48 AM
<?php

$default_lang= 'fr';

if (isset($_GET['lang'])) { $language = $_GET['lang']; } else { $language = $default_lang; }


$text[1]['en'] = "Last version";
$text[1]['fr'] = "Derni&egrave;re";


echo $text[1][$language];



function set_link($base_url, $language, $text){
return '<a href="'.$base_url.'"?lang='.$language.'">'.$text.'</a>';
}

$current_url= $_SERVER['PHP_SELF'];
$text= "test link name";
echo set_link( $current_url, "fr", "French");
echo set_link( $current_url, "en", "English");
?>

should the code become like this ?
the <a href somehow does not show ?lang ?
the escape seems right though ?

likon
08-08-2008, 08:50 AM
never mind . just remove the " in between base_url and ? lang.

thanks a lot oesxyl

oesxyl
08-08-2008, 06:06 PM
never mind . just remove the " in between base_url and ? lang.

thanks a lot oesxyl
sorry is my fault I didn't see it, :)

regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum