RE: [PHP] problem with if statement and language.
| From: | Lawrence dot Sheed at dfait-maeci dot gc dot ca | Date: | Tue, 03 Oct 2000 14:25:03 +0000 |
| Subject: | RE: [PHP] problem with if statement and language. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18421@lists.php.net to get a copy of this message | ||
2 Problems
1st problem
if (x == y)
not
if (x = y)
What you are effectively doing is
if ($HTTP_ACCEPT_LANGUAGE = "de") {
$HTTP_ACCEPT_LANGUAGE = "de"
if true then ...
Change it to
if ($HTTP_ACCEPT_LANGUAGE == "de" ) {
}
elseif ($HTTP_ACCEPT_LANGUAGE == "en" ) {
}
elseif (... etc) {
}
or use case
case ($HTTP_ACCEPT_LANGUAGE) {
"de":
break;
"en":
break;
}
(check the exact syntax, its off the top of my head!)
Also, unfortunately:
Check what $HTTP_ACCEPT_LANGUAGE is returning before doubting your code.
It differs based on what windows version, what browser version etc (if
microsoft). Unfortunately they didn't do it according to the spec's so you
can't really depend on the http_accept_language variable.
I usually have an entry screen with a language selection on that, you can
pop that up for the user if the language cookie isn't set, and then use that
setting for the rest of the time.
-----Original Message-----
From: Daniel Rezny [mailto:daniel@mail.viapvt.sk]
Sent: October 3, 2000 5:56 PM
To: php-general@lists.php.net
Subject: [PHP] problem with if statement and language.
Hello all,
I want to try a multilingual page and now I want to create it with
$HTTP_ACCEPT_LANGUAGE variable. So I made this:
if ($HTTP_ACCEPT_LANGUAGE = "de") {
$lang="d";
$Language=$lang."_text";
setcookie("LUWA_LANGUAGE",$lang);
require("order5.inc.php3");
}
else {
if ($HTTP_ACCEPT_LANGUAGE = "en") {
$lang="e";
$Language=$lang."_text";
setcookie("LUWA_LANGUAGE",$lang);
require("order5.inc.php3");
}
I have in one file default language and I included it before. And this
is not working. If I have english computer gives me german.
Some help or suggestions?
THX a lot
--
Best regards,
Daniel mailto:daniel@mail.viapvt.sk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net